audio: don't try to send partial samples to AO at EOF

At least with PCM it's possible to get an audio stream that doesn't
end at a multiple of whole sample per channel. At least ao_alsa
refuses to accept that part of input, and so EOF detection in
fill_audio_out_buffers didn't trigger until the 0.04 second sanity
check (as there "was still audio not sent to AO left"). Change the
logic to detect EOF if there's less than one sample per channel of
unsent data left.
This commit is contained in:
Uoti Urpala 2010-11-12 11:54:08 +02:00
parent e7d3e63a3f
commit a66cce61ad
1 changed files with 2 additions and 1 deletions

View File

@ -2170,7 +2170,8 @@ static int fill_audio_out_buffers(struct MPContext *mpctx)
format_change = true;
else if (mpctx->d_audio->eof) {
audio_eof = 1;
if (sh_audio->a_out_buffer_len == 0)
int unitsize = ao_data.channels * af_fmt2bits(ao_data.format) / 8;
if (sh_audio->a_out_buffer_len < unitsize)
return 0;
}
}