Takashi Iwai
5dabf3bcba
- Backport upstream fixes / enhancements about alsa modules: mainly for UCM support (boo#1160914): 0001-alsa-mixer-path-test-Hide-unused-functions-when-buil.patch 0002-alsa-mixer-recognize-the-Speaker-Jack-control.patch 0003-alsa-mixer-add-support-for-SteelSeries-Arctis-Pro-20.patch 0004-alsa-mixer-Add-support-for-SteelSeries-Arctis-5-2019.patch 0005-alsa-mixer-add-support-for-LucidSound-LS31-and-creat.patch 0006-alsa-ucm-use-ucm2-name-for-the-direct-card-index-ope.patch 0007-alsa-ucm-add-mixer-IDs-to-ucm_items.patch 0008-alsa-mixer-handle-the-index-for-ALSA-mixer-element-i.patch 0009-alsa-mixer-improve-alsa_id_decode-function.patch 0010-alsa-ucm-Support-Playback-CaptureVolume.patch 0011-alsa-ucm-Fix-volume-control-based-on-review.patch 0012-alsa-ucm-use-the-correct-mixer-identifiers-as-first.patch 0013-alsa-ucm-add-support-for-master-volume.patch 0014-alsa-ucm-split-correctly-JackHWMute-device-names.patch 0015-alsa-ucm-fix-parsing-for-JackControl.patch 0016-alsa-ucm-add-comments-to-ucm_get_mixer_id.patch 0017-alsa-ucm-validate-access-to-PA_DEVICE_PORT_DATA.patch 0018-alsa-Skip-resume-PCM-if-hardware-doesn-t-support-it.patch 0019-alsa-ucm-parse-correctly-the-device-values.patch 0020-alsa-ucm-do-not-try-to-use-UCM-device-name-as-jack-n.patch 0021-alsa-util-do-not-try-to-guess-the-mixer-name-from-th.patch 0022-alsa-ucm-add-control-and-mixer-device-items.patch 0023-alsa-ucm-get-the-mixer-names-from-ucm-don-t-guess.patch 0024-alsa-ucm-use-the-proper-mixer-name-for-ucm-pcm-sink-.patch 0025-alsa-mixer-handle-interface-type-CARD-PCM-for-mixer-.patch 0026-alsa-mixer-Add-the-ability-to-pass-the-intended-role.patch 0027-alsa-mixer-Set-the-intended-role-of-Steelseries-Arct.patch 0028-alsa-rewrite-mixer-open-close-cache-mixer-accesses-i.patch OBS-URL: https://build.opensuse.org/request/show/774841 OBS-URL: https://build.opensuse.org/package/show/multimedia:libs/pulseaudio?expand=0&rev=217
66 lines
2.5 KiB
Diff
66 lines
2.5 KiB
Diff
From 734a00c849815a45697970d593068c301a04ebbb Mon Sep 17 00:00:00 2001
|
|
From: Kai-Heng Feng <kai.heng.feng@canonical.com>
|
|
Date: Tue, 10 Dec 2019 16:16:18 +0800
|
|
Subject: [PATCH] alsa: Skip resume PCM if hardware doesn't support it
|
|
|
|
Hardwares without SNDRV_PCM_INFO_RESUME capability, like USB Audio,
|
|
don't support snd_pcm_resume() when it's in suspended state.
|
|
|
|
Let's use snd_pcm_hw_params_can_resume() to check hardware's capability
|
|
before snd_pcm_resume() attempt. If it doesn't support resume, just go
|
|
to snd_pcm_drop() to leave suspended state directly.
|
|
---
|
|
src/modules/alsa/alsa-util.c | 28 +++++++++++++++++++---------
|
|
1 file changed, 19 insertions(+), 9 deletions(-)
|
|
|
|
diff --git a/src/modules/alsa/alsa-util.c b/src/modules/alsa/alsa-util.c
|
|
index bd0a47e5072c..a14b061118e6 100644
|
|
--- a/src/modules/alsa/alsa-util.c
|
|
+++ b/src/modules/alsa/alsa-util.c
|
|
@@ -1066,6 +1066,7 @@ void pa_alsa_init_proplist_ctl(pa_proplist *p, const char *name) {
|
|
|
|
int pa_alsa_recover_from_poll(snd_pcm_t *pcm, int revents) {
|
|
snd_pcm_state_t state;
|
|
+ snd_pcm_hw_params_t *hwparams;
|
|
int err;
|
|
|
|
pa_assert(pcm);
|
|
@@ -1103,16 +1104,25 @@ int pa_alsa_recover_from_poll(snd_pcm_t *pcm, int revents) {
|
|
break;
|
|
|
|
case SND_PCM_STATE_SUSPENDED:
|
|
- /* Retry resume 3 times before giving up, then fallback to restarting the stream. */
|
|
- for (int i = 0; i < 3; i++) {
|
|
- if ((err = snd_pcm_resume(pcm)) == 0)
|
|
- return 0;
|
|
- if (err != -EAGAIN)
|
|
- break;
|
|
- pa_msleep(25);
|
|
+ snd_pcm_hw_params_alloca(&hwparams);
|
|
+
|
|
+ if ((err = snd_pcm_hw_params_any(pcm, hwparams)) < 0) {
|
|
+ pa_log_debug("snd_pcm_hw_params_any() failed: %s", pa_alsa_strerror(err));
|
|
+ return -1;
|
|
}
|
|
- pa_log_warn("Could not recover alsa device from SUSPENDED state, trying to restart PCM");
|
|
- /* Fall through */
|
|
+
|
|
+ if (snd_pcm_hw_params_can_resume(hwparams)) {
|
|
+ /* Retry resume 3 times before giving up, then fallback to restarting the stream. */
|
|
+ for (int i = 0; i < 3; i++) {
|
|
+ if ((err = snd_pcm_resume(pcm)) == 0)
|
|
+ return 0;
|
|
+ if (err != -EAGAIN)
|
|
+ break;
|
|
+ pa_msleep(25);
|
|
+ }
|
|
+ pa_log_warn("Could not recover alsa device from SUSPENDED state, trying to restart PCM");
|
|
+ }
|
|
+ /* Fall through */
|
|
|
|
default:
|
|
|
|
--
|
|
2.16.4
|
|
|