From: Takashi Iwai Subject: Re: How to transfer data to the endpoint (e.g. .wav file) in alsa external I/O plugin Date: Tue, 08 Nov 2016 15:49:53 +0100 Message-ID: References: Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 506BF2657A6 for ; Tue, 8 Nov 2016 15:49:54 +0100 (CET) In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Hermes Zhang Cc: "alsa-devel@alsa-project.org" List-Id: alsa-devel@alsa-project.org On Tue, 08 Nov 2016 07:45:07 +0100, Hermes Zhang wrote: > > Hi, > > I'm a new in alsa plugin develop. Now I'm try to implement an I/O plugin for my platform in alsa. I can config the alsa plugin and start it, but when I'm deal with the data in the transfer api, I could not flush the data to the endpoint, e.g. .wav file. > > I run below command to test my plugin: > > arecord -D my_plug -c 1 -f S16_LE raw > > I want to save the audio data to a wav file by my plugin. Then in my code, I try to write the data to the area structure like this: > > static snd_pcm_sframes_t > my_read (snd_pcm_ioplug_t * io, > const snd_pcm_channel_area_t * areas, > snd_pcm_uframes_t offset, snd_pcm_uframes_t size) > { > /* I got the audio data from other api here */ > > memcpy(areas->addr + areas->first + areas->step * offset, my_data, size); Both the first and the step fields are in bits, not in bytes. You need to divide by 8: areas->addr + (areas->first + areas->step * offset) / 8 Takashi