From bcc4da353afc37a6b9b4d65e43ff1876fd10bb3e Mon Sep 17 00:00:00 2001 From: Paul Kocialkowski Date: Sat, 20 Oct 2012 19:05:57 +0200 Subject: Mixer: Add a way to only disable the current device Signed-off-by: Paul Kocialkowski --- mixer.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'mixer.c') diff --git a/mixer.c b/mixer.c index 35c289d..6848dc8 100644 --- a/mixer.c +++ b/mixer.c @@ -882,6 +882,7 @@ int tinyalsa_mixer_set_route(struct tinyalsa_mixer *mixer, audio_devices_t devic struct tinyalsa_mixer_io *mixer_io = NULL; struct tinyalsa_mixer_device *mixer_device = NULL; struct list_head *list = NULL; + int device_default = 0; int rc; LOGD("%s(%x, %x)", __func__, device, mode); @@ -891,8 +892,12 @@ int tinyalsa_mixer_set_route(struct tinyalsa_mixer *mixer, audio_devices_t devic if(audio_is_output_device(device)) { mixer_io = &mixer->output; + if(device == AUDIO_DEVICE_OUT_DEFAULT) + device_default = 1; } else if(audio_is_input_device(device)) { mixer_io = &mixer->input; + if(device == AUDIO_DEVICE_IN_DEFAULT) + device_default = 1; } else { LOGE("Invalid device: 0x%x", device); return -1; @@ -904,13 +909,19 @@ int tinyalsa_mixer_set_route(struct tinyalsa_mixer *mixer, audio_devices_t devic return -1; } - mixer_device = tinyalsa_mixer_get_device(mixer_io, device, mode); - if(mixer_device == NULL) { - LOGE("Unable to find a matching device: 0x%x with mode: 0x%x", - device, mode); - goto error_mixer; + if(device_default && mixer_io->device_current != NULL) { + rc = tinyalsa_mixer_set_route_list(mixer, mixer_io->device_current->disable); + if(rc < 0) { + LOGE("Unable to disable current device controls"); + goto error_mixer; + } + + mixer_io->device_current = NULL; + + goto exit_mixer; } + mixer_device = tinyalsa_mixer_get_device(mixer_io, device, mode); if(mixer_device == NULL) { LOGE("Unable to find a matching device: 0x%x with mode: 0x%x", device, mode); @@ -932,6 +943,8 @@ int tinyalsa_mixer_set_route(struct tinyalsa_mixer *mixer, audio_devices_t devic } mixer_io->device_current = mixer_device; + +exit_mixer: mixer_close(mixer->mixer); mixer->mixer = NULL; -- cgit v1.1