On Mon, Sep 18, 2006 at 01:58:59AM +0200, Jan Zerebecki wrote: > I explained in a different mail to this thread what bugs are in > winealsa. (Archive link to that mail is: > http://www.winehq.org/pipermail/wine-devel/2006-September/050826.html )
> It seems I just found out how to fix the other winealsa problem I > mentioned in that mail, I'm currently testing if it works. The intention is to get the same buffer size (in bytes) for different formats, because dsound expects this (according to our dsound tests). I tried with the attached patch but snd_pcm_hw_params_set_buffer_size_near sets different than the requested size and snd_pcm_hw_params_set_buffer_size doesn't work at all. I don't know if this is because I am not familiar with the api or because of a bug in it. Can anyone shed some light on this who is more familiar with the alsa-lib api? Jan
From: Jan Zerebecki <[EMAIL PROTECTED]> Changelog: winmm/winealsa: set buffer size --- dlls/winmm/winealsa/audio.c | 17 ++++++++--------- 1 files changed, 8 insertions(+), 9 deletions(-) diff --git a/dlls/winmm/winealsa/audio.c b/dlls/winmm/winealsa/audio.c index 9eec364..d29e596 100644 --- a/dlls/winmm/winealsa/audio.c +++ b/dlls/winmm/winealsa/audio.c @@ -2334,10 +2334,8 @@ static DWORD wodOpen(WORD wDevID, LPWAVE snd_pcm_access_t access; snd_pcm_format_t format = -1; unsigned int rate; - unsigned int buffer_time = 500000; - unsigned int period_time = 10000; - snd_pcm_uframes_t buffer_size; - snd_pcm_uframes_t period_size; + snd_pcm_uframes_t buffer_size = 48000; + snd_pcm_uframes_t period_size = 1024; int flags; int err=0; int dir=0; @@ -2561,15 +2559,16 @@ #define EXIT_ON_ERROR(f,e,txt) do \ wwo->format.Format.nChannels, getFormat(wwo->format.Format.wFormatTag)); - dir=0; - EXIT_ON_ERROR( snd_pcm_hw_params_set_buffer_time_near(pcm, hw_params, &buffer_time, &dir), MMSYSERR_INVALPARAM, "unable to set buffer time"); - dir=0; - EXIT_ON_ERROR( snd_pcm_hw_params_set_period_time_near(pcm, hw_params, &period_time, &dir), MMSYSERR_INVALPARAM, "unable to set period time"); + buffer_size = buffer_size / ( snd_pcm_format_physical_width(format) * wwo->format.Format.nChannels ); + snd_pcm_uframes_t buffer_size_old = buffer_size; + EXIT_ON_ERROR( snd_pcm_hw_params_set_buffer_size_near(pcm, hw_params, &buffer_size), MMSYSERR_INVALPARAM, "unable to set buffer size"); + dir=0; + EXIT_ON_ERROR( snd_pcm_hw_params_set_period_size_near(pcm, hw_params, &period_size, &dir), MMSYSERR_INVALPARAM, "unable to set period time"); + if(buffer_size != buffer_size_old) ERR("buffer_size:%i buffer_size_old:%i\n", (int)buffer_size, (int)buffer_size_old); EXIT_ON_ERROR( snd_pcm_hw_params(pcm, hw_params), MMSYSERR_INVALPARAM, "unable to set hw params for playback"); err = snd_pcm_hw_params_get_period_size(hw_params, &period_size, &dir); - err = snd_pcm_hw_params_get_buffer_size(hw_params, &buffer_size); snd_pcm_sw_params_current(pcm, sw_params); EXIT_ON_ERROR( snd_pcm_sw_params_set_start_threshold(pcm, sw_params, dwFlags & WAVE_DIRECTSOUND ? INT_MAX : 1 ), MMSYSERR_ERROR, "unable to set start threshold");