From d42212cd679d99e2c865d84c618c1e661cd5fa16 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 9 Feb 2014 16:21:17 +0100 Subject: 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. --- player/audio.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/player/audio.c b/player/audio.c index 79d064940b..ec5f82d720 100644 --- a/player/audio.c +++ b/player/audio.c @@ -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) { -- cgit v1.2.3