summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlden DSouza <aldend@google.com>2020-05-01 22:17:48 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-05-01 22:17:48 +0000
commite0378f1c4b3c20f219aadc2e2b7e8be2a05bdb06 (patch)
treeeb317c56efb57bfd92804bfbc18b5c39c0f2f9a2
parentb22e2fcc53268690d919466b8785f7194e74a77d (diff)
parent23b27dc57e9f87a593a0a9aa3b3214a880cbc926 (diff)
downloadyukawa-e0378f1c4b3c20f219aadc2e2b7e8be2a05bdb06.tar.gz
yukawa: Add locking to audio HAL mic mute getter/setter am: 23b27dc57e
Change-Id: I2311a1267d3081b4d0bd331a5072ebb84cfb4d4c
-rw-r--r--audio/audio_hw.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/audio/audio_hw.c b/audio/audio_hw.c
index af9d7d6..d1c0e96 100644
--- a/audio/audio_hw.c
+++ b/audio/audio_hw.c
@@ -49,6 +49,8 @@
#include "audio_hw.h"
#include "audio_aec.h"
+static int adev_get_mic_mute(const struct audio_hw_device* dev, bool* state);
+
static int get_audio_output_port(audio_devices_t devices) {
/* Prefer HDMI, default to internal speaker */
int port = PORT_INTERNAL_SPEAKER;
@@ -621,7 +623,9 @@ static ssize_t in_read(struct audio_stream_in *stream, void* buffer,
exit:
pthread_mutex_unlock(&in->lock);
- if (adev->mic_mute) {
+ bool mic_muted = false;
+ adev_get_mic_mute((struct audio_hw_device*)adev, &mic_muted);
+ if (mic_muted) {
memset(buffer, 0, bytes);
}
@@ -631,7 +635,7 @@ exit:
} else {
/* Process AEC if available */
/* TODO move to a separate thread */
- if (!adev->mic_mute) {
+ if (!mic_muted) {
info.bytes = bytes;
int aec_ret = process_aec(adev->aec, buffer, &info);
if (aec_ret) {
@@ -852,7 +856,9 @@ static int adev_set_mic_mute(struct audio_hw_device *dev, bool state)
{
ALOGV("adev_set_mic_mute: %d",state);
struct alsa_audio_device *adev = (struct alsa_audio_device *)dev;
+ pthread_mutex_lock(&adev->lock);
adev->mic_mute = state;
+ pthread_mutex_unlock(&adev->lock);
return 0;
}
@@ -860,7 +866,9 @@ static int adev_get_mic_mute(const struct audio_hw_device *dev, bool *state)
{
ALOGV("adev_get_mic_mute");
struct alsa_audio_device *adev = (struct alsa_audio_device *)dev;
+ pthread_mutex_lock(&adev->lock);
*state = adev->mic_mute;
+ pthread_mutex_unlock(&adev->lock);
return 0;
}