player: don't send partial frames of silence

Another partial frame fix: the silence buffer was 1020 bytes, which
had room for 127.5 24 bit stereo frames.  Don't send the partial last
frame in this case.
This commit is contained in:
Max Kellermann 2008-10-23 20:54:52 +02:00
parent 4eadb0f7aa
commit 5fefa954a3
1 changed files with 7 additions and 1 deletions

View File

@ -428,8 +428,14 @@ static void do_play(void)
} else if (decoder_is_idle()) {
break;
} else {
size_t frame_size =
audio_format_frame_size(&pc.audio_format);
/* this formula ensures that we don't send
partial frames */
unsigned num_frames = CHUNK_SIZE / frame_size;
/*DEBUG("waiting for decoded audio, play silence\n");*/
if (playAudio(silence, CHUNK_SIZE) < 0)
if (playAudio(silence, num_frames * frame_size) < 0)
break;
}
}