[alsa-devel] [PATCH v2] aplay: Fix error message when writing captured data
Takashi Iwai
tiwai at suse.de
Fri Apr 7 15:27:51 CEST 2017
On Fri, 07 Apr 2017 15:20:36 +0200,
Daniel Baluta wrote:
>
> Read can return less then requested bytes, but we treat
> this as an error.
Actually that's the bug -- we should loop the write until it reaches
to the real error. Once when we get the proper errno, the error
message via perror() itself will be enough.
thanks,
Takashi
> Anyhow, errno is not updated in this case and we can end
> up with a confusing error message.
>
> For example, when there is no room to write data into the
> output file we receive:
>
> $ arecord -d 2000 -c 2 -r 192000 -f S16_LE -Dplughw:0,0 audio.wav
> Recording WAVE '/mnt/msc/audio.wav' : Signed 16 bit Little Endian, Rate
> 192000 Hz, Stereo
> audio.wav: No such file or directory
>
> Signed-off-by: Daniel Baluta <daniel.baluta at nxp.com>
> ---
> aplay/aplay.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/aplay/aplay.c b/aplay/aplay.c
> index ee480f2..96f5e1b 100644
> --- a/aplay/aplay.c
> +++ b/aplay/aplay.c
> @@ -3079,7 +3079,7 @@ static void capture(char *orig_name)
> break;
> }
> if (write(fd, audiobuf, c) != c) {
> - perror(name);
> + fprintf(stderr, _("Couldn't write all data to %s\n"), name);
> in_aborting = 1;
> break;
> }
> --
> 2.7.4
>
More information about the Alsa-devel
mailing list