[alsa-devel] Accessing pcm samples from snd_pcm_channel_area_t in an io type plugin

Pharaoh . pharaoh137 at gmail.com
Fri Mar 21 02:46:54 CET 2008


I am writing an external io type plugin for an ARM based board. In the
transfer function
of the plugin, I try to grab the audio samples in a temp buffer and send it
to the DSP in
chunks of period sizes. Somehow the the alsa buffer's audio samples are not
copied to the
temp buffer which I want to send further.

What I do to copy the buffers,
static snd_pcm_sframes_t my_transfer(snd_pcm_ioplug_t *io,
                   const snd_pcm_channel_area_t *areas,
                   snd_pcm_uframes_t offset,
                   snd_pcm_uframes_t size)

    char *temp = NULL;
    temp = malloc(io->period_size * frame_size);  //For malloc,

    //I tried all the three approaches here one by one, including the
malloc/memcpy one
    1. memcpy(temp,areas->addr+ offset*io->channels*2, io->period_size *
    2. memcpy(temp, (char *)areas->addr + (areas->first + areas->step *
offset) /8, io->period_size * frame_size);
    //This should work straight off....
    3. temp = (char *)areas->addr + (areas->first + areas->step * offset) /

    //write temp to DSP here

Somehow the empty buffers are being sent to DSP, when I try to send some
data from a static array then it goes
to DSP and is played well. Any idea what I am missing?


More information about the Alsa-devel mailing list