Mercurial > sdl-ios-xcode
annotate src/audio/mint/SDL_mintaudio_stfa.c @ 3842:6b04ca2f1016 SDL-ryan-multiple-audio-device
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Tue, 17 Oct 2006 06:37:42 +0000 |
parents | 1f156fd874fa |
children | 66fb40445587 |
rev | line source |
---|---|
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
1 /* |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
769
b8d311d90021
Updated copyright information for 2004 (Happy New Year!)
Sam Lantinga <slouken@libsdl.org>
parents:
704
diff
changeset
|
3 Copyright (C) 1997-2004 Sam Lantinga |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
4 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Library General Public |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
8 version 2 of the License, or (at your option) any later version. |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
9 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
13 Library General Public License for more details. |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
14 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Library General Public |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
18 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
19 Sam Lantinga |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
20 slouken@libsdl.org |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
21 */ |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1395
diff
changeset
|
22 #include "SDL_config.h" |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
23 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
24 /* |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
25 MiNT audio driver |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
26 using XBIOS functions (STFA driver) |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
27 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
28 Patrice Mandin |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
29 */ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
30 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
31 /* Mint includes */ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
32 #include <mint/osbind.h> |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
33 #include <mint/falcon.h> |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
34 #include <mint/cookie.h> |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
35 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
36 #include "SDL_audio.h" |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
37 #include "../SDL_audio_c.h" |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
38 #include "../SDL_sysaudio.h" |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
39 |
1412 | 40 #include "../../video/ataricommon/SDL_atarimxalloc_c.h" |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
41 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
42 #include "SDL_mintaudio.h" |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
43 #include "SDL_mintaudio_stfa.h" |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
44 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
45 /*--- Defines ---*/ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
46 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
47 #define MINT_AUDIO_DRIVER_NAME "mint_stfa" |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
48 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
49 /* Debug print info */ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
50 #define DEBUG_NAME "audio:stfa: " |
962
176240cf4405
Forgot to disable debug messages
Patrice Mandin <patmandin@gmail.com>
parents:
961
diff
changeset
|
51 #if 0 |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
52 #define DEBUG_PRINT(what) \ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
53 { \ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
54 printf what; \ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
55 } |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
56 #else |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
57 #define DEBUG_PRINT(what) |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
58 #endif |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
59 |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
60 /*--- Static variables ---*/ |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
61 |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
62 static unsigned long cookie_snd = 0; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
63 static unsigned long cookie_mch = 0; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
64 static cookie_stfa_t *cookie_stfa = NULL; |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
65 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
66 static const int freqs[16] = { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
67 4995, 6269, 7493, 8192, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
68 9830, 10971, 12538, 14985, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
69 16384, 19819, 21943, 24576, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
70 30720, 32336, 43885, 49152 |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
71 }; |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
72 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
73 static int |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
74 MINTSTFA_Available(void) |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
75 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
76 /* Cookie _MCH present ? if not, assume ST machine */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
77 if (Getcookie(C__MCH, &cookie_mch) == C_NOTFOUND) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
78 cookie_mch = MCH_ST; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
79 } |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
80 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
81 /* Cookie _SND present ? if not, assume ST machine */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
82 if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
83 cookie_snd = SND_PSG; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
84 } |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
85 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
86 /* Cookie STFA present ? */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
87 if (Getcookie(C_STFA, (long *) &cookie_stfa) != C_FOUND) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
88 DEBUG_PRINT((DEBUG_NAME "no STFA audio\n")); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
89 return (0); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
90 } |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
91 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
92 SDL_MintAudio_stfa = cookie_stfa; |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
93 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
94 DEBUG_PRINT((DEBUG_NAME "STFA audio available!\n")); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
95 return (1); |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
96 } |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
97 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
98 static void |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
99 MINTSTFA_LockDevice(_THIS) |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
100 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
101 /* Stop replay */ |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
102 void *oldpile = (void *) Super(0); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
103 cookie_stfa->sound_enable = STFA_PLAY_DISABLE; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
104 Super(oldpile); |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
105 } |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
106 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
107 static void |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
108 MINTSTFA_UnlockDevice(_THIS) |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
109 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
110 /* Restart replay */ |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
111 void *oldpile = (void *) Super(0); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
112 cookie_stfa->sound_enable = STFA_PLAY_ENABLE | STFA_PLAY_REPEAT; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
113 Super(oldpile); |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
114 } |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
115 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
116 static void |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
117 MINTSTFA_CloseDevice(_THIS) |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
118 { |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
119 if (this->hidden != NULL) { |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
120 /* Stop replay */ |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
121 void *oldpile = (void *) Super(0); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
122 cookie_stfa->sound_enable = STFA_PLAY_DISABLE; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
123 Super(oldpile); |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
124 |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
125 /* Wait if currently playing sound */ |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
126 while (SDL_MintAudio_mutex != 0) {} |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
127 |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
128 /* Clear buffers */ |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
129 if (SDL_MintAudio_audiobuf[0]) { |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
130 Mfree(SDL_MintAudio_audiobuf[0]); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
131 SDL_MintAudio_audiobuf[0] = SDL_MintAudio_audiobuf[1] = NULL; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
132 } |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
133 |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
134 SDL_free(this->hidden); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
135 this->hidden = NULL; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
136 } |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
137 } |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
138 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
139 static int |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
140 MINTSTFA_CheckAudio(_THIS) |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
141 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
142 int i; |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
143 |
2043 | 144 DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ", |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
145 SDL_AUDIO_BITSIZE(this->spec.format))); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
146 DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format))); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
147 DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(this->spec.format))); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
148 DEBUG_PRINT(("big endian=%d, ", SDL_AUDIO_ISBIGENDIAN(this->spec.format))); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
149 DEBUG_PRINT(("channels=%d, ", this->spec.channels)); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
150 DEBUG_PRINT(("freq=%d\n", this->spec.freq)); |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
151 |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
152 if (SDL_AUDIO_BITSIZE(this->spec.format) > 16) { |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
153 this->spec.format = AUDIO_S16SYS; /* clamp out int32/float32 ... */ |
2005
45af7d69f8eb
MiNT audio driver cleanups for clamping types and channels to supported
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
154 } |
45af7d69f8eb
MiNT audio driver cleanups for clamping types and channels to supported
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
155 |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
156 if (this->spec.channels > 2) { |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
157 this->spec.channels = 2; /* no more than stereo! */ |
2005
45af7d69f8eb
MiNT audio driver cleanups for clamping types and channels to supported
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
158 } |
45af7d69f8eb
MiNT audio driver cleanups for clamping types and channels to supported
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
159 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
160 /* Check formats available */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
161 MINTAUDIO_freqcount = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
162 for (i = 0; i < 16; i++) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
163 SDL_MintAudio_AddFrequency(this, freqs[i], 0, i, -1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
164 } |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
165 |
961
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
166 #if 1 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
167 for (i = 0; i < MINTAUDIO_freqcount; i++) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
168 DEBUG_PRINT((DEBUG_NAME "freq %d: %lu Hz, clock %lu, prediv %d\n", |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
169 i, MINTAUDIO_frequencies[i].frequency, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
170 MINTAUDIO_frequencies[i].masterclock, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
171 MINTAUDIO_frequencies[i].predivisor)); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
172 } |
961
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
173 #endif |
185acc07127a
Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents:
769
diff
changeset
|
174 |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
175 MINTAUDIO_numfreq = SDL_MintAudio_SearchFrequency(this, this->spec.freq); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
176 this->spec.freq = MINTAUDIO_frequencies[MINTAUDIO_numfreq].frequency; |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
177 |
2043 | 178 DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ", |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
179 SDL_AUDIO_BITSIZE(this->spec.format))); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
180 DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format))); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
181 DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(this->spec.format))); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
182 DEBUG_PRINT(("big endian=%d, ", SDL_AUDIO_ISBIGENDIAN(this->spec.format))); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
183 DEBUG_PRINT(("channels=%d, ", this->spec.channels)); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
184 DEBUG_PRINT(("freq=%d\n", this->spec.freq)); |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
185 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
186 return 0; |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
187 } |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
188 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
189 static void |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
190 MINTSTFA_InitAudio(_THIS) |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
191 { |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
192 void *buffer = SDL_MintAudio_audiobuf[SDL_MintAudio_numbuf]; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
193 void *oldpile = (void *) Super(0); |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
194 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
195 /* Stop replay */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
196 cookie_stfa->sound_enable = STFA_PLAY_DISABLE; |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
197 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
198 /* Select replay format */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
199 cookie_stfa->sound_control = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
200 MINTAUDIO_frequencies[MINTAUDIO_numfreq].predivisor; |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
201 if (SDL_AUDIO_BITSIZE(this->spec.format) == 8) { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
202 cookie_stfa->sound_control |= STFA_FORMAT_8BIT; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
203 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
204 cookie_stfa->sound_control |= STFA_FORMAT_16BIT; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
205 } |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
206 if (this->spec.channels == 2) { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
207 cookie_stfa->sound_control |= STFA_FORMAT_STEREO; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
208 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
209 cookie_stfa->sound_control |= STFA_FORMAT_MONO; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
210 } |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
211 if (SDL_AUDIO_ISSIGNED(this->spec.format) != 0) { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
212 cookie_stfa->sound_control |= STFA_FORMAT_SIGNED; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
213 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
214 cookie_stfa->sound_control |= STFA_FORMAT_UNSIGNED; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
215 } |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
216 if (SDL_AUDIO_ISBIGENDIAN(this->spec.format) != 0) { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
217 cookie_stfa->sound_control |= STFA_FORMAT_BIGENDIAN; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
218 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
219 cookie_stfa->sound_control |= STFA_FORMAT_LITENDIAN; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
220 } |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
221 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
222 /* Set buffer */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
223 cookie_stfa->sound_start = (unsigned long) buffer; |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
224 cookie_stfa->sound_end = (unsigned long) (buffer + this->spec.size); |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
225 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
226 /* Set interrupt */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
227 cookie_stfa->stfa_it = SDL_MintAudio_StfaInterrupt; |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
228 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
229 /* Restart replay */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
230 cookie_stfa->sound_enable = STFA_PLAY_ENABLE | STFA_PLAY_REPEAT; |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
231 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
232 Super(oldpile); |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
233 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
234 DEBUG_PRINT((DEBUG_NAME "hardware initialized\n")); |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
235 } |
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
236 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
237 static int |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
238 MINTSTFA_OpenDevice(_THIS, const char *devname, int iscapture) |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
239 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
240 SDL_MintAudio_device = this; |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
241 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
242 /* Check audio capabilities */ |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
243 if (MINTSTFA_CheckAudio(this) == -1) { |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
244 return 0; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
245 } |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
246 |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
247 /* Initialize all variables that we clean on shutdown */ |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
248 this->hidden = (struct SDL_PrivateAudioData *) |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
249 SDL_malloc((sizeof *this->hidden)); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
250 if (this->hidden == NULL) { |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
251 SDL_OutOfMemory(); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
252 return 0; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
253 } |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
254 SDL_memset(this->hidden, 0, (sizeof *this->hidden)); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
255 |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
256 SDL_CalculateAudioSpec(&this->spec); |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
257 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
258 /* Allocate memory for audio buffers in DMA-able RAM */ |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
259 DEBUG_PRINT((DEBUG_NAME "buffer size=%d\n", this->spec.size)); |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
260 |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
261 SDL_MintAudio_audiobuf[0] = Atari_SysMalloc(this->spec.size * 2, MX_STRAM); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
262 if (SDL_MintAudio_audiobuf[0] == NULL) { |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
263 SDL_OutOfMemory() |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
264 SDL_free(this->hidden); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
265 this->hidden = NULL; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
266 return 0; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
267 } |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
268 SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + this->spec.size; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
269 SDL_MintAudio_numbuf = 0; |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
270 SDL_memset(SDL_MintAudio_audiobuf[0],this->spec.silence,this->spec.size*2); |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
271 SDL_MintAudio_audiosize = this->spec.size; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
272 SDL_MintAudio_mutex = 0; |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
273 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
274 DEBUG_PRINT((DEBUG_NAME "buffer 0 at 0x%08x\n", |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
275 SDL_MintAudio_audiobuf[0])); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
276 DEBUG_PRINT((DEBUG_NAME "buffer 1 at 0x%08x\n", |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
277 SDL_MintAudio_audiobuf[1])); |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
278 |
2027
d48ead2d2ba5
Save/restore FPU registers in interrupt
Patrice Mandin <patmandin@gmail.com>
parents:
2005
diff
changeset
|
279 SDL_MintAudio_CheckFpu(); |
d48ead2d2ba5
Save/restore FPU registers in interrupt
Patrice Mandin <patmandin@gmail.com>
parents:
2005
diff
changeset
|
280 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
281 /* Setup audio hardware */ |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
282 MINTSTFA_InitAudio(this); |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
283 |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
284 return 1; /* good to go. */ |
644
594422ab8f9f
Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff
changeset
|
285 } |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
286 |
3820
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
287 |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
288 static int |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
289 MINTSTFA_Init(SDL_AudioDriverImpl *impl) |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
290 { |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
291 /* Set the function pointers */ |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
292 impl->OpenDevice = MINTSTFA_OpenDevice; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
293 impl->CloseDevice = MINTSTFA_CloseDevice; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
294 impl->LockAudio = MINTSTFA_LockAudio; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
295 impl->UnlockAudio = MINTSTFA_UnlockAudio; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
296 impl->OnlyHasDefaultOutputDevice = 1; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
297 impl->ProvidesOwnCallbackThread = 1; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
298 impl->SkipMixerLock = 1; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
299 |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
300 return 1; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
301 } |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
302 |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
303 AudioBootStrap MINTAUDIO_STFA_bootstrap = { |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
304 MINT_AUDIO_DRIVER_NAME, "MiNT STFA audio driver", |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
305 MINTSTFA_Available, MINTSTFA_Init, 0 |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
306 }; |
1f156fd874fa
Moved more audio drivers to 1.3 API (all 5 MiNT backends, BSD, IRIX...), and
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
307 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1412
diff
changeset
|
308 /* vi: set ts=4 sw=4 expandtab: */ |