1 |
|
/* |
2 |
|
* audio_amiga.cpp - Audio support, AmigaOS implementation using AHI |
3 |
|
* |
4 |
< |
* Basilisk II (C) 1997-1999 Christian Bauer |
4 |
> |
* Basilisk II (C) 1997-2002 Christian Bauer |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
* it under the terms of the GNU General Public License as published by |
37 |
|
#include "debug.h" |
38 |
|
|
39 |
|
|
40 |
– |
// Supported sample rates, sizes and channels |
41 |
– |
int audio_num_sample_rates = 1; |
42 |
– |
uint32 audio_sample_rates[] = {22050 << 16}; |
43 |
– |
int audio_num_sample_sizes = 1; |
44 |
– |
uint16 audio_sample_sizes[] = {16}; |
45 |
– |
int audio_num_channel_counts = 1; |
46 |
– |
uint16 audio_channel_counts[] = {2}; |
47 |
– |
|
48 |
– |
|
40 |
|
// Global variables |
41 |
|
static ULONG ahi_id = AHI_DEFAULT_ID; // AHI audio ID |
42 |
|
static struct AHIAudioCtrl *ahi_ctrl = NULL; |
48 |
|
|
49 |
|
|
50 |
|
// Prototypes |
51 |
< |
static __saveds __regargs ULONG audio_callback(struct Hook *hook /*a0*/, struct AHISoundMessage *msg /*a1*/, struct AHIAudioCtrl *ahi_ctrl /*a2*/); |
51 |
> |
static __saveds __attribute__((regparm(3))) ULONG audio_callback(struct Hook *hook /*a0*/, struct AHISoundMessage *msg /*a1*/, struct AHIAudioCtrl *ahi_ctrl /*a2*/); |
52 |
|
|
53 |
|
|
54 |
|
/* |
55 |
|
* Initialization |
56 |
|
*/ |
57 |
|
|
58 |
+ |
// Set AudioStatus to reflect current audio stream format |
59 |
+ |
static void set_audio_status_format(void) |
60 |
+ |
{ |
61 |
+ |
AudioStatus.sample_rate = audio_sample_rates[0]; |
62 |
+ |
AudioStatus.sample_size = audio_sample_sizes[0]; |
63 |
+ |
AudioStatus.channels = audio_channel_counts[0]; |
64 |
+ |
} |
65 |
+ |
|
66 |
|
void AudioInit(void) |
67 |
|
{ |
68 |
|
sample[0].ahisi_Address = sample[1].ahisi_Address = NULL; |
69 |
|
|
70 |
|
// Init audio status and feature flags |
71 |
< |
AudioStatus.sample_rate = audio_sample_rates[0]; |
72 |
< |
AudioStatus.sample_size = audio_sample_sizes[0]; |
73 |
< |
AudioStatus.channels = audio_channel_counts[0]; |
71 |
> |
audio_sample_rates.push_back(22050 << 16); |
72 |
> |
audio_sample_sizes.push_back(16); |
73 |
> |
audio_channel_counts.push_back(2); |
74 |
> |
set_audio_status_format(); |
75 |
|
AudioStatus.mixer = 0; |
76 |
|
AudioStatus.num_sources = 0; |
77 |
|
audio_component_flags = cmpWantsRegisterMessage | kStereoOut | k16BitOut; |
174 |
|
* AHI sound callback, request next buffer |
175 |
|
*/ |
176 |
|
|
177 |
< |
static __saveds __regargs ULONG audio_callback(struct Hook *hook /*a0*/, struct AHISoundMessage *msg /*a1*/, struct AHIAudioCtrl *ahi_ctrl /*a2*/) |
177 |
> |
static __saveds __attribute__((regparm(3))) ULONG audio_callback(struct Hook *hook /*a0*/, struct AHISoundMessage *msg /*a1*/, struct AHIAudioCtrl *ahi_ctrl /*a2*/) |
178 |
|
{ |
179 |
|
play_buf ^= 1; |
180 |
|
|
192 |
|
|
193 |
|
// Put data into AHI buffer (convert 8-bit data unsigned->signed) |
194 |
|
if (AudioStatus.sample_size == 16) |
195 |
< |
memcpy(sample[play_buf].ahisi_Address, Mac2HostAddr(ReadMacInt32(apple_stream_info + scd_buffer)), work_size); |
195 |
> |
Mac2Host_memcpy(sample[play_buf].ahisi_Address, ReadMacInt32(apple_stream_info + scd_buffer), work_size); |
196 |
|
else { |
197 |
|
uint32 *p = (uint32 *)Mac2HostAddr(ReadMacInt32(apple_stream_info + scd_buffer)); |
198 |
|
uint32 *q = (uint32 *)sample[play_buf].ahisi_Address; |
250 |
|
* It is guaranteed that AudioStatus.num_sources == 0 |
251 |
|
*/ |
252 |
|
|
253 |
< |
void audio_set_sample_rate(int index) |
253 |
> |
bool audio_set_sample_rate(int index) |
254 |
|
{ |
255 |
+ |
return true; |
256 |
|
} |
257 |
|
|
258 |
< |
void audio_set_sample_size(int index) |
258 |
> |
bool audio_set_sample_size(int index) |
259 |
|
{ |
260 |
+ |
return true; |
261 |
|
} |
262 |
|
|
263 |
< |
void audio_set_channels(int index) |
263 |
> |
bool audio_set_channels(int index) |
264 |
|
{ |
265 |
+ |
return true; |
266 |
|
} |
267 |
|
|
268 |
|
|
282 |
|
return 0x01000100; |
283 |
|
} |
284 |
|
|
285 |
< |
bool audio_get_dac_mute(void) |
285 |
> |
bool audio_get_speaker_mute(void) |
286 |
|
{ |
287 |
|
return false; |
288 |
|
} |
289 |
|
|
290 |
< |
uint32 audio_get_dac_volume(void) |
290 |
> |
uint32 audio_get_speaker_volume(void) |
291 |
|
{ |
292 |
|
return 0x01000100; |
293 |
|
} |
300 |
|
{ |
301 |
|
} |
302 |
|
|
303 |
< |
void audio_set_dac_mute(bool mute) |
303 |
> |
void audio_set_speaker_mute(bool mute) |
304 |
|
{ |
305 |
|
} |
306 |
|
|
307 |
< |
void audio_set_dac_volume(uint32 vol) |
307 |
> |
void audio_set_speaker_volume(uint32 vol) |
308 |
|
{ |
309 |
|
} |