- trying to fix specific case of stream failing to open when min/max period is specifying fixed value with +/-1 difference, we try choosing middle then which seems to be aligned to 2
This commit is contained in:
dmitrykos 2010-08-02 10:37:18 +00:00
commit 2b8866cd3d

View file

@ -1696,20 +1696,21 @@ static PaError PaAlsaStreamComponent_DetermineFramesPerBuffer( PaAlsaStreamCompo
{
/* Get min/max period sizes and adjust our chosen */
snd_pcm_uframes_t min = 0, max = 0;
snd_pcm_uframes_t min = 0, max = 0, minmax_diff;
ENSURE_( snd_pcm_hw_params_get_period_size_min( hwParams, &min, NULL ), paUnanticipatedHostError );
ENSURE_( snd_pcm_hw_params_get_period_size_max( hwParams, &max, NULL ), paUnanticipatedHostError );
minmax_diff = max - min;
if( framesPerHostBuffer < min )
{
PA_DEBUG(( "%s: The determined period size (%lu) is less than minimum (%lu)\n", __FUNCTION__, framesPerHostBuffer, min ));
framesPerHostBuffer = min;
framesPerHostBuffer = ((minmax_diff == 2) ? min + 1 : min);
}
else
if( framesPerHostBuffer > max )
{
PA_DEBUG(( "%s: The determined period size (%lu) is greater than maximum (%lu)\n", __FUNCTION__, framesPerHostBuffer, max ));
framesPerHostBuffer = max;
framesPerHostBuffer = ((minmax_diff == 2) ? max - 1 : max);
}
PA_DEBUG(( "%s: device period minimum = %lu\n", __FUNCTION__, min ));
@ -1717,7 +1718,7 @@ static PaError PaAlsaStreamComponent_DetermineFramesPerBuffer( PaAlsaStreamCompo
PA_DEBUG(( "%s: host buffer period = %lu\n", __FUNCTION__, framesPerHostBuffer ));
PA_DEBUG(( "%s: host buffer period latency = %f\n", __FUNCTION__, (double)(framesPerHostBuffer / sampleRate) ));
/* Try set period size */
/* Try setting period size */
dir = 0;
ENSURE_( snd_pcm_hw_params_set_period_size_near( self->pcm, hwParams, &framesPerHostBuffer, &dir ), paUnanticipatedHostError );
if( dir != 0 )