alsa-ucm: Disable UCM devices when suspending

This might save some power, according to the discussion here:
https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/294#note_522388
This commit is contained in:
Tanu Kaskinen 2020-06-10 11:15:21 +03:00
parent 738f64a133
commit 45cf9d61e7
4 changed files with 54 additions and 0 deletions

View file

@ -954,6 +954,12 @@ static void suspend(struct userdata *u) {
/* Close PCM device */
close_pcm(u);
/* Disabling the UCM devices may save some power. */
if (u->ucm_context) {
pa_alsa_ucm_port_data *data = PA_DEVICE_PORT_DATA(u->source->active_port);
pa_alsa_ucm_port_enable_devices(data, false);
}
pa_log_info("Device suspended...");
}
@ -1044,6 +1050,13 @@ static int unsuspend(struct userdata *u, bool recovering) {
pa_log_info("Trying resume...");
/* We disable all UCM devices when suspending, so let's enable them
* again. */
if (u->ucm_context) {
pa_alsa_ucm_port_data *data = PA_DEVICE_PORT_DATA(u->source->active_port);
pa_alsa_ucm_port_enable_devices(data, true);
}
if ((err = snd_pcm_open(&u->pcm_handle, u->device_name, SND_PCM_STREAM_CAPTURE,
SND_PCM_NONBLOCK|
SND_PCM_NO_AUTO_RESAMPLE|