summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2018-05-31 07:24:59 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2018-05-31 07:24:59 +0000
commit2ea88da2fdedc033640fee59d826b192c0429346 (patch)
tree6e0ad4a931c9d37f6fa2869ba028d51a877f48ea
parent908ac42cf83d75f98e010302ea656041fbc9b6eb (diff)
parent6f3ae29a9d8be05b812cbfde5b04c15d9356bf4d (diff)
downloaddevice_generic_car-pie-cts-release.tar.gz
device_generic_car-pie-cts-release.tar.bz2
device_generic_car-pie-cts-release.zip
Snap for 4813226 from 6f3ae29a9d8be05b812cbfde5b04c15d9356bf4d to pi-releaseandroid-wear-9.0.0_r9android-wear-9.0.0_r8android-wear-9.0.0_r7android-wear-9.0.0_r6android-wear-9.0.0_r5android-wear-9.0.0_r4android-wear-9.0.0_r3android-wear-9.0.0_r23android-wear-9.0.0_r22android-wear-9.0.0_r21android-wear-9.0.0_r20android-wear-9.0.0_r2android-wear-9.0.0_r19android-wear-9.0.0_r18android-wear-9.0.0_r17android-wear-9.0.0_r16android-wear-9.0.0_r15android-wear-9.0.0_r14android-wear-9.0.0_r13android-wear-9.0.0_r12android-wear-9.0.0_r11android-wear-9.0.0_r10android-wear-9.0.0_r1android-vts-9.0_r9android-vts-9.0_r8android-vts-9.0_r7android-vts-9.0_r6android-vts-9.0_r5android-vts-9.0_r4android-vts-9.0_r14android-vts-9.0_r13android-vts-9.0_r12android-vts-9.0_r11android-vts-9.0_r10android-cts-9.0_r9android-cts-9.0_r8android-cts-9.0_r7android-cts-9.0_r6android-cts-9.0_r5android-cts-9.0_r4android-cts-9.0_r3android-cts-9.0_r2android-cts-9.0_r13android-cts-9.0_r12android-cts-9.0_r11android-cts-9.0_r10android-cts-9.0_r1android-9.0.0_r9android-9.0.0_r8android-9.0.0_r7android-9.0.0_r60android-9.0.0_r6android-9.0.0_r59android-9.0.0_r58android-9.0.0_r57android-9.0.0_r56android-9.0.0_r55android-9.0.0_r54android-9.0.0_r53android-9.0.0_r52android-9.0.0_r51android-9.0.0_r50android-9.0.0_r5android-9.0.0_r49android-9.0.0_r48android-9.0.0_r3android-9.0.0_r2android-9.0.0_r18android-9.0.0_r17android-9.0.0_r10android-9.0.0_r1security-pi-releasepie-vts-releasepie-security-releasepie-s2-releasepie-release-2pie-releasepie-r2-s2-releasepie-r2-s1-releasepie-r2-releasepie-cts-release
Change-Id: I1d50b0f95b8a99b078d8156ac8b2c9fc26542804
-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