From 83104faa0b262531128053db71bdcff08229073d Mon Sep 17 00:00:00 2001 From: larsimmisch Date: Wed, 22 Apr 2009 22:10:14 +0000 Subject: [PATCH] Modified version of patch 2594366. git-svn-id: svn://svn.code.sf.net/p/pyalsaaudio/code/trunk@30 ec2f30ec-7544-0410-870e-f70ca00c83f0 --- alsaaudio.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/alsaaudio.c b/alsaaudio.c index 3a903e0..4190634 100644 --- a/alsaaudio.c +++ b/alsaaudio.c @@ -183,16 +183,23 @@ static int alsapcm_setup(alsapcm_t *self) snd_pcm_hw_params_set_access(self->handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED); snd_pcm_hw_params_set_format(self->handle, hwparams, self->format); - snd_pcm_hw_params_set_channels(self->handle, hwparams, self->channels); + res = snd_pcm_hw_params_set_channels(self->handle, hwparams, + self->channels); + if (res < 0) return res; + dir = 0; - snd_pcm_hw_params_set_rate(self->handle, hwparams, self->rate, dir); - snd_pcm_hw_params_set_period_size(self->handle, hwparams, + res = snd_pcm_hw_params_set_rate(self->handle, hwparams, self->rate, dir); + if (res < 0) return res; + + res = snd_pcm_hw_params_set_period_size(self->handle, hwparams, self->periodsize, dir); - snd_pcm_hw_params_set_periods(self->handle, hwparams, 4, 0); + if (res < 0) return res; + + res = snd_pcm_hw_params_set_periods(self->handle, hwparams, 4, 0); + if (res < 0) return res; /* Write it to the device */ res = snd_pcm_hw_params(self->handle, hwparams); - if (res) return res; /* Query current settings. These may differ from the requested values, which should therefore be sync'ed with actual values */