mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2026-02-11 04:27:48 -05:00
alsa-ucm: Disable UCM devices when suspending
Disabling UCM devices might save some power, according to an earlier discussion [1]. Disable them when suspending sinks/sources, and enable them when unsuspending. However, doing only that much introduces problems. The hardware controls we track for volume and mute state can change as part of disabling the UCM device. Enabling it back does not restore it to its pre-suspend state, so the UCM-triggered changes to disable the device will show up on user interfaces and cause confusion. The volume/mute should not be kept in sync with hardware for inactive UCM devices [2]. Skip the callbacks for reading/changing volume/mute state if the UCM device is disabled. This way, the volume/mute controls for sinks/sources are essentially detached from the hardware controls until the UCM device is re-enabled. Finally, sync volume and mute state for the sinks/sources just after we re-enable the UCM devices, to restore things to the pre-suspend state. Combined with the above, this means we can still change volume/mute state in user interfaces while the sink/source is suspended, and its updated value will be applied to the UCM device when it's actually going to be used. [1] https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/294#note_522388 [2] https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/772#note_1872757 Co-developed-by: Tanu Kaskinen <tanuk@iki.fi> [Alper: Rebase, split enable/disable functions, skip volume/mute callbacks if disabled, sync mixer at unsuspend, edit message] Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
This commit is contained in:
parent
3e2bb8a1ec
commit
bafe545da7
4 changed files with 120 additions and 0 deletions
|
|
@ -2535,6 +2535,18 @@ static void ucm_port_data_free(pa_device_port *port) {
|
|||
pa_xfree(ucm_port->eld_mixer_device_name);
|
||||
}
|
||||
|
||||
int pa_alsa_ucm_port_device_enable(pa_alsa_ucm_port_data *data) {
|
||||
return ucm_device_enable(data->ucm, data->device);
|
||||
}
|
||||
|
||||
int pa_alsa_ucm_port_device_disable(pa_alsa_ucm_port_data *data) {
|
||||
return ucm_device_disable(data->ucm, data->device);
|
||||
}
|
||||
|
||||
long pa_alsa_ucm_port_device_status(pa_alsa_ucm_port_data *data) {
|
||||
return ucm_device_status(data->ucm, data->device);
|
||||
}
|
||||
|
||||
#else /* HAVE_ALSA_UCM */
|
||||
|
||||
/* Dummy functions for systems without UCM support */
|
||||
|
|
@ -2591,4 +2603,16 @@ void pa_alsa_ucm_roled_stream_begin(pa_alsa_ucm_config *ucm, const char *role, p
|
|||
void pa_alsa_ucm_roled_stream_end(pa_alsa_ucm_config *ucm, const char *role, pa_direction_t dir) {
|
||||
}
|
||||
|
||||
int pa_alsa_ucm_port_device_enable(pa_alsa_ucm_port_data *data) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int pa_alsa_ucm_port_device_disable(pa_alsa_ucm_port_data *data) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
long pa_alsa_ucm_port_device_status(pa_alsa_ucm_port_data *data) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue