mirror of
https://github.com/mpv-player/mpv
synced 2024-12-23 15:22:09 +00:00
audio: minor improvements to timeline switching
In theory, timestamps can be negative, so we shouldn't just return -1 as special value. Remove the separate code for clearing decode buffers; use the same code that is used for normal seek reset.
This commit is contained in:
parent
b55e093075
commit
21f52aeeba
@ -537,10 +537,3 @@ void clear_audio_output_buffers(struct MPContext *mpctx)
|
|||||||
mp_audio_buffer_clear(mpctx->ao_buffer);
|
mp_audio_buffer_clear(mpctx->ao_buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Drop decoded data queued for filtering.
|
|
||||||
void clear_audio_decode_buffers(struct MPContext *mpctx)
|
|
||||||
{
|
|
||||||
if (mpctx->d_audio)
|
|
||||||
mp_audio_buffer_clear(mpctx->d_audio->decode_buffer);
|
|
||||||
}
|
|
||||||
|
@ -365,7 +365,6 @@ double playing_audio_pts(struct MPContext *mpctx);
|
|||||||
void fill_audio_out_buffers(struct MPContext *mpctx, double endpts);
|
void fill_audio_out_buffers(struct MPContext *mpctx, double endpts);
|
||||||
double written_audio_pts(struct MPContext *mpctx);
|
double written_audio_pts(struct MPContext *mpctx);
|
||||||
void clear_audio_output_buffers(struct MPContext *mpctx);
|
void clear_audio_output_buffers(struct MPContext *mpctx);
|
||||||
void clear_audio_decode_buffers(struct MPContext *mpctx);
|
|
||||||
|
|
||||||
// configfiles.c
|
// configfiles.c
|
||||||
void mp_parse_cfgfiles(struct MPContext *mpctx);
|
void mp_parse_cfgfiles(struct MPContext *mpctx);
|
||||||
|
@ -391,7 +391,7 @@ double timeline_set_from_time(struct MPContext *mpctx, double pts, bool *need_re
|
|||||||
return pts - p->start + p->source_start;
|
return pts - p->start + p->source_start;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return MP_NOPTS_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int find_new_tid(struct MPContext *mpctx, enum stream_type t)
|
static int find_new_tid(struct MPContext *mpctx, enum stream_type t)
|
||||||
|
@ -188,13 +188,13 @@ static int mp_seek(MPContext *mpctx, struct seek_params seek,
|
|||||||
bool need_reset = false;
|
bool need_reset = false;
|
||||||
demuxer_amount = timeline_set_from_time(mpctx, seek.amount,
|
demuxer_amount = timeline_set_from_time(mpctx, seek.amount,
|
||||||
&need_reset);
|
&need_reset);
|
||||||
if (demuxer_amount == -1) {
|
if (demuxer_amount == MP_NOPTS_VALUE) {
|
||||||
assert(!need_reset);
|
assert(!need_reset);
|
||||||
mpctx->stop_play = AT_END_OF_FILE;
|
mpctx->stop_play = AT_END_OF_FILE;
|
||||||
if (mpctx->d_audio && !timeline_fallthrough) {
|
// When seeking outside of the file, but not when ending last segment.
|
||||||
// Seek outside of the file -> clear audio from current position
|
if (!timeline_fallthrough) {
|
||||||
clear_audio_decode_buffers(mpctx);
|
|
||||||
clear_audio_output_buffers(mpctx);
|
clear_audio_output_buffers(mpctx);
|
||||||
|
reset_playback_state(mpctx);
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user