blob: 7a8e15b8ed6859d49d9bd05b808ff532eebbcf33 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <CoreAudio/AudioHardware.h>
#include "base/at_exit.h"
#include "media/audio/mac/audio_manager_mac.h"
#include "media/audio/mac/audio_output_mac.h"
bool AudioManagerMac::HasAudioDevices() {
AudioDeviceID output_device_id = 0;
size_t size = sizeof(output_device_id);
OSStatus err = AudioHardwareGetProperty(
kAudioHardwarePropertyDefaultOutputDevice, &size, &output_device_id);
return ((err == noErr) && (output_device_id > 0));
}
AudioOutputStream* AudioManagerMac::MakeAudioStream(Format format, int channels,
int sample_rate,
char bits_per_sample) {
// TODO(cpu): add mock format.
if (format != AUDIO_PCM_LINEAR)
return NULL;
return new PCMQueueOutAudioOutputStream(this, channels, sample_rate,
bits_per_sample);
}
void AudioManagerMac::MuteAll() {
// TODO(cpu): implement.
}
void AudioManagerMac::UnMuteAll() {
// TODO(cpu): implement.
}
const void* AudioManagerMac::GetLastMockBuffer() {
// TODO(cpu): implement.
return NULL;
}
// Called by the stream when it has been released by calling Close().
void AudioManagerMac::ReleaseStream(PCMQueueOutAudioOutputStream* stream) {
delete stream;
}
namespace {
AudioManagerMac* g_audio_manager = NULL;
} // namespace.
void DestroyAudioManagerMac(void* param) {
delete g_audio_manager;
g_audio_manager = NULL;
}
// By convention, the AudioManager is not thread safe.
AudioManager* AudioManager::GetAudioManager() {
if (!g_audio_manager) {
g_audio_manager = new AudioManagerMac();
base::AtExitManager::RegisterCallback(&DestroyAudioManagerMac, NULL);
}
return g_audio_manager;
}
|