Hi all, I met a problem about period_time/buffer_time on PXA with ASOC enabled. The kernel version is 2.6.21.
The Audio stream is 32k which is not supported by PXA ASOC driver. Please refer following RATES definition for PXA2xx.
#define PXA2XX_AC97_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\ SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 | \ SNDRV_PCM_RATE_48000)
So I set plughw as default ALSA device enable auto samplerate conversion.
The code to set the period_time/buffer_time is as following:
err = snd_pcm_hw_params_set_rate_near(hPCM, params, &rate, 0); if (err < 0) { error("Rate not available: %d\n", rate); return err; }
err = snd_pcm_hw_params_get_buffer_time_max(params, &buffer_time, 0); if (buffer_time > 500000) buffer_time = 500000;
buffer_time = 400000; period_time = buffer_time/4;
err = snd_pcm_hw_params_set_buffer_time_near(hPCM, params, &buffer_time, 0); if (err < 0) { error("Buffer time not available: %d, error number: %d\n", buffer_time, err); return err; }
err = snd_pcm_hw_params_set_period_time_near(hPCM, params, &period_time, 0); if (err < 0) { error("Period time not available: %d\n", period_time); return err; }
If I set buffer_time to 400000, I will get: " Buffer time not available: 400000, error number: -22
Cannot init audio driver. Floating point exception " If I set buffer time to 500000, buffer_time can be set correctly. But audio playback failed.
If I set period_time before setting buffer_time, Everything is OK.
Any thought about this problem. Thanks.
Regards Yin, Fengwei