From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Miartus, Adam (Arion Recruitment; ADITG/ESM)" Subject: Re: [ALSA patch] FW: [PATCH - alsa-lib 1/4] pcm_file: add support for infile reading in non interleaved mode Date: Tue, 21 May 2019 11:48:46 +0000 Message-ID: References: <1558370831-15960-1-git-send-email-adam.miartus@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from smtp1.de.adit-jv.com (smtp1.de.adit-jv.com [93.241.18.167]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id AC761F89633 for ; Tue, 21 May 2019 13:48:54 +0200 (CEST) In-Reply-To: Content-Language: en-US List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" To: Takashi Iwai Cc: "alsa-devel@alsa-project.org" List-Id: alsa-devel@alsa-project.org > On Mon, 20 May 2019 18:49:34 +0200, > Miartus, Adam (Arion Recruitment; ADITG/ESM) wrote: > > > > From: Adam Miartus > > > > add helper function to copy input file data to buffer mapped by areas, in > case of an error, do not fill the areas, allowing device read buffer to be > provided to api caller > > > > previously unused rbuf variable is reused for this purpose > > > > Signed-off-by: Adam Miartus > > Reviewed-by: Timo Wischer > > > > diff --git a/src/pcm/pcm_file.c b/src/pcm/pcm_file.c index > 3a19cef..7998b64 100644 > > --- a/src/pcm/pcm_file.c > > +++ b/src/pcm/pcm_file.c > > @@ -77,6 +77,7 @@ typedef struct { > > snd_pcm_uframes_t appl_ptr; > > snd_pcm_uframes_t file_ptr_bytes; > > snd_pcm_uframes_t wbuf_size; > > + snd_pcm_uframes_t rbuf_size; > > size_t wbuf_size_bytes; > > size_t wbuf_used_bytes; > > char *wbuf; > > @@ -266,6 +267,37 @@ static int > snd_pcm_file_open_output_file(snd_pcm_file_t *file) > > return 0; > > } > > > > +/* fill areas with data from input file, return bytes red */ static int > > +snd_pcm_file_areas_read_infile(snd_pcm_t *pcm, const > snd_pcm_channel_area_t *areas, > > + snd_pcm_uframes_t offset, snd_pcm_uframes_t frames) { > > Please follow the standard coding style. > > > + snd_pcm_file_t *file = pcm->private_data; > > + snd_pcm_channel_area_t areas_if[pcm->channels]; > > + ssize_t bytes; > > + > > + if (file->ifd < 0) > > + return -EBADF; > > + > > + if (file->rbuf == NULL) > > + return -ENOMEM; > > + > > + if (file->rbuf_size < frames) { > > + SYSERR("requested more frames than pcm buffer"); > > + return -ENOMEM; > > + } > > + > > + bytes = read(file->ifd, file->rbuf, snd_pcm_frames_to_bytes(pcm, > frames)); > > + if (bytes < 0) { > > + SYSERR("read from file failed, error: %d", bytes); > > + return bytes; > > + } > > + > > + snd_pcm_areas_from_buf(pcm, areas_if, file->rbuf); > > + snd_pcm_areas_copy(areas, offset, areas_if, 0, pcm->channels, > > +snd_pcm_bytes_to_frames(pcm, bytes), pcm->format); > > Wrong indentation. > > > thanks, > > Takashi Sorry, my email client messed up the whitespace. I re-sent the patch using git send-mail. Best Regards, Adam