aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-10-23 20:54:52 +0200
committerMax Kellermann <max@duempel.org>2008-10-23 20:54:52 +0200
commit5fefa954a32cb8bae15df12d4ffdfe23c86c3802 (patch)
tree072af373afff2448cdc8642ddc2f6aeae08082c5
parent4eadb0f7aafe18d5e6032e202444afcaf8955eec (diff)
downloadmpd-5fefa954a32cb8bae15df12d4ffdfe23c86c3802.tar.gz
mpd-5fefa954a32cb8bae15df12d4ffdfe23c86c3802.tar.xz
mpd-5fefa954a32cb8bae15df12d4ffdfe23c86c3802.zip
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.
-rw-r--r--src/player_thread.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/player_thread.c b/src/player_thread.c
index bef3c9194..21f88cc77 100644
--- a/src/player_thread.c
+++ b/src/player_thread.c
@@ -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;
}
}