Re: [linux-audio-dev] Exact description of PCM system for ALSA

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: Re: [linux-audio-dev] Exact description of PCM system for ALSA
From: joy (joy_AT_pingfm.org)
Date: Wed Jul 17 2002 - 23:16:39 EEST


i finally figured out the magic of snd_pcm_mmap_begin/commit, and
what i did wrong all the time. its really simple, but to figure it out
was somehow a 'long way'.

the baisc steps how i did it now are:

frames_available = snd_pcm_avail_update(alsa_handler)
gets the available space in audio-buffer to write to.

frames_transmit = frames_available;
snd_pcm_mmap_begin(alsa_handler, &area, &offset, &frames_transmit);
prepare the areas and get back area, offset and frames_transmit.
frames_transmit gives back the REAL value of available frames which
could be written to in the mmaped-area. its sometimes for some unknown
reasons < frames_available. this is what i did wrong all the time. i
had the wrong idea that frames_transmit is always == frames_available.

outbuffer = ((char *) area->addr + (area->first + area->step * offset)
/ 8);
this mysterious formula setup and calculates the mmaped-buffer which could be
written to. it works only with '2 chn, Signed 16-bit'-streams for
me. should be modified for 'usigned 8-bit'-streams', but i currently
don't know how.

result = snd_pcm_mmap_commit(alsa_handler, offset, frames_transmit);
gives back the virtually written (writable) frames which should be
always == frames_transmit.

a simple
memcpy(outbuffer, data, result);
finally transfers the current data into the mmaped-buffer.

-- 
regards

____- joy

________/\---------%%%___________----------- webcast every sunday 2000 cest at pingfm.org

pgp key at: x-hkp://wwwkeys.de.pgp.net


New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : Wed Jul 17 2002 - 23:12:36 EEST