annotate src/audio/mint/SDL_mintaudio_stfa.c @ 3846:66fb40445587 SDL-ryan-multiple-audio-device

Removed distinction between "available" and "init" in audio backends, since both had to be checked for success as a pair at the higher level and several of the Available methods were just always-succeed placeholders anyhow. Now the availability check is done in the init code, and the higher level tries all possible drivers until one manages to initialize successfully.
author Ryan C. Gordon <icculus@icculus.org>
date Tue, 17 Oct 2006 09:09:21 +0000
parents 1f156fd874fa
children
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
a8181c4040b8 Fixed include files
Patrice Mandin <patmandin@gmail.com>
parents: 1402
diff changeset
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 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
74 MINTSTFA_LockDevice(_THIS)
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 /* 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
77 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
78 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
79 Super(oldpile);
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
80 }
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
81
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
82 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
83 MINTSTFA_UnlockDevice(_THIS)
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
84 {
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
85 /* 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
86 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
87 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
88 Super(oldpile);
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
89 }
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
90
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
91 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
92 MINTSTFA_CloseDevice(_THIS)
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
93 {
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
94 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
95 /* 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
96 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
97 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
98 Super(oldpile);
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
99
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
100 /* 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
101 while (SDL_MintAudio_mutex != 0) {}
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
102
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
103 /* 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
104 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
105 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
106 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
107 }
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
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
109 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
110 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
111 }
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
112 }
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
113
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
114 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
115 MINTSTFA_CheckAudio(_THIS)
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
116 {
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
117 int i;
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
118
2043
adf732f1f016 Formatting update
Sam Lantinga <slouken@libsdl.org>
parents: 2027
diff changeset
119 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
120 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
121 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
122 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
123 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
124 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
125 DEBUG_PRINT(("freq=%d\n", this->spec.freq));
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
126
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
127 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
128 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
129 }
45af7d69f8eb MiNT audio driver cleanups for clamping types and channels to supported
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
130
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
131 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
132 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
133 }
45af7d69f8eb MiNT audio driver cleanups for clamping types and channels to supported
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
134
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
135 /* 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
136 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
137 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
138 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
139 }
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
140
961
185acc07127a Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
141 #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
142 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
143 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
144 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
145 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
146 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
147 }
961
185acc07127a Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
148 #endif
185acc07127a Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
149
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
150 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
151 this->spec.freq = MINTAUDIO_frequencies[MINTAUDIO_numfreq].frequency;
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
152
2043
adf732f1f016 Formatting update
Sam Lantinga <slouken@libsdl.org>
parents: 2027
diff changeset
153 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
154 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
155 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
156 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
157 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
158 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
159 DEBUG_PRINT(("freq=%d\n", this->spec.freq));
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
160
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
161 return 0;
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
162 }
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
163
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
164 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
165 MINTSTFA_InitAudio(_THIS)
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
166 {
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
167 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
168 void *oldpile = (void *) Super(0);
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
169
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
170 /* 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
171 cookie_stfa->sound_enable = STFA_PLAY_DISABLE;
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
172
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
173 /* 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
174 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
175 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
176 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
177 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
178 } 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
179 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
180 }
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
181 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
182 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
183 } 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
184 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
185 }
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
186 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
187 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
188 } 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
189 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
190 }
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
191 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
192 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
193 } 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
194 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
195 }
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
196
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
197 /* 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
198 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
199 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
200
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
201 /* 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
202 cookie_stfa->stfa_it = SDL_MintAudio_StfaInterrupt;
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
203
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
204 /* 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
205 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
206
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 Super(oldpile);
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
208
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
209 DEBUG_PRINT((DEBUG_NAME "hardware initialized\n"));
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
210 }
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
211
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 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
213 MINTSTFA_OpenDevice(_THIS, const char *devname, int iscapture)
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
214 {
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
215 SDL_MintAudio_device = this;
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
216
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 /* 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
218 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
219 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
220 }
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
221
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
222 /* 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
223 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
224 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
225 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
226 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
227 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
228 }
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
229 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
230
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
231 SDL_CalculateAudioSpec(&this->spec);
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
232
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
233 /* 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
234 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
235
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
236 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
237 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
238 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
239 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
240 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
241 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
242 }
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 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
244 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
245 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
246 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
247 SDL_MintAudio_mutex = 0;
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
248
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
249 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
250 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
251 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
252 SDL_MintAudio_audiobuf[1]));
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
253
2027
d48ead2d2ba5 Save/restore FPU registers in interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 2005
diff changeset
254 SDL_MintAudio_CheckFpu();
d48ead2d2ba5 Save/restore FPU registers in interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 2005
diff changeset
255
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
256 /* 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
257 MINTSTFA_InitAudio(this);
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
258
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 return 1; /* good to go. */
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
260 }
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
261
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
262
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 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
264 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
265 {
3846
66fb40445587 Removed distinction between "available" and "init" in audio backends, since
Ryan C. Gordon <icculus@icculus.org>
parents: 3820
diff changeset
266 /* Cookie _MCH present ? if not, assume ST machine */
66fb40445587 Removed distinction between "available" and "init" in audio backends, since
Ryan C. Gordon <icculus@icculus.org>
parents: 3820
diff changeset
267 if (Getcookie(C__MCH, &cookie_mch) == C_NOTFOUND) {
66fb40445587 Removed distinction between "available" and "init" in audio backends, since
Ryan C. Gordon <icculus@icculus.org>
parents: 3820
diff changeset
268 cookie_mch = MCH_ST;
66fb40445587 Removed distinction between "available" and "init" in audio backends, since
Ryan C. Gordon <icculus@icculus.org>
parents: 3820
diff changeset
269 }
66fb40445587 Removed distinction between "available" and "init" in audio backends, since
Ryan C. Gordon <icculus@icculus.org>
parents: 3820
diff changeset
270
66fb40445587 Removed distinction between "available" and "init" in audio backends, since
Ryan C. Gordon <icculus@icculus.org>
parents: 3820
diff changeset
271 /* Cookie _SND present ? if not, assume ST machine */
66fb40445587 Removed distinction between "available" and "init" in audio backends, since
Ryan C. Gordon <icculus@icculus.org>
parents: 3820
diff changeset
272 if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) {
66fb40445587 Removed distinction between "available" and "init" in audio backends, since
Ryan C. Gordon <icculus@icculus.org>
parents: 3820
diff changeset
273 cookie_snd = SND_PSG;
66fb40445587 Removed distinction between "available" and "init" in audio backends, since
Ryan C. Gordon <icculus@icculus.org>
parents: 3820
diff changeset
274 }
66fb40445587 Removed distinction between "available" and "init" in audio backends, since
Ryan C. Gordon <icculus@icculus.org>
parents: 3820
diff changeset
275
66fb40445587 Removed distinction between "available" and "init" in audio backends, since
Ryan C. Gordon <icculus@icculus.org>
parents: 3820
diff changeset
276 /* Cookie STFA present ? */
66fb40445587 Removed distinction between "available" and "init" in audio backends, since
Ryan C. Gordon <icculus@icculus.org>
parents: 3820
diff changeset
277 if (Getcookie(C_STFA, (long *) &cookie_stfa) != C_FOUND) {
66fb40445587 Removed distinction between "available" and "init" in audio backends, since
Ryan C. Gordon <icculus@icculus.org>
parents: 3820
diff changeset
278 SDL_SetError(DEBUG_NAME "no STFA audio");
66fb40445587 Removed distinction between "available" and "init" in audio backends, since
Ryan C. Gordon <icculus@icculus.org>
parents: 3820
diff changeset
279 return (0);
66fb40445587 Removed distinction between "available" and "init" in audio backends, since
Ryan C. Gordon <icculus@icculus.org>
parents: 3820
diff changeset
280 }
66fb40445587 Removed distinction between "available" and "init" in audio backends, since
Ryan C. Gordon <icculus@icculus.org>
parents: 3820
diff changeset
281
66fb40445587 Removed distinction between "available" and "init" in audio backends, since
Ryan C. Gordon <icculus@icculus.org>
parents: 3820
diff changeset
282 SDL_MintAudio_stfa = cookie_stfa;
66fb40445587 Removed distinction between "available" and "init" in audio backends, since
Ryan C. Gordon <icculus@icculus.org>
parents: 3820
diff changeset
283
66fb40445587 Removed distinction between "available" and "init" in audio backends, since
Ryan C. Gordon <icculus@icculus.org>
parents: 3820
diff changeset
284 DEBUG_PRINT((DEBUG_NAME "STFA audio available!\n"));
66fb40445587 Removed distinction between "available" and "init" in audio backends, since
Ryan C. Gordon <icculus@icculus.org>
parents: 3820
diff changeset
285
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
286 /* 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
287 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
288 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
289 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
290 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
291 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
292 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
293 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
294
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 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
296 }
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
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 AudioBootStrap MINTAUDIO_STFA_bootstrap = {
3846
66fb40445587 Removed distinction between "available" and "init" in audio backends, since
Ryan C. Gordon <icculus@icculus.org>
parents: 3820
diff changeset
299 MINT_AUDIO_DRIVER_NAME, "MiNT STFA audio driver", MINTSTFA_Init, 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
300 };
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
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
302 /* vi: set ts=4 sw=4 expandtab: */