2022-11-04 01:50:07

by Ai Chao

[permalink] [raw]
Subject: [PATCH] ALSA: usb-audio: fix usb camero disconnect issue

When current rate is different from the runtime rate,
snd_usb_endpoint stop and close endpoint to resetting rate.
if snd_usb_endpoint close the endpoint, sometimes usb will
disconnect the device.

Signed-off-by: aichao <[email protected]>
---
sound/usb/pcm.c | 5 -----
1 file changed, 5 deletions(-)

diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
index 5dc9266180e3..2ae4a55cbaa8 100644
--- a/sound/usb/pcm.c
+++ b/sound/usb/pcm.c
@@ -517,7 +517,6 @@ static int snd_usb_hw_params(struct snd_pcm_substream *substream,
if (snd_usb_endpoint_compatible(chip, subs->data_endpoint,
fmt, hw_params))
goto unlock;
- close_endpoints(chip, subs);
}

subs->data_endpoint = snd_usb_endpoint_open(chip, fmt, hw_params, false);
@@ -546,9 +545,6 @@ static int snd_usb_hw_params(struct snd_pcm_substream *substream,
ret = configure_endpoints(chip, subs);

unlock:
- if (ret < 0)
- close_endpoints(chip, subs);
-
snd_usb_unlock_shutdown(chip);
stop_pipeline:
if (ret < 0)
@@ -574,7 +570,6 @@ static int snd_usb_hw_free(struct snd_pcm_substream *substream)
if (!snd_usb_lock_shutdown(chip)) {
if (stop_endpoints(subs))
sync_pending_stops(subs);
- close_endpoints(chip, subs);
snd_usb_unlock_shutdown(chip);
}

--
2.25.1



2022-11-04 08:15:13

by Takashi Iwai

[permalink] [raw]
Subject: Re: [PATCH] ALSA: usb-audio: fix usb camero disconnect issue

On Fri, 04 Nov 2022 02:32:36 +0100,
aichao wrote:
>
> When current rate is different from the runtime rate,
> snd_usb_endpoint stop and close endpoint to resetting rate.
> if snd_usb_endpoint close the endpoint, sometimes usb will
> disconnect the device.

What do you mean...? snd_usb_endpoint_close() never disconnects the
device by itself.

Please elaborate the problem.


Takashi

>
> Signed-off-by: aichao <[email protected]>
> ---
> sound/usb/pcm.c | 5 -----
> 1 file changed, 5 deletions(-)
>
> diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c
> index 5dc9266180e3..2ae4a55cbaa8 100644
> --- a/sound/usb/pcm.c
> +++ b/sound/usb/pcm.c
> @@ -517,7 +517,6 @@ static int snd_usb_hw_params(struct snd_pcm_substream *substream,
> if (snd_usb_endpoint_compatible(chip, subs->data_endpoint,
> fmt, hw_params))
> goto unlock;
> - close_endpoints(chip, subs);
> }
>
> subs->data_endpoint = snd_usb_endpoint_open(chip, fmt, hw_params, false);
> @@ -546,9 +545,6 @@ static int snd_usb_hw_params(struct snd_pcm_substream *substream,
> ret = configure_endpoints(chip, subs);
>
> unlock:
> - if (ret < 0)
> - close_endpoints(chip, subs);
> -
> snd_usb_unlock_shutdown(chip);
> stop_pipeline:
> if (ret < 0)
> @@ -574,7 +570,6 @@ static int snd_usb_hw_free(struct snd_pcm_substream *substream)
> if (!snd_usb_lock_shutdown(chip)) {
> if (stop_endpoints(subs))
> sync_pending_stops(subs);
> - close_endpoints(chip, subs);
> snd_usb_unlock_shutdown(chip);
> }
>
> --
> 2.25.1
>