Skip to content
Snippets Groups Projects
Commit 9ca42c45 authored by Mike Lockwood's avatar Mike Lockwood Committed by Vineeta Srivastava
Browse files

usb: gadget: audio: Fix problem resuming playback on alt interface change

If the alternate interface is set back to 1, we now resume playback
if still triggered.

Bug: 12549807
(cherry picked from commit 898bafb4)

Change-Id: I6c3eb43ebafbc8a101ae83e7864097be5b07a0f9
parent 485db764
No related branches found
No related tags found
No related merge requests found
...@@ -260,6 +260,7 @@ struct audio_dev { ...@@ -260,6 +260,7 @@ struct audio_dev {
s64 frames_sent; s64 frames_sent;
bool audio_ep_enabled; bool audio_ep_enabled;
bool triggered;
}; };
static inline struct audio_dev *func_to_audio_source(struct usb_function *f) static inline struct audio_dev *func_to_audio_source(struct usb_function *f)
...@@ -267,6 +268,8 @@ static inline struct audio_dev *func_to_audio_source(struct usb_function *f) ...@@ -267,6 +268,8 @@ static inline struct audio_dev *func_to_audio_source(struct usb_function *f)
return container_of(f, struct audio_dev, func); return container_of(f, struct audio_dev, func);
} }
static void audio_pcm_playback_start(struct audio_dev *audio);
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
static struct usb_request *audio_request_new(struct usb_ep *ep, int buffer_size) static struct usb_request *audio_request_new(struct usb_ep *ep, int buffer_size)
...@@ -545,6 +548,10 @@ static int audio_set_alt(struct usb_function *f, unsigned intf, unsigned alt) ...@@ -545,6 +548,10 @@ static int audio_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
return ret; return ret;
} }
audio->audio_ep_enabled = true; audio->audio_ep_enabled = true;
if (audio->triggered) {
// resume playing if we are still triggered
audio_pcm_playback_start(audio);
}
} else if (!alt && audio->audio_ep_enabled) { } else if (!alt && audio->audio_ep_enabled) {
usb_ep_disable(audio->in_ep); usb_ep_disable(audio->in_ep);
audio->audio_ep_enabled = false; audio->audio_ep_enabled = false;
...@@ -767,11 +774,13 @@ static int audio_pcm_playback_trigger(struct snd_pcm_substream *substream, ...@@ -767,11 +774,13 @@ static int audio_pcm_playback_trigger(struct snd_pcm_substream *substream,
switch (cmd) { switch (cmd) {
case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_START:
case SNDRV_PCM_TRIGGER_RESUME: case SNDRV_PCM_TRIGGER_RESUME:
audio->triggered = 1;
audio_pcm_playback_start(audio); audio_pcm_playback_start(audio);
break; break;
case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_STOP:
case SNDRV_PCM_TRIGGER_SUSPEND: case SNDRV_PCM_TRIGGER_SUSPEND:
audio->triggered = 0;
audio_pcm_playback_stop(audio); audio_pcm_playback_stop(audio);
break; break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment