Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(779)

Unified Diff: media/audio/mac/audio_low_latency_input_mac.cc

Issue 645923002: Add support for audio input mute detection on all platforms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed audio_recorder_unittest Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/audio/mac/audio_low_latency_input_mac.cc
diff --git a/media/audio/mac/audio_low_latency_input_mac.cc b/media/audio/mac/audio_low_latency_input_mac.cc
index 1baa09f1fe07f0e2b4d5a89c017eaf53c8a23247..08d40b68f6c5162507d0ee6516f33a54c6d98832 100644
--- a/media/audio/mac/audio_low_latency_input_mac.cc
+++ b/media/audio/mac/audio_low_latency_input_mac.cc
@@ -451,6 +451,34 @@ double AUAudioInputStream::GetVolume() {
return 0.0;
}
+bool AUAudioInputStream::IsMuted() {
+ // Verify that we have a valid device.
+ if (input_device_id_ == kAudioObjectUnknown) {
+ NOTREACHED() << "Device ID is unknown";
tommi (sloooow) - chröme 2014/10/15 17:00:48 should this be a DCHECK then? DCHECK_NE(input_dev
+ return false;
+ }
+
+ AudioObjectPropertyAddress property_address = {
+ kAudioDevicePropertyMute,
tommi (sloooow) - chröme 2014/10/15 17:00:48 nit: indent by two spaces and put the closing brac
henrika (OOO until Aug 14) 2014/10/16 09:58:00 Done.
+ kAudioDevicePropertyScopeInput,
+ kAudioObjectPropertyElementMaster};
+
+ if (!AudioObjectHasProperty(input_device_id_, &property_address)) {
+ NOTREACHED() << "Device does not support checking master mute state";
tommi (sloooow) - chröme 2014/10/15 17:00:48 since NOTREACHED is essentially the same as DCHECK
henrika (OOO until Aug 14) 2014/10/16 09:58:00 Done.
+ return false;
+ }
+
+ UInt32 muted = 0;
+ UInt32 size = sizeof(muted);
+ OSStatus result = AudioObjectGetPropertyData(
+ input_device_id_, &property_address, 0, NULL, &size, &muted);
+ if (result == noErr)
+ return static_cast<bool>(muted);
tommi (sloooow) - chröme 2014/10/15 17:00:48 nit: return muted != 0u; actually, you could also
henrika (OOO until Aug 14) 2014/10/16 09:58:00 Done.
+
+ DLOG(WARNING) << "Failed to get mute state";
+ return false;
+}
+
// AUHAL AudioDeviceOutput unit callback
OSStatus AUAudioInputStream::InputProc(void* user_data,
AudioUnitRenderActionFlags* flags,

Powered by Google App Engine
This is Rietveld 408576698