From 22a233161f3ab4eb5f0dd7dce32e68e6cb79b188 Mon Sep 17 00:00:00 2001 From: Ross Bencina Date: Sun, 12 May 2019 22:01:29 +1000 Subject: [PATCH] set dir=0 prior to passing its address in to ALSA function in _PA_LOCAL_IMPL(snd_pcm_hw_params_get_buffer_size_max) as is done elsewhere in the code. mark all places in the code where dir is not set dir=0 prior to passing in to ALSA function (i.e. where the previous value returned by ALSA is used. Are these omissions or is it intentional to use the rounding mode of the previous call? --- src/hostapi/alsa/pa_linux_alsa.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/hostapi/alsa/pa_linux_alsa.c b/src/hostapi/alsa/pa_linux_alsa.c index b5bdd3a..09a1e61 100644 --- a/src/hostapi/alsa/pa_linux_alsa.c +++ b/src/hostapi/alsa/pa_linux_alsa.c @@ -323,8 +323,10 @@ int _PA_LOCAL_IMPL(snd_pcm_hw_params_get_buffer_size_max) (const snd_pcm_hw_para snd_pcm_uframes_t pmax = 0; unsigned int pcnt = 0; + dir = 0; if(( ret = _PA_LOCAL_IMPL(snd_pcm_hw_params_get_period_size_max)(params, &pmax, &dir) ) < 0 ) return ret; + /* REVIEW: why no dir=0 here? is it intended to use the rounding mode of get_period_size_max? either set dir=0 or add explanatory comment. -- rossb 12 May 2019 */ if(( ret = _PA_LOCAL_IMPL(snd_pcm_hw_params_get_periods_max)(params, &pcnt, &dir) ) < 0 ) return ret; @@ -2323,6 +2325,7 @@ static PaError PaAlsaStreamComponent_DetermineFramesPerBuffer( PaAlsaStreamCompo /* It may be that the device only supports 2 periods for instance */ dir = 0; ENSURE_( alsa_snd_pcm_hw_params_get_periods_min( hwParams, &minPeriods, &dir ), paUnanticipatedHostError ); + /* REVIEW: why no dir=0 here? is it intended to use the rounding mode of get_periods_min? either set dir=0 or add explanatory comment. -- rossb 12 May 2019 */ ENSURE_( alsa_snd_pcm_hw_params_get_periods_max( hwParams, &maxPeriods, &dir ), paUnanticipatedHostError ); assert( maxPeriods > 1 ); @@ -3208,6 +3211,7 @@ error: unsigned int _min = 0, _max = 0; int _dir = 0; ENSURE_( alsa_snd_pcm_hw_params_get_rate_min( hwParams, &_min, &_dir ), paUnanticipatedHostError ); + /* REVIEW: why no dir=0 here? is it intended to use the rounding mode of get_rate_min? either set dir=0 or add explanatory comment -- rossb 12 May 2019 */ ENSURE_( alsa_snd_pcm_hw_params_get_rate_max( hwParams, &_max, &_dir ), paUnanticipatedHostError ); PA_DEBUG(( "%s: SR min = %u, max = %u, req = %u\n", __FUNCTION__, _min, _max, reqRate )); } -- 2.43.0