From 39023ada602b2bf8bf6bdab72d9a58bdbdc3ae05 Mon Sep 17 00:00:00 2001 From: Ziyan Date: Thu, 20 Aug 2015 16:45:24 +0200 Subject: espresso-common: audio: dynamically choose default incall device If the device doesn't have an earpiece (P5100), let's use the speaker as the default incall device. This commit makes it possible to use a common audio HAL for all variants. Change-Id: I2acb0ad03025688602f973734bcbabd3a4ba7820 --- audio/audio_hw.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'audio') diff --git a/audio/audio_hw.c b/audio/audio_hw.c index 1a6e4bd..377c5fb 100644 --- a/audio/audio_hw.c +++ b/audio/audio_hw.c @@ -194,6 +194,8 @@ struct espresso_dev_cfg { unsigned int off_len; }; +static bool device_has_earpiece = false; + /** * NOTE: when multiple mutexes have to be acquired, always respect the following order: * hw device > in stream > out stream @@ -513,7 +515,11 @@ static void set_incall_device(struct espresso_audio_device *adev) } break; default: - device_type = SOUND_AUDIO_PATH_HANDSET; + if (device_has_earpiece) { + device_type = SOUND_AUDIO_PATH_HANDSET; + } else { + device_type = SOUND_AUDIO_PATH_SPEAKER; + } break; } @@ -2867,6 +2873,10 @@ static void adev_config_start(void *data, const XML_Char *elem, return; } + if (strcmp(name, "earpiece") == 0) { + device_has_earpiece = true; + } + s->dev = &dev_cfg[s->adev->num_dev_cfgs]; memset(s->dev, 0, sizeof(*s->dev)); s->dev->mask = dev_names[i].mask; -- cgit v1.1