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.

Signed-off-by: William Wu <william.wu@rock-chips.com>
Change-Id: Iced57de39b6b88a7c987897dcb123cf8d7cf6473
This commit is contained in:
William Wu
2021-12-02 18:09:39 +08:00
parent 49cb39f8c2
commit 35f020b0e8

View File

@@ -532,6 +532,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);
@@ -591,6 +600,15 @@ int u_audio_start_playback(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
* 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);