@ -73,7 +73,8 @@ protected:
snd_pcm_t * m_pcm_playback ;
snd_pcm_t * m_pcm_playback ;
snd_pcm_t * m_pcm_capture ;
snd_pcm_t * m_pcm_capture ;
snd_pcm_format_t m_format ;
snd_pcm_format_t m_format ;
int m_period_size , m_periods ;
snd_pcm_uframes_t m_period_size ;
unsigned m_periods ;
void startIO ( ) ;
void startIO ( ) ;
int setPcmParams ( snd_pcm_t * pcm ) ;
int setPcmParams ( snd_pcm_t * pcm ) ;
@ -540,7 +541,11 @@ int AudioIOALSA::setPcmParams(snd_pcm_t *pcm)
return 1 ;
return 1 ;
}
}
unsigned int rate = snd_pcm_hw_params_set_rate_near ( pcm , hw , _samplingRate , 0 ) ;
unsigned rate = _samplingRate ;
if ( snd_pcm_hw_params_set_rate_near ( pcm , hw , & rate , 0 ) < 0 ) {
_error = " Unable to set sampling rate! " ;
return 1 ;
}
const unsigned int tolerance = _samplingRate / 10 + 1000 ;
const unsigned int tolerance = _samplingRate / 10 + 1000 ;
if ( abs ( ( int ) rate - ( int ) _samplingRate ) > ( int ) tolerance ) {
if ( abs ( ( int ) rate - ( int ) _samplingRate ) > ( int ) tolerance ) {
_error = " Can't set requested sampling rate! " ;
_error = " Can't set requested sampling rate! " ;
@ -562,12 +567,12 @@ int AudioIOALSA::setPcmParams(snd_pcm_t *pcm)
m_period_size < < = 1 ;
m_period_size < < = 1 ;
if ( _channels > 1 )
if ( _channels > 1 )
m_period_size / = _channels ;
m_period_size / = _channels ;
if ( ( m_period_size = snd_pcm_hw_params_set_period_size_near ( pcm , hw , m_period_size , 0 ) ) < 0 ) {
if ( snd_pcm_hw_params_set_period_size_near ( pcm , hw , & m_period_size , 0 ) < 0 ) {
_error = " Unable to set period size! " ;
_error = " Unable to set period size! " ;
return 1 ;
return 1 ;
}
}
m_periods = _fragmentCount ;
m_periods = _fragmentCount ;
if ( ( m_periods = snd_pcm_hw_params_set_periods_near ( pcm , hw , m_periods , 0 ) ) < 0 ) {
if ( snd_pcm_hw_params_set_periods_near ( pcm , hw , & m_periods , 0 ) < 0 ) {
_error = " Unable to set periods! " ;
_error = " Unable to set periods! " ;
return 1 ;
return 1 ;
}
}