summaryrefslogtreecommitdiffstats
path: root/player/loadfile.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-03-09 01:20:36 +0100
committerwm4 <wm4@nowhere>2014-03-09 01:27:42 +0100
commit7b6e211e63e3cc3e53cc58360b9067f98489d892 (patch)
treeaf56949fd8ac2f77fea2189539cb527960e4e9c2 /player/loadfile.c
parente16c91d07ab2acfb83fdeaa6dcfcd25c97666504 (diff)
downloadmpv-7b6e211e63e3cc3e53cc58360b9067f98489d892.tar.bz2
mpv-7b6e211e63e3cc3e53cc58360b9067f98489d892.tar.xz
audio: remove handling of partially written data
Remove the ao_buffer_playable_samples field. This contained the number of samples that fill_audio_out_buffers() wanted to write to the AO (i.e. this data was supposed to be played at some point), but ao_play() rejected it due to partial fill. This could happen with many AOs, notably those which align all written data to an internal period size (often called "outburst" in the AO code), and the accepted number of samples is rounded down to period boundaries. The left-over samples at the end were still kept in mpctx->ao_buffer, and had to be played later. The reason ao_buffer_playable_samples had to exist was to make sure that at EOF, the correct number of left-over samples was played (and not possibly other data in the buffer that had to be sliced off due to endpts in fill_audio_out_buffers()). (You'd think you could just slice the entire buffer, but I suspect this wasn't done because the end time could actually change due to A/V sync changes. Maybe that was the reason it's so complicated.) Some commits ago, ao.c gained internal buffering, and ao_play() will never return partial writes - as long as you don't try to write more samples than ao_get_space() reports. This is always the case. The only exception is filling the audio buffers while paused. In this case, we decode and play only 1 sample in order to initialize decoding (e.g. on seeking). Actually playing this 1 sample is in fact a bug, but even of the AO doesn't have period size alignment, you won't notice it. In summary, this means we can safely remove the code.
Diffstat (limited to 'player/loadfile.c')
-rw-r--r--player/loadfile.c13
1 files changed, 1 insertions, 12 deletions
diff --git a/player/loadfile.c b/player/loadfile.c
index 89f893cc25..05f4646d0a 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -174,19 +174,8 @@ void uninit_player(struct MPContext *mpctx, unsigned int mask)
mpctx->initialized_flags &= ~INITIALIZED_AO;
if (ao) {
// Note: with gapless_audio, stop_play is not correctly set
- if (opts->gapless_audio || mpctx->stop_play == AT_END_OF_FILE) {
- struct mp_audio data;
- mp_audio_buffer_peek(mpctx->ao_buffer, &data);
- int samples = mpctx->ao_buffer_playable_samples;
- assert(samples <= data.samples);
- if (samples > 0) {
- int played = ao_play(ao, data.planes, samples,
- AOPLAY_FINAL_CHUNK);
- if (played < samples)
- MP_WARN(mpctx, "Audio output truncated at end.\n");
- }
+ if (opts->gapless_audio || mpctx->stop_play == AT_END_OF_FILE)
ao_drain(ao);
- }
ao_uninit(ao);
}
mpctx->ao = NULL;