diff options
author | henrika <henrika@chromium.org> | 2014-10-16 07:44:12 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-16 14:44:37 +0000 |
commit | c569d98674f56fccf39c53f7ec7a63127755390f (patch) | |
tree | 12bc496f1bf71c5c9421f492c63bd8f600682a88 /media/audio/mac | |
parent | 15a8709fe24ebb55e15ed88b306d76ad72412931 (diff) | |
download | chromium_src-c569d98674f56fccf39c53f7ec7a63127755390f.zip chromium_src-c569d98674f56fccf39c53f7ec7a63127755390f.tar.gz chromium_src-c569d98674f56fccf39c53f7ec7a63127755390f.tar.bz2 |
Add support for audio input mute detection on all platforms.
TBR=rkc@chromium.org
BUG=422275
TEST=Manual tests using DVLOGs to confirm valid microphone mute states.
Review URL: https://codereview.chromium.org/645923002
Cr-Commit-Position: refs/heads/master@{#299891}
Diffstat (limited to 'media/audio/mac')
-rw-r--r-- | media/audio/mac/audio_input_mac.cc | 5 | ||||
-rw-r--r-- | media/audio/mac/audio_input_mac.h | 1 | ||||
-rw-r--r-- | media/audio/mac/audio_low_latency_input_mac.cc | 23 | ||||
-rw-r--r-- | media/audio/mac/audio_low_latency_input_mac.h | 1 |
4 files changed, 30 insertions, 0 deletions
diff --git a/media/audio/mac/audio_input_mac.cc b/media/audio/mac/audio_input_mac.cc index b7f6e17..af5d9bc 100644 --- a/media/audio/mac/audio_input_mac.cc +++ b/media/audio/mac/audio_input_mac.cc @@ -136,6 +136,11 @@ double PCMQueueInAudioInputStream::GetVolume() { return 0.0; } +bool PCMQueueInAudioInputStream::IsMuted() { + NOTREACHED() << "Only supported for low-latency mode."; + return false; +} + void PCMQueueInAudioInputStream::SetAutomaticGainControl(bool enabled) { NOTREACHED() << "Only supported for low-latency mode."; } diff --git a/media/audio/mac/audio_input_mac.h b/media/audio/mac/audio_input_mac.h index 37afcee..6c1b4a14f 100644 --- a/media/audio/mac/audio_input_mac.h +++ b/media/audio/mac/audio_input_mac.h @@ -38,6 +38,7 @@ class PCMQueueInAudioInputStream : public AudioInputStream { virtual double GetVolume() override; virtual void SetAutomaticGainControl(bool enabled) override; virtual bool GetAutomaticGainControl() override; + virtual bool IsMuted() override; private: // Issue the OnError to |callback_|; diff --git a/media/audio/mac/audio_low_latency_input_mac.cc b/media/audio/mac/audio_low_latency_input_mac.cc index 1baa09f..2b2ce00 100644 --- a/media/audio/mac/audio_low_latency_input_mac.cc +++ b/media/audio/mac/audio_low_latency_input_mac.cc @@ -451,6 +451,29 @@ double AUAudioInputStream::GetVolume() { return 0.0; } +bool AUAudioInputStream::IsMuted() { + // Verify that we have a valid device. + DCHECK_NE(input_device_id_, kAudioObjectUnknown) << "Device ID is unknown"; + + AudioObjectPropertyAddress property_address = { + kAudioDevicePropertyMute, + kAudioDevicePropertyScopeInput, + kAudioObjectPropertyElementMaster + }; + + if (!AudioObjectHasProperty(input_device_id_, &property_address)) { + DLOG(ERROR) << "Device does not support checking master mute state"; + return false; + } + + UInt32 muted = 0; + UInt32 size = sizeof(muted); + OSStatus result = AudioObjectGetPropertyData( + input_device_id_, &property_address, 0, NULL, &size, &muted); + DLOG_IF(WARNING, result != noErr) << "Failed to get mute state"; + return result == noErr && muted != 0; +} + // AUHAL AudioDeviceOutput unit callback OSStatus AUAudioInputStream::InputProc(void* user_data, AudioUnitRenderActionFlags* flags, diff --git a/media/audio/mac/audio_low_latency_input_mac.h b/media/audio/mac/audio_low_latency_input_mac.h index 623cf1d..b3950ffd 100644 --- a/media/audio/mac/audio_low_latency_input_mac.h +++ b/media/audio/mac/audio_low_latency_input_mac.h @@ -72,6 +72,7 @@ class AUAudioInputStream : public AgcAudioStream<AudioInputStream> { virtual double GetMaxVolume() override; virtual void SetVolume(double volume) override; virtual double GetVolume() override; + virtual bool IsMuted() override; // Returns the current hardware sample rate for the default input device. MEDIA_EXPORT static int HardwareSampleRate(); |