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

Side by Side Diff: media/audio/mac/audio_manager_mac.cc

Issue 159167: Refactoring to share MockAudioOutputStream implementations across 3 platforms (Closed)
Patch Set: the same as before Created 11 years, 5 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_manager_mac.h ('k') | media/audio/mac/audio_output_mac.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) 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/mac/audio_manager_mac.h" 9 #include "media/audio/mac/audio_manager_mac.h"
9 #include "media/audio/mac/audio_output_mac.h" 10 #include "media/audio/mac/audio_output_mac.h"
10 11
11 bool AudioManagerMac::HasAudioDevices() { 12 bool AudioManagerMac::HasAudioDevices() {
12 AudioDeviceID output_device_id = 0; 13 AudioDeviceID output_device_id = 0;
13 size_t size = sizeof(output_device_id); 14 size_t size = sizeof(output_device_id);
14 OSStatus err = AudioHardwareGetProperty( 15 OSStatus err = AudioHardwareGetProperty(
15 kAudioHardwarePropertyDefaultOutputDevice, &size, &output_device_id); 16 kAudioHardwarePropertyDefaultOutputDevice, &size, &output_device_id);
16 return ((err == noErr) && (output_device_id > 0)); 17 return ((err == noErr) && (output_device_id > 0));
17 } 18 }
18 19
19 AudioOutputStream* AudioManagerMac::MakeAudioStream(Format format, int channels, 20 AudioOutputStream* AudioManagerMac::MakeAudioStream(Format format, int channels,
20 int sample_rate, 21 int sample_rate,
21 char bits_per_sample) { 22 char bits_per_sample) {
22 // TODO(cpu): add mock format. 23 if (format == AUDIO_MOCK)
23 if (format != AUDIO_PCM_LINEAR) 24 return FakeAudioOutputStream::MakeFakeStream();
25 else if (format != AUDIO_PCM_LINEAR)
24 return NULL; 26 return NULL;
25 return new PCMQueueOutAudioOutputStream(this, channels, sample_rate, 27 return new PCMQueueOutAudioOutputStream(this, channels, sample_rate,
26 bits_per_sample); 28 bits_per_sample);
27 } 29 }
28 30
29 void AudioManagerMac::MuteAll() { 31 void AudioManagerMac::MuteAll() {
30 // TODO(cpu): implement. 32 // TODO(cpu): implement.
31 } 33 }
32 34
33 void AudioManagerMac::UnMuteAll() { 35 void AudioManagerMac::UnMuteAll() {
34 // TODO(cpu): implement. 36 // TODO(cpu): implement.
35 } 37 }
36 38
37 const void* AudioManagerMac::GetLastMockBuffer() {
38 // TODO(cpu): implement.
39 return NULL;
40 }
41
42 // Called by the stream when it has been released by calling Close(). 39 // Called by the stream when it has been released by calling Close().
43 void AudioManagerMac::ReleaseStream(PCMQueueOutAudioOutputStream* stream) { 40 void AudioManagerMac::ReleaseStream(PCMQueueOutAudioOutputStream* stream) {
44 delete stream; 41 delete stream;
45 } 42 }
46 43
47 namespace { 44 namespace {
48 AudioManagerMac* g_audio_manager = NULL; 45
49 46 AudioManagerMac* g_audio_manager = NULL;
47
50 } // namespace. 48 } // namespace.
51 49
52 void DestroyAudioManagerMac(void* param) { 50 void DestroyAudioManagerMac(void* param) {
53 delete g_audio_manager; 51 delete g_audio_manager;
54 g_audio_manager = NULL; 52 g_audio_manager = NULL;
55 } 53 }
56 54
57 // By convention, the AudioManager is not thread safe. 55 // By convention, the AudioManager is not thread safe.
58 AudioManager* AudioManager::GetAudioManager() { 56 AudioManager* AudioManager::GetAudioManager() {
59 if (!g_audio_manager) { 57 if (!g_audio_manager) {
60 g_audio_manager = new AudioManagerMac(); 58 g_audio_manager = new AudioManagerMac();
61 base::AtExitManager::RegisterCallback(&DestroyAudioManagerMac, NULL); 59 base::AtExitManager::RegisterCallback(&DestroyAudioManagerMac, NULL);
62 } 60 }
63 return g_audio_manager; 61 return g_audio_manager;
64 } 62 }
OLDNEW
« no previous file with comments | « media/audio/mac/audio_manager_mac.h ('k') | media/audio/mac/audio_output_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698