OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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::HasAudioOutputDevices() { | 12 bool AudioManagerMac::HasAudioOutputDevices() { |
13 AudioDeviceID output_device_id = kAudioObjectUnknown; | 13 AudioDeviceID output_device_id = kAudioObjectUnknown; |
14 AudioObjectPropertyAddress property_address = { | 14 AudioObjectPropertyAddress property_address = { |
15 kAudioHardwarePropertyDefaultOutputDevice, // mSelector | 15 kAudioHardwarePropertyDefaultOutputDevice, // mSelector |
16 kAudioObjectPropertyScopeGlobal, // mScope | 16 kAudioObjectPropertyScopeGlobal, // mScope |
17 kAudioObjectPropertyElementMaster // mElement | 17 kAudioObjectPropertyElementMaster // mElement |
18 }; | 18 }; |
19 size_t output_device_id_size = sizeof(output_device_id); | 19 size_t output_device_id_size = sizeof(output_device_id); |
20 OSStatus err = AudioObjectGetPropertyData(kAudioObjectSystemObject, | 20 OSStatus err = AudioObjectGetPropertyData(kAudioObjectSystemObject, |
21 &property_address, | 21 &property_address, |
22 0, // inQualifierDataSize | 22 0, // inQualifierDataSize |
23 NULL, // inQualifierData | 23 NULL, // inQualifierData |
24 &output_device_id_size, | 24 &output_device_id_size, |
25 &output_device_id); | 25 &output_device_id); |
26 return err == kAudioHardwareNoError && | 26 return err == kAudioHardwareNoError && |
27 output_device_id != kAudioObjectUnknown; | 27 output_device_id != kAudioObjectUnknown; |
28 } | 28 } |
29 | 29 |
| 30 bool AudioManagerMac::HasAudioInputDevices() { |
| 31 // TODO(satish): implement. |
| 32 return false; |
| 33 } |
| 34 |
| 35 AudioInputStream* AudioManagerMac::MakeAudioInputStream( |
| 36 Format format, |
| 37 int channels, |
| 38 int sample_rate, |
| 39 char bits_per_sample, |
| 40 uint32 samples_per_packet) { |
| 41 // TODO(satish): implement. |
| 42 return NULL; |
| 43 } |
| 44 |
30 AudioOutputStream* AudioManagerMac::MakeAudioOutputStream( | 45 AudioOutputStream* AudioManagerMac::MakeAudioOutputStream( |
31 Format format, | 46 Format format, |
32 int channels, | 47 int channels, |
33 int sample_rate, | 48 int sample_rate, |
34 char bits_per_sample) { | 49 char bits_per_sample) { |
35 if (format == AUDIO_MOCK) | 50 if (format == AUDIO_MOCK) |
36 return FakeAudioOutputStream::MakeFakeStream(); | 51 return FakeAudioOutputStream::MakeFakeStream(); |
37 else if (format != AUDIO_PCM_LINEAR) | 52 else if (format != AUDIO_PCM_LINEAR) |
38 return NULL; | 53 return NULL; |
39 return new PCMQueueOutAudioOutputStream(this, channels, sample_rate, | 54 return new PCMQueueOutAudioOutputStream(this, channels, sample_rate, |
(...skipping 26 matching lines...) Expand all Loading... |
66 } | 81 } |
67 | 82 |
68 // By convention, the AudioManager is not thread safe. | 83 // By convention, the AudioManager is not thread safe. |
69 AudioManager* AudioManager::GetAudioManager() { | 84 AudioManager* AudioManager::GetAudioManager() { |
70 if (!g_audio_manager) { | 85 if (!g_audio_manager) { |
71 g_audio_manager = new AudioManagerMac(); | 86 g_audio_manager = new AudioManagerMac(); |
72 base::AtExitManager::RegisterCallback(&DestroyAudioManagerMac, NULL); | 87 base::AtExitManager::RegisterCallback(&DestroyAudioManagerMac, NULL); |
73 } | 88 } |
74 return g_audio_manager; | 89 return g_audio_manager; |
75 } | 90 } |
OLD | NEW |