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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/audio/mac/audio_low_latency_input_mac.h" 5 #include "media/audio/mac/audio_low_latency_input_mac.h"
6 6
7 #include <CoreServices/CoreServices.h> 7 #include <CoreServices/CoreServices.h>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 444
445 // Get the average volume of the channels. 445 // Get the average volume of the channels.
446 if (successful_channels != 0) 446 if (successful_channels != 0)
447 return static_cast<double>(volume_float32 / successful_channels); 447 return static_cast<double>(volume_float32 / successful_channels);
448 } 448 }
449 449
450 DLOG(WARNING) << "Failed to get volume"; 450 DLOG(WARNING) << "Failed to get volume";
451 return 0.0; 451 return 0.0;
452 } 452 }
453 453
454 bool AUAudioInputStream::IsMuted() {
455 // Verify that we have a valid device.
456 DCHECK_NE(input_device_id_, kAudioObjectUnknown) << "Device ID is unknown";
457
458 AudioObjectPropertyAddress property_address = {
459 kAudioDevicePropertyMute,
460 kAudioDevicePropertyScopeInput,
461 kAudioObjectPropertyElementMaster
462 };
463
464 if (!AudioObjectHasProperty(input_device_id_, &property_address)) {
465 DLOG(ERROR) << "Device does not support checking master mute state";
466 return false;
467 }
468
469 UInt32 muted = 0;
470 UInt32 size = sizeof(muted);
471 OSStatus result = AudioObjectGetPropertyData(
472 input_device_id_, &property_address, 0, NULL, &size, &muted);
473 DLOG_IF(WARNING, result != noErr) << "Failed to get mute state";
474 return result == noErr && muted != 0;
475 }
476
454 // AUHAL AudioDeviceOutput unit callback 477 // AUHAL AudioDeviceOutput unit callback
455 OSStatus AUAudioInputStream::InputProc(void* user_data, 478 OSStatus AUAudioInputStream::InputProc(void* user_data,
456 AudioUnitRenderActionFlags* flags, 479 AudioUnitRenderActionFlags* flags,
457 const AudioTimeStamp* time_stamp, 480 const AudioTimeStamp* time_stamp,
458 UInt32 bus_number, 481 UInt32 bus_number,
459 UInt32 number_of_frames, 482 UInt32 number_of_frames,
460 AudioBufferList* io_data) { 483 AudioBufferList* io_data) {
461 // Verify that the correct bus is used (Input bus/Element 1) 484 // Verify that the correct bus is used (Input bus/Element 1)
462 DCHECK_EQ(bus_number, static_cast<UInt32>(1)); 485 DCHECK_EQ(bus_number, static_cast<UInt32>(1));
463 AUAudioInputStream* audio_input = 486 AUAudioInputStream* audio_input =
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 kAudioDevicePropertyScopeInput, 670 kAudioDevicePropertyScopeInput,
648 static_cast<UInt32>(channel) 671 static_cast<UInt32>(channel)
649 }; 672 };
650 OSStatus result = AudioObjectIsPropertySettable(input_device_id_, 673 OSStatus result = AudioObjectIsPropertySettable(input_device_id_,
651 &property_address, 674 &property_address,
652 &is_settable); 675 &is_settable);
653 return (result == noErr) ? is_settable : false; 676 return (result == noErr) ? is_settable : false;
654 } 677 }
655 678
656 } // namespace media 679 } // namespace media
OLDNEW
« 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