[alsa-devel] Constraining the number of frames per period

Clemens Ladisch clemens at ladisch.de
Fri Oct 22 08:38:11 CEST 2010


Adam Rosenberg wrote:
> I am trying to constrain the number of frames per period (not the number of
> periods).  The DMA transfer creates an interrupt every 512 frames (1 frame =
> 16 channels with 32bits per channel) .  I am having a difficult time
> understanding how to properly write the ALSA driver so that it will work
> with many different formats and between 1 and 2 channels.

Using period_bytes_min/max doesn't work for this situation; these fields
are intended for hardware that has constraints on the number of bytes.

Set the snd_pcm_hardware fields so that all sample formats are supported.
In the PCM devive's open callback, add another constraint by calling
snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, 512, 512);

>     // the max number of bytes in one PCM stream
>     // must allow for a minimum of 4 periods with
>     // 512 frames per period and up to 2 channels of
>     // 32 bit data per frame
>     .buffer_bytes_max = 32768,  // this value allows 8 periods of the max frame size

Are the minimum 4 and maximum 8 periods actual hardware constraints?


Regards,
Clemens


More information about the Alsa-devel mailing list