alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* Direct write (using mmap_bigin and commit)
@ 2010-11-15 12:24 Irfan Shaikh
  2010-11-15 13:22 ` Jaroslav Kysela
  2010-11-16  7:10 ` David Henningsson
  0 siblings, 2 replies; 4+ messages in thread
From: Irfan Shaikh @ 2010-11-15 12:24 UTC (permalink / raw)
  To: alsa-devel@alsa-project.org

Hello,

         I am reading an raw PCM  file and want to write on PCM device using direct write (interleaved). I have gone through PCM.c test application.
I am trying tio write PCM audio data as follows. I am unable to use  snd_pcm_mmap_begin and snd_pcm_mmap_commit properly. Please help me to use using these APIs
Question :
1) How can i write to Ring buffer area (any pcm audio data)?  //Any example or explanation other than pcm.c
2) Do i need to write diffferently for each channel as shown in pcm.c

I am trying to do following but not succeded (reading pcm file and writing content on device) . ANy thing played on audio device would help me in understanding.

        snd_pcm_channel_area_t my_areas;
        snd_pcm_uframes_t offset, frames, size;
        snd_pcm_sframes_t avail, commitres;
        int result;
        char *buffer;

        while(1)
        {
            avail = snd_pcm_avail_update(handle);
            if(avail>=period_size)
            {
                size=periodsize
                while (size > 0) {
                        frames = size;
                        err = snd_pcm_mmap_begin(handle, &my_areas, &offset, &frames);
                        mybuffer=(char *)malloc(frames*2);
                        result = fread (mybuffer,1,(frames*2),pFile);
                        my_areas.addr=mybuffer;           // IS THIS CORRECT ? WILL THIS WORK ? How can i write my audio file data here in areas?
                        commitres = snd_pcm_mmap_commit(handle, offset, frames);
            }
        }

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] 4+ messages in thread

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

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-15 12:24 Direct write (using mmap_bigin and commit) Irfan Shaikh
2010-11-15 13:22 ` Jaroslav Kysela
2010-11-16  5:51   ` Irfan Shaikh
2010-11-16  7:10 ` David Henningsson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).