From 8f41a72aea03e74a94a3024de7ac4eaf71687b87 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Wed, 18 Feb 2004 07:29:41 +0000 Subject: [PATCH] xfer_align fix --- stepmania/src/arch/Sound/ALSA9Helpers.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/stepmania/src/arch/Sound/ALSA9Helpers.cpp b/stepmania/src/arch/Sound/ALSA9Helpers.cpp index 5df87bee5b..6babb3bfa9 100644 --- a/stepmania/src/arch/Sound/ALSA9Helpers.cpp +++ b/stepmania/src/arch/Sound/ALSA9Helpers.cpp @@ -229,9 +229,17 @@ Alsa9Buf::~Alsa9Buf() /* Don't fill the buffer any more than than "writeahead". Don't write any - * more than "chunksize" at a time. */ + * more than "chunksize" at a time. (These numbers are hints; if the hardware + * parameters require it, they can be ignored.) */ int Alsa9Buf::GetNumFramesToFill( snd_pcm_sframes_t writeahead, snd_pcm_sframes_t chunksize ) { + /* We have to write at least xfer_align bytes. */ + chunksize = max( chunksize, xfer_align ); + + /* Make sure we can write ahead at least two chunks. Otherwise, we'll only + * fill one chunk ahead, and underrun. */ + writeahead = max( writeahead, chunksize*2 ); + snd_pcm_sframes_t avail_frames = dsnd_pcm_avail_update(pcm); if( avail_frames > total_frames )