summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlden DSouza <aldend@google.com>2020-05-01 10:38:12 -0700
committerAlden DSouza <aldend@google.com>2020-05-01 18:17:06 +0000
commit23b27dc57e9f87a593a0a9aa3b3214a880cbc926 (patch)
treeeb317c56efb57bfd92804bfbc18b5c39c0f2f9a2
parentb22e2fcc53268690d919466b8785f7194e74a77d (diff)
downloadyukawa-23b27dc57e9f87a593a0a9aa3b3214a880cbc926.tar.gz
yukawa: Add locking to audio HAL mic mute getter/setter
cherry-picked from AOSP SHA 710ffc5776f2be9b750395d8f0af18c751efbb23 Merged-In: Icd00bfd9ce46726f96284972d36bd5638c77be09 Bug: b/150299669 Test: Tested on AOSP, see above SHA for details. Change-Id: If47e0ae0841aef01c531a139cdd8ec2a4240b691
-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;
}