2
* audio_MacOSX.cpp - Based on audio_dummy.cpp
4
* $Id: audio_macosx.mm,v 1.1 2003/03/23 23:36:04 nigel Exp $
6
* Basilisk II (C) 1997-2002 Christian Bauer
8
* This program is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 2 of the License, or
11
* (at your option) any later version.
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
18
* You should have received a copy of the GNU General Public License
19
* along with this program; if not, write to the Free Software
20
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24
#include "macos_util_macosx.h"
27
#include "audio_defs_macosx.h"
33
#include "main_macosx.h"
35
#import <CoreFoundation/CoreFoundation.h>
37
#import <CoreAudio/CoreAudio.h>
39
#import <AppKit/AppKit.h>
43
AudioDeviceID device = kAudioDeviceUnknown;
54
// Init audio status and feature flags
55
AudioStatus.sample_rate = 44100 << 16;
56
AudioStatus.sample_size = 16;
57
AudioStatus.channels = 2;
58
AudioStatus.mixer = 0;
59
AudioStatus.num_sources = 0;
60
audio_component_flags = cmpWantsRegisterMessage | kStereoOut | k16BitOut;
62
// Only one sample format is supported
63
audio_sample_rates.push_back(44100 << 16);
64
audio_sample_sizes.push_back(16);
65
audio_channel_counts.push_back(2);
67
// Sound disabled in prefs? Then do nothing
68
if (PrefsFindBool("nosound"))
72
// Get default audio device
74
count = sizeof(device);
75
err = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice,
76
&count, (void *) &device);
77
if ( err != noErr || device == kAudioDeviceUnknown )
79
NSLog(@"Failed to get default audio output device");
84
D(NSLog(@"Got default audio output device"));
86
// Audio not available
101
* First source added, start audio stream
104
void audio_enter_stream()
110
* Last source removed, stop audio stream
113
void audio_exit_stream()
119
* MacOS audio interrupt, read next data block
122
void AudioInterrupt(void)
124
D(bug("AudioInterrupt\n"));
129
* Set sampling parameters
130
* "index" is an index into the audio_sample_rates[] etc. vectors
131
* It is guaranteed that AudioStatus.num_sources == 0
134
bool audio_set_sample_rate(int index)
139
bool audio_set_sample_size(int index)
144
bool audio_set_channels(int index)
151
* Get/set volume controls (volume values received/returned have the left channel
152
* volume in the upper 16 bits and the right channel volume in the lower 16 bits;
153
* both volumes are 8.8 fixed point values with 0x0100 meaning "maximum volume"))
156
bool audio_get_main_mute(void)
161
uint32 audio_get_main_volume(void)
166
bool audio_get_speaker_mute(void)
171
uint32 audio_get_speaker_volume(void)
176
void audio_set_main_mute(bool mute)
180
void audio_set_main_volume(uint32 vol)
184
void audio_set_speaker_mute(bool mute)
188
void audio_set_speaker_volume(uint32 vol)