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

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: nit 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
« no previous file with comments | « media/audio/mac/audio_low_latency_input_mac.h ('k') | media/audio/pulse/pulse_input.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..2b2ce0090da0f54d25fdb9a40f60eb5e7f417b14 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,
« no previous file with comments | « media/audio/mac/audio_low_latency_input_mac.h ('k') | media/audio/pulse/pulse_input.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698