diff options
author | wm4 <wm4@nowhere> | 2014-02-09 16:21:17 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-02-12 22:33:03 +0100 |
commit | d42212cd679d99e2c865d84c618c1e661cd5fa16 (patch) | |
tree | cb68782f33b7c8f86f1de961d400bc7e6a41040b | |
parent | 674cc1d3a93d2bfb8e1964d26f4e073af74f0c24 (diff) | |
download | mpv-d42212cd679d99e2c865d84c618c1e661cd5fa16.tar.bz2 mpv-d42212cd679d99e2c865d84c618c1e661cd5fa16.tar.xz |
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.
-rw-r--r-- | player/audio.c | 3 |
1 files changed, 3 insertions, 0 deletions
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) { |