Commit 384dc085c32285e6548511bf80c5d5a5b246ed24
1 parent
61a709504b
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
ALSA: usb-audio: Avoid unnecessary EP setups in prepare
The recent fix for USB suspend breakage moved the code to set up EP from hw_params to prepare, but it means also the EP setup might be called multiple times unnecessarily because the prepare callback can be called multiple times without starting the stream (e.g. OSS emulation). This patch adds a new flag to struct snd_usb_substream indicating whether the setup of EP is required, and do it only when necessary, i.e. right after hw_params or suspend. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Showing 3 changed files with 10 additions and 3 deletions Side-by-side Diff
sound/usb/card.c
sound/usb/card.h
... | ... | @@ -125,6 +125,7 @@ |
125 | 125 | struct snd_usb_endpoint *data_endpoint; |
126 | 126 | struct snd_usb_endpoint *sync_endpoint; |
127 | 127 | unsigned long flags; |
128 | + bool need_setup_ep; /* (re)configure EP at prepare? */ | |
128 | 129 | |
129 | 130 | u64 formats; /* format bitmasks (all or'ed) */ |
130 | 131 | unsigned int num_formats; /* number of supported audio formats (list) */ |
sound/usb/pcm.c
... | ... | @@ -510,6 +510,7 @@ |
510 | 510 | |
511 | 511 | subs->interface = fmt->iface; |
512 | 512 | subs->altset_idx = fmt->altset_idx; |
513 | + subs->need_setup_ep = true; | |
513 | 514 | |
514 | 515 | return 0; |
515 | 516 | } |
... | ... | @@ -568,9 +569,12 @@ |
568 | 569 | if (ret < 0) |
569 | 570 | return ret; |
570 | 571 | |
571 | - ret = configure_endpoint(subs); | |
572 | - if (ret < 0) | |
573 | - return ret; | |
572 | + if (subs->need_setup_ep) { | |
573 | + ret = configure_endpoint(subs); | |
574 | + if (ret < 0) | |
575 | + return ret; | |
576 | + subs->need_setup_ep = false; | |
577 | + } | |
574 | 578 | |
575 | 579 | /* some unit conversions in runtime */ |
576 | 580 | subs->data_endpoint->maxframesize = |