summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--emulator/audio/driver/audio_hw.c33
-rw-r--r--emulator/audio/driver/audio_hw.h1
2 files changed, 26 insertions, 8 deletions
diff --git a/emulator/audio/driver/audio_hw.c b/emulator/audio/driver/audio_hw.c
index c2eff7e..807cc15 100644
--- a/emulator/audio/driver/audio_hw.c
+++ b/emulator/audio/driver/audio_hw.c
@@ -50,6 +50,8 @@
#define IN_PERIOD_MS 15
#define IN_PERIOD_COUNT 4
+#define _bool_str(x) ((x)?"true":"false")
+
static int adev_get_mic_mute(const struct audio_hw_device *dev, bool *state);
static struct pcm_config pcm_config_out = {
@@ -264,7 +266,7 @@ static void *out_write_worker(void *args) {
ALOGE("pcm_write failed %s address %s", ext_pcm_get_error(ext_pcm), out->bus_address);
restart = true;
} else {
- ALOGD("pcm_write succeed address %s", out->bus_address);
+ ALOGV("pcm_write succeed address %s", out->bus_address);
}
}
if (buffer) {
@@ -347,9 +349,14 @@ static ssize_t out_write(struct audio_stream_out *stream, const void *buffer, si
out->frames_total_buffered = 0;
}
- out_apply_gain(out, buffer, bytes);
- size_t frames_written = audio_vbuffer_write(&out->buffer, buffer, frames);
- pthread_cond_signal(&out->worker_wake);
+ size_t frames_written = frames;
+ if (out->dev->master_mute) {
+ ALOGV("%s: ignored due to master mute", __func__);
+ } else {
+ out_apply_gain(out, buffer, bytes);
+ frames_written = audio_vbuffer_write(&out->buffer, buffer, frames);
+ pthread_cond_signal(&out->worker_wake);
+ }
/* Implementation just consumes bytes if we start getting backed up */
out->frames_written += frames;
@@ -1049,11 +1056,21 @@ static int adev_get_master_volume(struct audio_hw_device *dev, float *volume) {
}
static int adev_set_master_mute(struct audio_hw_device *dev, bool muted) {
- return -ENOSYS;
+ ALOGD("%s: %s", __func__, _bool_str(muted));
+ struct generic_audio_device *adev = (struct generic_audio_device *)dev;
+ pthread_mutex_lock(&adev->lock);
+ adev->master_mute = muted;
+ pthread_mutex_unlock(&adev->lock);
+ return 0;
}
static int adev_get_master_mute(struct audio_hw_device *dev, bool *muted) {
- return -ENOSYS;
+ struct generic_audio_device *adev = (struct generic_audio_device *)dev;
+ pthread_mutex_lock(&adev->lock);
+ *muted = adev->master_mute;
+ pthread_mutex_unlock(&adev->lock);
+ ALOGD("%s: %s", __func__, _bool_str(*muted));
+ return 0;
}
static int adev_set_mode(struct audio_hw_device *dev, audio_mode_t mode) {
@@ -1326,8 +1343,8 @@ static int adev_open(const hw_module_t *module,
adev->device.set_voice_volume = adev_set_voice_volume; // no op
adev->device.set_master_volume = adev_set_master_volume; // no op
adev->device.get_master_volume = adev_get_master_volume; // no op
- adev->device.set_master_mute = adev_set_master_mute; // no op
- adev->device.get_master_mute = adev_get_master_mute; // no op
+ adev->device.set_master_mute = adev_set_master_mute;
+ adev->device.get_master_mute = adev_get_master_mute;
adev->device.set_mode = adev_set_mode; // no op
adev->device.set_mic_mute = adev_set_mic_mute;
adev->device.get_mic_mute = adev_get_mic_mute;
diff --git a/emulator/audio/driver/audio_hw.h b/emulator/audio/driver/audio_hw.h
index 9ad7990..41217ad 100644
--- a/emulator/audio/driver/audio_hw.h
+++ b/emulator/audio/driver/audio_hw.h
@@ -28,6 +28,7 @@
struct generic_audio_device {
struct audio_hw_device device; // Constant after init
pthread_mutex_t lock;
+ bool master_mute; // Proteced by this->lock
bool mic_mute; // Proteced by this->lock
struct mixer *mixer; // Proteced by this->lock
Hashmap *out_bus_stream_map; // Extended field. Constant after init