> On Mon, 20 May 2019 18:49:34 +0200, > Miartus, Adam (Arion Recruitment; ADITG/ESM) wrote: > > > > From: Adam Miartus <amiartus@xxxxxxxxxxxxxx> > > > > 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 <amiartus@xxxxxxxxxxxxxx> > > Reviewed-by: Timo Wischer <twischer@xxxxxxxxxxxxxx> > > > > 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 _______________________________________________ Alsa-devel mailing list Alsa-devel@xxxxxxxxxxxxxxxx https://mailman.alsa-project.org/mailman/listinfo/alsa-devel