mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-09-20 13:08:50 +02:00
deps/media-playback: Reset TS when seeking
If seeking occurs too close to the previous time value, it could cause the playback to delay an abnormal amount of time, or if the time value is under the previous value, then it would cause an assert. So instead, reset the next timestamp value to be instant in both cases if a seek occurs to ensure timely playback.
This commit is contained in:
parent
2ba2df6e59
commit
56e56cd265
8
deps/media-playback/media-playback/media.c
vendored
8
deps/media-playback/media-playback/media.c
vendored
@ -419,6 +419,11 @@ static void mp_media_calc_next_ns(mp_media_t *m)
|
|||||||
{
|
{
|
||||||
int64_t min_next_ns = mp_media_get_next_min_pts(m);
|
int64_t min_next_ns = mp_media_get_next_min_pts(m);
|
||||||
int64_t delta = min_next_ns - m->next_pts_ns;
|
int64_t delta = min_next_ns - m->next_pts_ns;
|
||||||
|
|
||||||
|
if (m->seek_next_ts) {
|
||||||
|
delta = 0;
|
||||||
|
m->seek_next_ts = false;
|
||||||
|
} else {
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
assert(delta >= 0);
|
assert(delta >= 0);
|
||||||
#endif
|
#endif
|
||||||
@ -426,6 +431,7 @@ static void mp_media_calc_next_ns(mp_media_t *m)
|
|||||||
delta = 0;
|
delta = 0;
|
||||||
if (delta > 3000000000)
|
if (delta > 3000000000)
|
||||||
delta = 0;
|
delta = 0;
|
||||||
|
}
|
||||||
|
|
||||||
m->next_ns += delta;
|
m->next_ns += delta;
|
||||||
m->next_pts_ns = min_next_ns;
|
m->next_pts_ns = min_next_ns;
|
||||||
@ -473,6 +479,7 @@ static bool mp_media_reset(mp_media_t *m)
|
|||||||
|
|
||||||
m->eof = false;
|
m->eof = false;
|
||||||
m->base_ts += next_ts;
|
m->base_ts += next_ts;
|
||||||
|
m->seek_next_ts = false;
|
||||||
|
|
||||||
pthread_mutex_lock(&m->mutex);
|
pthread_mutex_lock(&m->mutex);
|
||||||
stopping = m->stopping;
|
stopping = m->stopping;
|
||||||
@ -684,6 +691,7 @@ static inline bool mp_media_thread(mp_media_t *m)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (seek) {
|
if (seek) {
|
||||||
|
m->seek_next_ts = true;
|
||||||
seek_to(m, seek_pos);
|
seek_to(m, seek_pos);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
1
deps/media-playback/media-playback/media.h
vendored
1
deps/media-playback/media-playback/media.h
vendored
@ -98,6 +98,7 @@ struct mp_media {
|
|||||||
bool pause;
|
bool pause;
|
||||||
bool reset_ts;
|
bool reset_ts;
|
||||||
bool seek;
|
bool seek;
|
||||||
|
bool seek_next_ts;
|
||||||
int64_t seek_pos;
|
int64_t seek_pos;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user