From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai 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 13:59:39 +0200 Message-ID: References: <1558370831-15960-1-git-send-email-adam.miartus@gmail.com> 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 mx1.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id E8B52F89633 for ; Tue, 21 May 2019 13:59:40 +0200 (CEST) In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" To: "Miartus, Adam (Arion Recruitment; ADITG/ESM)" Cc: "alsa-devel@alsa-project.org" List-Id: alsa-devel@alsa-project.org On Tue, 21 May 2019 13:48:46 +0200, Miartus, Adam (Arion Recruitment; ADITG/ESM) wrote: > > > 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. Could you resubmit the whole patch set, at best with a cover letter? thanks, Takashi