All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] aplay: Fix error message when writing captured data
@ 2017-04-07 12:14 Daniel Baluta
  2017-04-07 12:56 ` Takashi Sakamoto
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Baluta @ 2017-04-07 12:14 UTC (permalink / raw)
  To: tiwai; +Cc: mihai.serban, alsa-devel, broonie, shengjiu.wang, viorel.suman

Write can return less then requested bytes, but we treat
this as an error.

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@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..9547d1b 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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] aplay: Fix error message when writing captured data
  2017-04-07 12:14 [PATCH] aplay: Fix error message when writing captured data Daniel Baluta
@ 2017-04-07 12:56 ` Takashi Sakamoto
  2017-04-07 13:13   ` Daniel Baluta
  0 siblings, 1 reply; 3+ messages in thread
From: Takashi Sakamoto @ 2017-04-07 12:56 UTC (permalink / raw)
  To: Daniel Baluta, tiwai
  Cc: mihai.serban, alsa-devel, broonie, shengjiu.wang, viorel.suman

Hi,

On Apr 7 2017 21:14, Daniel Baluta wrote:
> Write can return less then requested bytes, but we treat
> this as an error.
>
> 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@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..9547d1b 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;
>  			}

I agree with this change.

A small nitpicking. This utility supports i18n with gettext. Let us use 
gettext alias to the message?

$ cd alsa-utils/aplay
$ git grep fprintf\( | wc
      57     387    3939
$ git grep fprintf\( | grep _\( | wc
      37     260    2570


Regards

Takashi Sakamoto

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] aplay: Fix error message when writing captured data
  2017-04-07 12:56 ` Takashi Sakamoto
@ 2017-04-07 13:13   ` Daniel Baluta
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel Baluta @ 2017-04-07 13:13 UTC (permalink / raw)
  To: o-takashi, tiwai
  Cc: Mihai Serban, alsa-devel, broonie, S.J. Wang, Viorel Suman

On Vi, 2017-04-07 at 21:56 +0900, Takashi Sakamoto wrote:
> Hi,
> 
> On Apr 7 2017 21:14, Daniel Baluta wrote:
> > 
> > Write can return less then requested bytes, but we treat
> > this as an error.
> > 
> > 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@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..9547d1b 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;
> >  			}
> I agree with this change.
> 
> A small nitpicking. This utility supports i18n with gettext. Let us
> use 
> gettext alias to the message?
> 
> $ cd alsa-utils/aplay
> $ git grep fprintf\( | wc
>       57     387    3939
> $ git grep fprintf\( | grep _\( | wc
>       37     260    2570
> 
> 

Sure, will send v2. I didn't know about the gettext alias. :)

Daniel.
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-04-07 13:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-07 12:14 [PATCH] aplay: Fix error message when writing captured data Daniel Baluta
2017-04-07 12:56 ` Takashi Sakamoto
2017-04-07 13:13   ` Daniel Baluta

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.