[alsa-devel] [PATCH v2] aplay: Fix error message when writing captured data

Daniel Baluta daniel.baluta at gmail.com
Fri Apr 7 17:00:06 CEST 2017


On Fri, Apr 7, 2017 at 5:30 PM, Takashi Iwai <tiwai at suse.de> wrote:
> On Fri, 07 Apr 2017 15:45:42 +0200,
> Daniel Baluta wrote:
>>
>> On Fri, Apr 7, 2017 at 4:27 PM, Takashi Iwai <tiwai at suse.de> wrote:
>> > 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.
>> >
>> s/read/write here :)).
>>
>> > 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.
>>
>> Correct. But I think aplay decided to keep things simple and fail in case
>> couldn't write all requested bytes.
>
> And that's wrong.  We should loop instead.
>
>> This pattern can be noticed all over the places where write is used.
>
> All wrong :)
>
> We can implement a simple helper function and replace each write call
> with it.
>
>> Given the fact that write is blocking (meaning that it must write
>> at least one byte until return) this should work most of the time,
>> excepting corner cases like disk full, etc.
>
> Yes, and such corner cases must be handled properly, too -- in the
> end, it's what you wanted to achieve by your patch, but into a
> different direction.

:), all right. Will fix this the correct way and resend.

thanks,
Daniel.


More information about the Alsa-devel mailing list