diff options
author | Chih-Wei Huang <cwhuang@linux.org.tw> | 2020-04-28 14:58:50 +0800 |
---|---|---|
committer | Chih-Wei Huang <cwhuang@linux.org.tw> | 2020-04-28 14:58:50 +0800 |
commit | 5e36c28f9f7dbf254160b34f43d4ee974a7c63e5 (patch) | |
tree | 907d51d7b233e9068641f8c4f6a7be425722af4a | |
parent | fc4aceec5137d1658bedc97e257896e81bad625f (diff) | |
parent | 6d1fe3709284532cb22c3f30cb32fd10b389d95b (diff) | |
download | platform_hardware_libaudio-pie-x86.tar.gz platform_hardware_libaudio-pie-x86.tar.bz2 platform_hardware_libaudio-pie-x86.zip |
Merge remote-tracking branch 'x86/oreo-x86' into pie-x86pie-x86
-rw-r--r-- | audio_hw.c | 53 |
1 files changed, 9 insertions, 44 deletions
@@ -107,7 +107,6 @@ struct audio_device { bool standby; bool mic_mute; struct audio_route *ar; - int orientation; bool screen_off; struct stream_out *active_out; @@ -159,13 +158,6 @@ struct stream_in { size_t proc_frames_in; }; -enum { - ORIENTATION_LANDSCAPE, - ORIENTATION_PORTRAIT, - ORIENTATION_SQUARE, - ORIENTATION_UNDEFINED, -}; - static uint32_t out_get_sample_rate(const struct audio_stream *stream); static size_t out_get_buffer_size(const struct audio_stream *stream); static audio_format_t out_get_format(const struct audio_stream *stream); @@ -273,12 +265,14 @@ static void select_devices(struct audio_device *adev) int speaker_on; int docked; int main_mic_on; + int headset_mic_on; headphone_on = adev->out_device & (AUDIO_DEVICE_OUT_WIRED_HEADSET | AUDIO_DEVICE_OUT_WIRED_HEADPHONE); speaker_on = adev->out_device & AUDIO_DEVICE_OUT_SPEAKER; docked = adev->out_device & AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET; main_mic_on = adev->in_device & AUDIO_DEVICE_IN_BUILTIN_MIC; + headset_mic_on = adev->in_device & AUDIO_DEVICE_IN_WIRED_HEADSET; reset_mixer_state(adev->ar); @@ -288,17 +282,15 @@ static void select_devices(struct audio_device *adev) audio_route_apply_path(adev->ar, "headphone"); if (docked) audio_route_apply_path(adev->ar, "dock"); - if (main_mic_on) { - if (adev->orientation == ORIENTATION_LANDSCAPE) - audio_route_apply_path(adev->ar, "main-mic-left"); - else - audio_route_apply_path(adev->ar, "main-mic-top"); - } + if (main_mic_on) + audio_route_apply_path(adev->ar, "main-mic"); + if (headset_mic_on) + audio_route_apply_path(adev->ar, "headset-mic"); update_mixer_state(adev->ar); - ALOGV("hp=%c speaker=%c dock=%c main-mic=%c", headphone_on ? 'y' : 'n', - speaker_on ? 'y' : 'n', docked ? 'y' : 'n', main_mic_on ? 'y' : 'n'); + ALOGV("hp=%c speaker=%c dock=%c main-mic=%c headset-mic=%c", headphone_on ? 'y' : 'n', + speaker_on ? 'y' : 'n', docked ? 'y' : 'n', main_mic_on ? 'y' : 'n', headset_mic_on ? 'y' : 'n'); } /* must be called with hw device and output stream mutexes locked */ @@ -1254,33 +1246,6 @@ static int adev_set_parameters(struct audio_hw_device *dev, const char *kvpairs) int ret; parms = str_parms_create_str(kvpairs); - ret = str_parms_get_str(parms, "orientation", value, sizeof(value)); - if (ret >= 0) { - int orientation; - - if (strcmp(value, "landscape") == 0) - orientation = ORIENTATION_LANDSCAPE; - else if (strcmp(value, "portrait") == 0) - orientation = ORIENTATION_PORTRAIT; - else if (strcmp(value, "square") == 0) - orientation = ORIENTATION_SQUARE; - else - orientation = ORIENTATION_UNDEFINED; - - pthread_mutex_lock(&adev->lock); - if (orientation != adev->orientation) { - adev->orientation = orientation; - /* - * Orientation changes can occur with the input device - * closed so we must call select_devices() here to set - * up the mixer. This is because select_devices() will - * not be called when the input device is opened if no - * other input parameter is changed. - */ - select_devices(adev); - } - pthread_mutex_unlock(&adev->lock); - } ret = str_parms_get_str(parms, "screen_state", value, sizeof(value)); if (ret >= 0) { @@ -1464,7 +1429,7 @@ static int adev_open(const hw_module_t* module, const char* name, adev->hw_device.dump = adev_dump; adev->ar = audio_route_init(); - adev->orientation = ORIENTATION_UNDEFINED; + adev->out_device = AUDIO_DEVICE_OUT_SPEAKER; adev->in_device = AUDIO_DEVICE_IN_BUILTIN_MIC & ~AUDIO_DEVICE_BIT_IN; |