summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2014-09-14 12:18:18 -0700
committerEric Laurent <elaurent@google.com>2014-09-14 12:32:28 -0700
commit253def9fa0b5d597125ce0af883d9c1deddd7ef9 (patch)
treedfb72e5a730a0b6e53268cb4da4d351410960aca
parentb5459839759300ce7b6fca3313ac130e1ed9c309 (diff)
downloadlibhardware-253def9fa0b5d597125ce0af883d9c1deddd7ef9.tar.gz
usb audio: implement microphone mute.
Bug: 17321604. Change-Id: I8e3daf2636dfd5f85d990c0093c52c908064afac
-rw-r--r--modules/usbaudio/audio_hw.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/modules/usbaudio/audio_hw.c b/modules/usbaudio/audio_hw.c
index caddf97d..664a753a 100644
--- a/modules/usbaudio/audio_hw.c
+++ b/modules/usbaudio/audio_hw.c
@@ -66,6 +66,8 @@ struct audio_device {
/* input */
alsa_device_profile in_profile;
+ bool mic_muted;
+
bool standby;
};
@@ -869,6 +871,10 @@ static ssize_t in_read(struct audio_stream_in *stream, void* buffer, size_t byte
sample_size_in_bytes, num_read_buff_bytes);
}
}
+
+ /* no need to acquire in->dev->lock to read mic_muted here as we don't change its state */
+ if (num_read_buff_bytes > 0 && in->dev->mic_muted)
+ memset(buffer, 0, num_read_buff_bytes);
}
err:
@@ -1061,6 +1067,10 @@ static int adev_set_mode(struct audio_hw_device *dev, audio_mode_t mode)
static int adev_set_mic_mute(struct audio_hw_device *dev, bool state)
{
+ struct audio_device * adev = (struct audio_device *)dev;
+ pthread_mutex_lock(&adev->lock);
+ adev->mic_muted = state;
+ pthread_mutex_unlock(&adev->lock);
return -ENOSYS;
}