mirror of
https://github.com/mpv-player/mpv
synced 2024-11-14 22:48:35 +01:00
player: fix an assert when reinitializing audio in some cases
This sometimes happened when changing playback speed (= reinitializing audio) after seeking of playback start. The assertion in audio.c:441 was triggered, because buffer_playable_samples wasn't reset correctly when the audio buffer was cleared or shortened. The assertion is correct and should hold up any time.
This commit is contained in:
parent
257d9f1610
commit
c0771b8144
@ -334,11 +334,13 @@ static int audio_start_sync(struct MPContext *mpctx, int playsize)
|
||||
res = audio_decode(d_audio, ao->buffer, a);
|
||||
if (skip_samples <= mp_audio_buffer_samples(ao->buffer)) {
|
||||
mp_audio_buffer_skip(ao->buffer, skip_samples);
|
||||
ao->buffer_playable_samples = 0;
|
||||
if (res < 0)
|
||||
return res;
|
||||
return audio_decode(d_audio, ao->buffer, playsize);
|
||||
}
|
||||
mp_audio_buffer_clear(ao->buffer);
|
||||
ao->buffer_playable_samples = 0;
|
||||
if (res < 0)
|
||||
return res;
|
||||
}
|
||||
@ -442,6 +444,7 @@ int fill_audio_out_buffers(struct MPContext *mpctx, double endpts)
|
||||
mp_audio_buffer_peek(ao->buffer, &data);
|
||||
data.samples = MPMIN(data.samples, playsize);
|
||||
int played = write_to_ao(mpctx, &data, playflags, written_audio_pts(mpctx));
|
||||
assert(played >= 0 && played <= data.samples);
|
||||
ao->buffer_playable_samples = playsize - played;
|
||||
|
||||
if (played > 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user