[PATCH] ALSA: pcm: accept the OPEN state for snd_pcm_stop()

Pavel Hofman pavel.hofman at ivitera.com
Mon Feb 14 13:23:20 CET 2022


Dne 13. 01. 22 v 16:08 Jaroslav Kysela napsal(a):
> On 13. 01. 22 14:45, Takashi Iwai wrote:
> 
>>> Also ideally, there may be a check in hw_params, if parameters
>>> (buffers) are changed, but the implementation is not so easy. Maybe we
>>> can allow OPEN ->
>>> PREPARE transition for this case, so the applications may just restart
>>> the streaming in the most light way.
>>
>> Hmm.  Reading more about those restrictions and requirements, I feel
>> that this might be better implemented in the gadget driver side
>> locally at first.  Basically we can handle similarly: add a new local
>> flag, set it at the stream stop, and return an error at prepare until
>> hw_params gets reconfigured.  This might be even smaller changes?
> 
> Pavel reported that stop to SETUP is not enough for sox, but it's true 
> that the driver may fail in the prepare() callback until the standard 
> stream operation is not recovered. I think that sox is trying to recover 
> and it succeeds - then the I/O timeout occurs.
> 
> Ref: 
> https://lore.kernel.org/alsa-devel/9635d70f-dc12-f9ed-29f5-ce34a1d4b112@ivitera.com/ 
> 
> 
> The gadget driver (drivers/usb/gadget/function/u_audio.c) has empty 
> prepare callback at the moment.
> 
> Pavel, could you try to add the no-stream flag management to the gadget 
> driver and return an error in the prepare callback in this case?

My apology for the delay. I can make the changes to the gadget to be 
prepared for the alsa change. Let me recap to see if I understand your 
plan correctly:

* Currently the stopped stream is indicated by unsetting prm->active 
https://kernel.googlesource.com/pub/scm/linux/kernel/git/gregkh/usb/+/554237f2bb62c4fcf01372e4c63d3e0062f27bac/drivers/usb/gadget/function/u_audio.c#502 
.

* A hw_params_set flag indicating that hw params have been configured 
should be set at 
https://kernel.googlesource.com/pub/scm/linux/kernel/git/gregkh/usb/+/554237f2bb62c4fcf01372e4c63d3e0062f27bac/drivers/usb/gadget/function/u_audio.c#423 
. Where should it be unset? At snd_pcm_ops.stop (currently empty), at 
https://kernel.googlesource.com/pub/scm/linux/kernel/git/gregkh/usb/+/554237f2bb62c4fcf01372e4c63d3e0062f27bac/drivers/usb/gadget/function/u_audio.c#494 
for active = false, or somewhere else?

* A check should be added to snd_pcm_ops.prepare which fails if the 
hw_params_set flag is unset. What error type should the fail return?

Thanks a lot for help.

Best regards,

Pavel.


More information about the Alsa-devel mailing list