usb: gadget: u_audio: improve uac compatibility

Some PC USB Hosts (e.g Dell laptop) fail to send
SetInterface(AltSet=0) to stop capture/playback
when PC enter suspend or play YouTube Video.

To be compatible with these PC, add this patch to
stop capture/playback prior to start again if the
stream_state is true.

Change-Id: Iced57de39b6b88a7c987897dcb123cf8d7cf6473
Signed-off-by: William Wu <william.wu@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
This commit is contained in:
William Wu
2021-12-02 18:09:39 +08:00
committed by Tao Huang
parent 1abe6982f8
commit 01ccdd1489

View File

@@ -601,6 +601,15 @@ int u_audio_start_capture(struct g_audio *audio_dev)
struct uac_params *params = &audio_dev->params;
int req_len, i;
/*
* For better compatibility on some PC Hosts which
* failed to send SetInterface(AltSet=0) to stop
* capture last time. It needs to stop capture
* prior to start capture next time.
*/
if (audio_dev->stream_state[STATE_OUT])
u_audio_stop_capture(audio_dev);
audio_dev->usb_state[SET_INTERFACE_OUT] = true;
audio_dev->stream_state[STATE_OUT] = true;
schedule_work(&audio_dev->work);
@@ -705,6 +714,15 @@ int u_audio_start_playback(struct g_audio *audio_dev)
int req_len, i;
unsigned int p_pktsize;
/*
* For better compatibility on some PC Hosts which
* failed to send SetInterface(AltSet=0) to stop
* playback last time. It needs to stop playback
* prior to start playback next time.
*/
if (audio_dev->stream_state[STATE_IN])
u_audio_stop_playback(audio_dev);
audio_dev->usb_state[SET_INTERFACE_IN] = true;
audio_dev->stream_state[STATE_IN] = true;
schedule_work(&audio_dev->work);