summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorSimon Wilson <simonwilson@google.com>2011-09-18 12:48:52 -0700
committerSimon Wilson <simonwilson@google.com>2011-09-20 13:40:33 -0700
commite8c16fe2c718c1e638ef52d7435957fc8ed0c0ae (patch)
treee564f3b722c0a93168e053bbbe8f8d3362369824 /audio
parentfc51006f02e808d4d032486584c5ef2ca45dad4e (diff)
downloaddevice_samsung_tuna-e8c16fe2c718c1e638ef52d7435957fc8ed0c0ae.zip
device_samsung_tuna-e8c16fe2c718c1e638ef52d7435957fc8ed0c0ae.tar.gz
device_samsung_tuna-e8c16fe2c718c1e638ef52d7435957fc8ed0c0ae.tar.bz2
audio: force initial non-speaker output for call
When the phone is ringing the active output device is always the speaker, perhaps with a secondary output device such as headset. When we answer the call the active output device is still speaker, and set_mode() causes the modem PCM to be opened for this route. However, we never use the speaker as our initial audio route for call audio. This change forces speaker off when we set up the initial in-call state so we don't have to change it immediately when out_set_parameters() is called with a different route. This works for earpiece, headset and headphones. It doesn't help bluetooth because the SCO connection is only begun after the call is started. Change-Id: Ie9f411c61570749fc26ab2ffa18cd1477e68a7e6
Diffstat (limited to 'audio')
-rw-r--r--audio/audio_hw.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/audio/audio_hw.c b/audio/audio_hw.c
index 7e8f3da..df4ce44 100644
--- a/audio/audio_hw.c
+++ b/audio/audio_hw.c
@@ -433,7 +433,6 @@ struct tuna_stream_out {
pthread_mutex_t lock; /* see note below on mutex acquisition order */
struct pcm_config config;
struct pcm *pcm;
- int device;
struct resampler_itfe *resampler;
char *buffer;
int standby;
@@ -670,6 +669,14 @@ static void set_input_volumes(struct tuna_audio_device *adev, int main_mic_on,
static void force_all_standby(struct tuna_audio_device *adev)
{
struct tuna_stream_in *in;
+ struct tuna_stream_out *out;
+
+ if (adev->active_output) {
+ out = adev->active_output;
+ pthread_mutex_lock(&out->lock);
+ do_output_standby(out);
+ pthread_mutex_unlock(&out->lock);
+ }
if (adev->active_input) {
in = adev->active_input;
@@ -685,6 +692,21 @@ static void select_mode(struct tuna_audio_device *adev)
LOGE("Entering IN_CALL state, in_call=%d", adev->in_call);
if (!adev->in_call) {
force_all_standby(adev);
+ /* force earpiece route for in call state if speaker is the
+ only currently selected route. This prevents having to tear
+ down the modem PCMs to change route from speaker to earpiece
+ after the ringtone is played, but doesn't cause a route
+ change if a headset or bt device is already connected. If
+ speaker is not the only thing active, just remove it from
+ the route. We'll assume it'll never be used initally during
+ a call. This works because we're sure that the audio policy
+ manager will update the output device after the audio mode
+ change, even if the device selection did not change. */
+ if ((adev->devices & AUDIO_DEVICE_OUT_ALL) == AUDIO_DEVICE_OUT_SPEAKER)
+ adev->devices = AUDIO_DEVICE_OUT_EARPIECE |
+ AUDIO_DEVICE_IN_BUILTIN_MIC;
+ else
+ adev->devices &= ~AUDIO_DEVICE_OUT_SPEAKER;
select_output_device(adev);
start_call(adev);
ril_set_call_clock_sync(&adev->ril, SOUND_CLOCK_START);
@@ -1141,8 +1163,7 @@ static int out_set_parameters(struct audio_stream *stream, const char *kvpairs)
val = atoi(value);
pthread_mutex_lock(&adev->lock);
pthread_mutex_lock(&out->lock);
- if ((out->device != val) && (val != 0)) {
- out->device = val;
+ if (((adev->devices & AUDIO_DEVICE_OUT_ALL) != val) && (val != 0)) {
if (out == adev->active_output) {
/* a change in output device may change the microphone selection */
if (adev->active_input &&
@@ -1150,12 +1171,12 @@ static int out_set_parameters(struct audio_stream *stream, const char *kvpairs)
force_input_standby = true;
}
/* force standby if moving to/from HDMI */
- if ((out->device & AUDIO_DEVICE_OUT_AUX_DIGITAL) ^
+ if ((val & AUDIO_DEVICE_OUT_AUX_DIGITAL) ^
(adev->devices & AUDIO_DEVICE_OUT_AUX_DIGITAL))
do_output_standby(out);
}
adev->devices &= ~AUDIO_DEVICE_OUT_ALL;
- adev->devices |= out->device;
+ adev->devices |= val;
select_output_device(adev);
}
pthread_mutex_unlock(&out->lock);
@@ -1951,7 +1972,6 @@ static int adev_open_output_stream(struct audio_hw_device *dev,
out->config = pcm_config_mm;
- out->device = devices;
out->dev = ladev;
out->standby = 1;