| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <CoreAudio/AudioHardware.h> | 5 #include <CoreAudio/AudioHardware.h> |
| 6 | 6 |
| 7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
| 8 #include "media/audio/fake_audio_output_stream.h" | 8 #include "media/audio/fake_audio_output_stream.h" |
| 9 #include "media/audio/mac/audio_manager_mac.h" | 9 #include "media/audio/mac/audio_manager_mac.h" |
| 10 #include "media/audio/mac/audio_output_mac.h" | 10 #include "media/audio/mac/audio_output_mac.h" |
| 11 | 11 |
| 12 bool AudioManagerMac::HasAudioDevices() { | 12 bool AudioManagerMac::HasAudioDevices() { |
| 13 AudioDeviceID output_device_id = 0; | 13 AudioDeviceID output_device_id = kAudioObjectUnknown; |
| 14 size_t size = sizeof(output_device_id); | 14 AudioObjectPropertyAddress property_address = { |
| 15 OSStatus err = AudioHardwareGetProperty( | 15 kAudioHardwarePropertyDefaultOutputDevice, // mSelector |
| 16 kAudioHardwarePropertyDefaultOutputDevice, &size, &output_device_id); | 16 kAudioObjectPropertyScopeGlobal, // mScope |
| 17 return ((err == noErr) && (output_device_id > 0)); | 17 kAudioObjectPropertyElementMaster // mElement |
| 18 }; |
| 19 size_t output_device_id_size = sizeof(output_device_id); |
| 20 OSStatus err = AudioObjectGetPropertyData(kAudioObjectSystemObject, |
| 21 &property_address, |
| 22 0, // inQualifierDataSize |
| 23 NULL, // inQualifierData |
| 24 &output_device_id_size, |
| 25 &output_device_id); |
| 26 return err == kAudioHardwareNoError && |
| 27 output_device_id != kAudioObjectUnknown; |
| 18 } | 28 } |
| 19 | 29 |
| 20 AudioOutputStream* AudioManagerMac::MakeAudioStream(Format format, int channels, | 30 AudioOutputStream* AudioManagerMac::MakeAudioStream(Format format, int channels, |
| 21 int sample_rate, | 31 int sample_rate, |
| 22 char bits_per_sample) { | 32 char bits_per_sample) { |
| 23 if (format == AUDIO_MOCK) | 33 if (format == AUDIO_MOCK) |
| 24 return FakeAudioOutputStream::MakeFakeStream(); | 34 return FakeAudioOutputStream::MakeFakeStream(); |
| 25 else if (format != AUDIO_PCM_LINEAR) | 35 else if (format != AUDIO_PCM_LINEAR) |
| 26 return NULL; | 36 return NULL; |
| 27 return new PCMQueueOutAudioOutputStream(this, channels, sample_rate, | 37 return new PCMQueueOutAudioOutputStream(this, channels, sample_rate, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 53 } | 63 } |
| 54 | 64 |
| 55 // By convention, the AudioManager is not thread safe. | 65 // By convention, the AudioManager is not thread safe. |
| 56 AudioManager* AudioManager::GetAudioManager() { | 66 AudioManager* AudioManager::GetAudioManager() { |
| 57 if (!g_audio_manager) { | 67 if (!g_audio_manager) { |
| 58 g_audio_manager = new AudioManagerMac(); | 68 g_audio_manager = new AudioManagerMac(); |
| 59 base::AtExitManager::RegisterCallback(&DestroyAudioManagerMac, NULL); | 69 base::AtExitManager::RegisterCallback(&DestroyAudioManagerMac, NULL); |
| 60 } | 70 } |
| 61 return g_audio_manager; | 71 return g_audio_manager; |
| 62 } | 72 } |
| OLD | NEW |