diff options
author | wm4 <wm4@nowhere> | 2014-07-24 15:26:07 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-07-24 15:26:07 +0200 |
commit | 986099d32356bb2c9520ae32b987e7155be55605 (patch) | |
tree | adede5a57aaf8b7800c50cd2782fd12c6051cce1 /audio/decode/dec_audio.c | |
parent | b77dab0f6e7a43d9a9480626805317df7843bf7a (diff) | |
download | mpv-986099d32356bb2c9520ae32b987e7155be55605.tar.bz2 mpv-986099d32356bb2c9520ae32b987e7155be55605.tar.xz |
audio: fix race condition in EOF code
Don't return an EOF code if there's still buffered data.
Also, don't call demux_stream_eof() in the playloop. There's probably
nothing wrong with it, but it's cleaner not to use it.
Also give AD_EOF its own value, so that a decoding error doesn't drain
audio by causing an EOF condition.
Diffstat (limited to 'audio/decode/dec_audio.c')
-rw-r--r-- | audio/decode/dec_audio.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/audio/decode/dec_audio.c b/audio/decode/dec_audio.c index 4cd823e029..218063a699 100644 --- a/audio/decode/dec_audio.c +++ b/audio/decode/dec_audio.c @@ -274,13 +274,13 @@ static int filter_n_bytes(struct dec_audio *da, struct mp_audio_buffer *outbuf, filter_data.rate = da->afilter->input.rate; // due to playback speed change len = MPMIN(filter_data.samples, len); filter_data.samples = len; - bool eof = filter_data.samples == 0 && error < 0; + bool eof = error == AD_EOF && filter_data.samples == 0; if (af_filter(da->afilter, &filter_data, eof ? AF_FILTER_FLAG_EOF : 0) < 0) return AD_ERR; mp_audio_buffer_append(outbuf, &filter_data); - if (eof && filter_data.samples > 0) + if (error == AD_EOF && filter_data.samples > 0) error = 0; // don't end playback yet // remove processed data from decoder buffer: |