From 8125252399d9b02a6f143d109a92341ff7eff5a9 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 8 Nov 2013 20:00:58 +0100 Subject: audio: don't let ao_lavc access frontend internals, change gapless audio ao_lavc.c accesses ao->buffer, which I consider internal. The access was done in ao_lavc.c/uninit(), which tried to get the left-over audio in order to write the last (possibly partial) audio frame. The play() function didn't accept partial frames, because the AOPLAY_FINAL_CHUNK flag was not correctly set, and handling it otherwise would require an internal FIFO. Fix this by making sure that with gapless audio (used with encoding), the AOPLAY_FINAL_CHUNK is set only once, instead when each file ends. Basically, move the hack in ao_lavc's uninit to uninit_player. One thing can not be entirely correctly handled: if gapless audio is active, we don't know really whether the AO is closed because the file ended playing (i.e. we want to send the buffered remainder of the audio to the AO), or whether the user is quitting the player. (The stop_play flag is overwritten, fixing that is perhaps not worth it.) Handle this by adding additional code to drain the AO and the buffers when playback is quit (see play_current_file() change). Test case: mpv avdevice://lavfi:sine=441 avdevice://lavfi:sine=441 -length 0.2267 -gapless-audio --- audio/out/ao.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'audio/out/ao.c') diff --git a/audio/out/ao.c b/audio/out/ao.c index 3f0865af22..ccbcc16e88 100644 --- a/audio/out/ao.c +++ b/audio/out/ao.c @@ -198,11 +198,7 @@ autoprobe: void ao_uninit(struct ao *ao, bool cut_audio) { - assert(ao->buffer.len >= ao->buffer_playable_size); - ao->buffer.len = ao->buffer_playable_size; ao->driver->uninit(ao, cut_audio); - if (!cut_audio && ao->buffer.len) - mp_msg(MSGT_AO, MSGL_WARN, "Audio output truncated at end.\n"); talloc_free(ao); } @@ -234,8 +230,6 @@ int ao_get_space(struct ao *ao) void ao_reset(struct ao *ao) { - ao->buffer.len = 0; - ao->buffer_playable_size = 0; if (ao->driver->reset) ao->driver->reset(ao); } -- cgit v1.2.3