summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Kocialkowski <contact@paulk.fr>2012-10-20 19:05:57 +0200
committerPaul Kocialkowski <contact@paulk.fr>2012-10-20 19:05:57 +0200
commitbcc4da353afc37a6b9b4d65e43ff1876fd10bb3e (patch)
tree47a2e9fbc2009cfb7749b5efc9e33c653b9b8f23
parent4d1f4e9cad4800bac513c0c49f3ea4d0a72697e7 (diff)
downloadhardware_tinyalsa-audio-bcc4da353afc37a6b9b4d65e43ff1876fd10bb3e.zip
hardware_tinyalsa-audio-bcc4da353afc37a6b9b4d65e43ff1876fd10bb3e.tar.gz
hardware_tinyalsa-audio-bcc4da353afc37a6b9b4d65e43ff1876fd10bb3e.tar.bz2
Mixer: Add a way to only disable the current device
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
-rw-r--r--mixer.c23
1 files changed, 18 insertions, 5 deletions
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;