ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/MacOSX/audio_macosx.mm
Revision: 1.1
Committed: 2003-03-23T23:36:04Z (21 years, 8 months ago) by nigel
Branch: MAIN
CVS Tags: nigel-build-12, nigel-build-13
Log Message:
Start of audio hacking

File Contents

# User Rev Content
1 nigel 1.1 /*
2     * audio_MacOSX.cpp - Based on audio_dummy.cpp
3     *
4     * $Id: audio_macosx.cpp,v 1.1 2002/03/16 03:59:58 nigel Exp $
5     *
6     * Basilisk II (C) 1997-2002 Christian Bauer
7     *
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.
12     *
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.
17     *
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
21     */
22    
23     #include "sysdeps.h"
24     #include "macos_util_macosx.h"
25     #include "prefs.h"
26     #include "audio.h"
27     #include "audio_defs_macosx.h"
28    
29     #define DEBUG 0
30     #include "debug.h"
31    
32    
33     #include "main_macosx.h"
34    
35     #import <CoreFoundation/CoreFoundation.h>
36    
37     #import <CoreAudio/CoreAudio.h>
38    
39     #import <AppKit/AppKit.h>
40    
41    
42    
43     AudioDeviceID device = kAudioDeviceUnknown;
44    
45     /*
46     * Initialization
47     */
48    
49     void AudioInit(void)
50     {
51     UInt32 count;
52     OSErr err;
53    
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;
61    
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);
66    
67     // Sound disabled in prefs? Then do nothing
68     if (PrefsFindBool("nosound"))
69     return;
70    
71    
72     // Get default audio device
73    
74     count = sizeof(device);
75     err = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultOutputDevice,
76     &count, (void *) &device);
77     if ( err != noErr || device == kAudioDeviceUnknown )
78     {
79     NSLog(@"Failed to get default audio output device");
80     audio_open = false;
81     return;
82     }
83    
84     D(NSLog(@"Got default audio output device"));
85    
86     // Audio not available
87     audio_open = false;
88     }
89    
90    
91     /*
92     * Deinitialization
93     */
94    
95     void AudioExit(void)
96     {
97     }
98    
99    
100     /*
101     * First source added, start audio stream
102     */
103    
104     void audio_enter_stream()
105     {
106     }
107    
108    
109     /*
110     * Last source removed, stop audio stream
111     */
112    
113     void audio_exit_stream()
114     {
115     }
116    
117    
118     /*
119     * MacOS audio interrupt, read next data block
120     */
121    
122     void AudioInterrupt(void)
123     {
124     D(bug("AudioInterrupt\n"));
125     }
126    
127    
128     /*
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
132     */
133    
134     bool audio_set_sample_rate(int index)
135     {
136     return NO;
137     }
138    
139     bool audio_set_sample_size(int index)
140     {
141     return NO;
142     }
143    
144     bool audio_set_channels(int index)
145     {
146     return NO;
147     }
148    
149    
150     /*
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"))
154     */
155    
156     bool audio_get_main_mute(void)
157     {
158     return false;
159     }
160    
161     uint32 audio_get_main_volume(void)
162     {
163     return 0x01000100;
164     }
165    
166     bool audio_get_speaker_mute(void)
167     {
168     return false;
169     }
170    
171     uint32 audio_get_speaker_volume(void)
172     {
173     return 0x01000100;
174     }
175    
176     void audio_set_main_mute(bool mute)
177     {
178     }
179    
180     void audio_set_main_volume(uint32 vol)
181     {
182     }
183    
184     void audio_set_speaker_mute(bool mute)
185     {
186     }
187    
188     void audio_set_speaker_volume(uint32 vol)
189     {
190     }