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

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

Issue 10909185: Add Mac OS X synchronized audio I/O back-end (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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_manager_mac.cc
===================================================================
--- media/audio/mac/audio_manager_mac.cc (revision 157152)
+++ media/audio/mac/audio_manager_mac.cc (working copy)
@@ -6,6 +6,7 @@
#include <string>
+#include "base/command_line.h"
#include "base/mac/mac_logging.h"
#include "base/mac/scoped_cftyperef.h"
#include "base/sys_string_conversions.h"
@@ -14,7 +15,10 @@
#include "media/audio/mac/audio_low_latency_output_mac.h"
#include "media/audio/mac/audio_manager_mac.h"
#include "media/audio/mac/audio_output_mac.h"
+#include "media/audio/mac/audio_synchronized_mac.h"
+#include "media/audio/mac/audio_unified_mac.h"
#include "media/base/limits.h"
+#include "media/base/media_switches.h"
namespace media {
@@ -39,6 +43,44 @@
output_device_id != kAudioObjectUnknown;
}
+// Returns if the default input device is the same as the default output.
scherkus (not reviewing) 2012/09/17 23:07:17 Returns... true? :)
Chris Rogers 2012/09/18 00:22:36 Done.
+static bool HasUnifiedDefaultIO() {
+ AudioDeviceID input_id, output_id;
+
+ AudioObjectPropertyAddress pa;
+ pa.mSelector = kAudioHardwarePropertyDefaultInputDevice;
+ pa.mScope = kAudioObjectPropertyScopeGlobal;
+ pa.mElement = kAudioObjectPropertyElementMaster;
+ UInt32 size = sizeof(input_id);
+
+ // Get the default input.
+ OSStatus result = AudioObjectGetPropertyData(
+ kAudioObjectSystemObject,
+ &pa,
+ 0,
+ 0,
+ &size,
+ &input_id);
+
+ if (result != noErr)
+ return false;
+
+ // Get the default output.
+ pa.mSelector = kAudioHardwarePropertyDefaultOutputDevice;
+ result = AudioObjectGetPropertyData(
+ kAudioObjectSystemObject,
+ &pa,
+ 0,
+ 0,
+ &size,
+ &output_id);
+
+ if (result != noErr)
+ return false;
+
+ return input_id == output_id;
+}
+
static void GetAudioDeviceInfo(bool is_input,
media::AudioDeviceNames* device_names) {
DCHECK(device_names);
@@ -250,6 +292,21 @@
AudioOutputStream* AudioManagerMac::MakeLowLatencyOutputStream(
const AudioParameters& params) {
DCHECK_EQ(AudioParameters::AUDIO_PCM_LOW_LATENCY, params.format());
+
+ // TODO(crogers): remove once we properly handle input device selection.
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableWebAudioInput)) {
+ if (HasUnifiedDefaultIO()) {
+ return new AudioHardwareUnifiedStream(this, params);
+ } else {
scherkus (not reviewing) 2012/09/17 23:07:17 nit: no need for else due to early return
Chris Rogers 2012/09/18 00:22:36 Done.
+ // kAudioDeviceUnknown translates to "use default" here.
+ return new AudioSynchronizedStream(this,
+ params,
+ kAudioDeviceUnknown,
+ kAudioDeviceUnknown);
+ }
+ }
+
return new AUAudioOutputStream(this, params);
}

Powered by Google App Engine
This is Rietveld 408576698