diff options
Diffstat (limited to 'audio')
-rwxr-xr-x | audio/audio_hw.c | 67 |
1 files changed, 39 insertions, 28 deletions
diff --git a/audio/audio_hw.c b/audio/audio_hw.c index 3890f42..73ba949 100755 --- a/audio/audio_hw.c +++ b/audio/audio_hw.c @@ -321,30 +321,41 @@ void select_devices(struct espresso_audio_device *adev) ALOGV("Changing input device %x => %x\n", adev->active_in_device, adev->in_device); /* Turn on new devices first so we don't glitch due to powerdown... */ - for (i = 0; i < adev->num_dev_cfgs; i++) - if ((adev->out_device & adev->dev_cfgs[i].mask) && - !(adev->active_out_device & adev->dev_cfgs[i].mask)) - set_route_by_array(adev->mixer, adev->dev_cfgs[i].on, - adev->dev_cfgs[i].on_len); - - for (i = 0; i < adev->num_dev_cfgs; i++) - if ((adev->in_device & adev->dev_cfgs[i].mask) && - !(adev->active_in_device & adev->dev_cfgs[i].mask)) - set_route_by_array(adev->mixer, adev->dev_cfgs[i].on, - adev->dev_cfgs[i].on_len); - - /* ...then disable old ones. */ - for (i = 0; i < adev->num_dev_cfgs; i++) - if (!(adev->out_device & adev->dev_cfgs[i].mask) && - (adev->active_out_device & adev->dev_cfgs[i].mask)) - set_route_by_array(adev->mixer, adev->dev_cfgs[i].off, - adev->dev_cfgs[i].off_len); - - for (i = 0; i < adev->num_dev_cfgs; i++) - if (!(adev->in_device & adev->dev_cfgs[i].mask) && - (adev->active_in_device & adev->dev_cfgs[i].mask)) - set_route_by_array(adev->mixer, adev->dev_cfgs[i].off, - adev->dev_cfgs[i].off_len); + if (adev->out_device != adev->active_out_device && adev->out_device != 0) { + for (i = 0; i < adev->num_dev_cfgs; i++) + if (!(adev->dev_cfgs[i].mask & AUDIO_DEVICE_BIT_IN) && + (adev->dev_cfgs[i].mask & adev->out_device) == adev->out_device) { + ALOGD("Turning on out 0x%x", adev->dev_cfgs[i].mask); + set_route_by_array(adev->mixer, adev->dev_cfgs[i].on, adev->dev_cfgs[i].on_len); + } + } + + if (adev->in_device != adev->active_in_device && adev->in_device != 0) { + for (i = 0; i < adev->num_dev_cfgs; i++) + if ((adev->dev_cfgs[i].mask & AUDIO_DEVICE_BIT_IN) && + (adev->dev_cfgs[i].mask & adev->in_device) == adev->in_device) { + ALOGD("Turning on in 0x%x", adev->dev_cfgs[i].mask); + set_route_by_array(adev->mixer, adev->dev_cfgs[i].on, adev->dev_cfgs[i].on_len); + } + } + + if (adev->out_device != adev->active_out_device && adev->active_out_device != 0) { + for (i = 0; i < adev->num_dev_cfgs; i++) + if (!(adev->dev_cfgs[i].mask & AUDIO_DEVICE_BIT_IN) && + (adev->dev_cfgs[i].mask & adev->active_out_device) == adev->active_out_device) { + ALOGD("Turning off out 0x%x", adev->dev_cfgs[i].mask); + set_route_by_array(adev->mixer, adev->dev_cfgs[i].off, adev->dev_cfgs[i].off_len); + } + } + + if (adev->in_device != adev->active_in_device && adev->active_in_device != 0) { + for (i = 0; i < adev->num_dev_cfgs; i++) + if ((adev->dev_cfgs[i].mask & AUDIO_DEVICE_BIT_IN) && + (adev->dev_cfgs[i].mask & adev->active_in_device) == adev->active_in_device) { + ALOGD("Turning off in 0x%x", adev->dev_cfgs[i].mask); + set_route_by_array(adev->mixer, adev->dev_cfgs[i].off, adev->dev_cfgs[i].off_len); + } + } adev->active_out_device = adev->out_device; adev->active_in_device = adev->in_device; @@ -572,7 +583,7 @@ static void select_mode(struct espresso_audio_device *adev) change, even if the device selection did not change. */ if (adev->out_device == AUDIO_DEVICE_OUT_SPEAKER) { adev->out_device = AUDIO_DEVICE_OUT_EARPIECE; - adev->in_device = AUDIO_DEVICE_IN_BUILTIN_MIC & ~AUDIO_DEVICE_BIT_IN; + adev->in_device = AUDIO_DEVICE_IN_BUILTIN_MIC; } else adev->out_device &= ~AUDIO_DEVICE_OUT_SPEAKER; select_output_device(adev); @@ -1590,7 +1601,7 @@ static int in_set_parameters(struct audio_stream *stream, const char *kvpairs) ret = str_parms_get_str(parms, AUDIO_PARAMETER_STREAM_ROUTING, value, sizeof(value)); if (ret >= 0) { - val = atoi(value) & ~AUDIO_DEVICE_BIT_IN; + val = atoi(value); if ((in->device != val) && (val != 0)) { in->device = val; do_standby = true; @@ -2750,7 +2761,7 @@ static int adev_open_input_stream(struct audio_hw_device *dev, in->dev = ladev; in->standby = 1; - in->device = devices & ~AUDIO_DEVICE_BIT_IN; + in->device = devices; *stream_in = &in->stream; return 0; @@ -3079,7 +3090,7 @@ static int adev_open(const hw_module_t* module, const char* name, pthread_mutex_init(&adev->lock, NULL); adev->mode = AUDIO_MODE_NORMAL; adev->out_device = AUDIO_DEVICE_OUT_SPEAKER; - adev->in_device = AUDIO_DEVICE_IN_BUILTIN_MIC & ~AUDIO_DEVICE_BIT_IN; + adev->in_device = AUDIO_DEVICE_IN_BUILTIN_MIC; select_devices(adev); for (i = 0; i < OUTPUT_TOTAL; i++) { |