All of lore.kernel.org
 help / color / mirror / Atom feed
* SEGFAULT : snd_pcm_mmap_begin/commit
@ 2010-11-16  8:44 Irfan Shaikh
  2010-11-16  8:59 ` David Henningsson
  0 siblings, 1 reply; 3+ messages in thread
From: Irfan Shaikh @ 2010-11-16  8:44 UTC (permalink / raw)
  To: alsa-devel@alsa-project.org

Hello All,

I have been facing dificulty in using snd_pcm_mmap_begin and snd_pcm_mmap_commit.
Shows Seg fault as pointed by comment in code below.
Please tell me what wrong i am doing and how do i correct.

/###################################################################################/
        unsigned int count = (alsaParams->frames/(((alsaParams->bit_per_sample)*(alsaParams->num_channel)) / 8));
        unsigned char *data = alsaParams->data;https://owa.sasken.com/owa/?ae=Item&t=IPM.Note&a=New#
        snd_pcm_sframes_t frames_available, frames_transmit;
        const snd_pcm_channel_area_t *area;
        snd_pcm_uframes_t offset;
        char *outbuffer;
        int result;

        /*available space in audio-buffer to write to*/
        frames_available = snd_pcm_avail_update(alsaParams->pcm_handle);

        /*
         * 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
         * frames_transmit are less than frames_available
         */
        frames_transmit = frames_available;

        snd_pcm_mmap_begin(alsaParams->pcm_handle, &area, &offset, &frames_transmit);

        /*calculates the mmaped-buffer which could be written to*/
        outbuffer = ((char *) area->addr + (area->first + area->step * offset)/ 8);    // ****** SEGFAULT *******

        /*gives back the virtually written (writable) frames which should be always == frames_transmit*/
        result = snd_pcm_mmap_commit(alsaParams->pcm_handle, offset, frames_transmit);

        memcpy(outbuffer, data, count);  //data is actual data

I think if above code works fine should play sound.
/###################################################################################/

SASKEN BUSINESS DISCLAIMER: This message may contain confidential, proprietary or legally privileged information. In case you are not the original intended Recipient of the message, you must not, directly or indirectly, use, disclose, distribute, print, or copy any part of this message and you are requested to delete it and inform the sender. Any views expressed in this message are those of the individual sender unless otherwise stated. Nothing contained in this message shall be construed as an offer or acceptance of any offer by Sasken Communication Technologies Limited ("Sasken") unless sent with that express intent and with due authority of Sasken. Sasken has taken enough precautions to prevent the spread of viruses. However the company accepts no liability for any damage caused by any 
 virus transmitted by this email.
Read Disclaimer at http://www.sasken.com/extras/mail_disclaimer.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-11-16  9:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-16  8:44 SEGFAULT : snd_pcm_mmap_begin/commit Irfan Shaikh
2010-11-16  8:59 ` David Henningsson
2010-11-16  9:18   ` Irfan Shaikh

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.