[alsa-devel] [PATCH - JACK plugin 4/4] jack: Support snd_pcm_drain()

Jaroslav Kysela perex at perex.cz
Fri Mar 16 16:11:15 CET 2018


Dne 16.3.2018 v 15:44 Wischer, Timo (ADITG/ESB) napsal(a):
> Hello Jaroslav
> 
>> Do you handle the non-blocking mode correctly here? It seems that this
>> mode is completely ignored.
> 
> You are right. The non-blocking mode flag will be ignored here.
> But this case is also not covered by the IO plug API.
> snd_pcm_drop() is called immediately after the IO plugin drain callback returns [1].
> The return value of the drain callback will be ignored.

Yes, it seems like a flaw in the ioplug core code.

> Therefore the IO plug API has to be changed to support this.
> But I do not really see a use case for it.

But it changes the PCM API behaviour, so some apps might have trouble
with it, because it might cause the unexpected task blocking. The
correct behaviour is return with -EAGAIN and let application wait for
the end-of-data using the file descriptor event (or build-in
snd_pcm_wait() fcn which implements the poll() loop - see
snd_pcm_wait_nocheck()).

> If you want to drain you also want to wait/block your application until all frames were played.

But it does not imply that the drain should block. The app just notify
the device that the rest of the data should be played.

> If you think it is required to change anything in this patch
> we have to clarify when drop should be called and when not.
> What is the sequence which the user would expect?
> Does the user need to call drop after drain is done or would it be called by snd_pcm_wait/snd_pcm_drain when it is not returning -EAGAIN?
> 
> [1] http://git.alsa-project.org/?p=alsa-lib.git;a=blob;f=src/pcm/pcm_ioplug.c;h=8c0ed4836365afb53c0cbce796a5d39c2d05a3d7;hb=07a17bd5a50289e2fdb2714a4e39f38f41811558#l504
> 
> Best regards
> 
> Timo Wischer
> 
> Advanced Driver Information Technology GmbH
> Engineering Software Base (ADITG/ESB)
> Robert-Bosch-Str. 200
> 31139 Hildesheim
> Germany
> 
> Tel. +49 5121 49 6938
> Fax +49 5121 49 6999
> twischer at de.adit-jv.com
> 
> ADIT is a joint venture company of Robert Bosch GmbH/Robert Bosch Car Multimedia GmbH and DENSO Corporation
> Sitz: Hildesheim, Registergericht: Amtsgericht Hildesheim HRB 3438
> Geschäftsführung: Wilhelm Grabow, Ken Yaguchi
> 
> ________________________________________
> From: Jaroslav Kysela [perex at perex.cz]
> Sent: Thursday, March 01, 2018 2:42 PM
> To: Wischer, Timo (ADITG/ESB)
> Cc: ALSA development; Takashi Iwai
> Subject: Re: [alsa-devel] [PATCH - JACK plugin 4/4] jack: Support snd_pcm_drain()
> 
> Dne 1.3.2018 v 14:14 twischer at de.adit-jv.com napsal(a):
>> From: Timo Wischer <twischer at de.adit-jv.com>
>>
>> Block on drain till available samples played
> 
> Do you handle the non-blocking mode correctly here? It seems that this
> mode is completely ignored.
> 
>                                         Jaroslav
> 
> --
> Jaroslav Kysela <perex at perex.cz>
> Linux Sound Maintainer; ALSA Project; Red Hat, Inc.
> 


-- 
Jaroslav Kysela <perex at perex.cz>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.


More information about the Alsa-devel mailing list