annotate src/audio/mint/SDL_mintaudio_gsxb.c @ 3796:b19680c84cdf SDL-ryan-multiple-audio-device

Bunch of 1.3 audio cleanups to remove FIXMEs, get driver specific crap out of the core and into the drivers where it belongs, and push generic responsibilities out of the drivers and into the core where they belong.
author Ryan C. Gordon <icculus@icculus.org>
date Wed, 04 Oct 2006 19:54:23 +0000
parents 8d5d119b1640
children c8b3d3d13ed1
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: 1361
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 (GSXB compatible 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_gsxb.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_gsxb"
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:gsxb: "
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
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
62 static unsigned long cookie_snd, cookie_gsxb;
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
63
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
64 /*--- Audio driver functions ---*/
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
65
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
66 static void Mint_CloseAudio(_THIS);
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
67 static int Mint_OpenAudio(_THIS, SDL_AudioSpec * spec);
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
68 static void Mint_LockAudio(_THIS);
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
69 static void Mint_UnlockAudio(_THIS);
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
70
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
71 /* To check/init hardware audio */
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
72 static int Mint_CheckAudio(_THIS, SDL_AudioSpec * spec);
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 Mint_InitAudio(_THIS, SDL_AudioSpec * spec);
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
74
1097
c83fa1c650dd Move GSXB callback to C source
Patrice Mandin <patmandin@gmail.com>
parents: 962
diff changeset
75 /* GSXB callbacks */
c83fa1c650dd Move GSXB callback to C source
Patrice Mandin <patmandin@gmail.com>
parents: 962
diff changeset
76 static void Mint_GsxbInterrupt(void);
c83fa1c650dd Move GSXB callback to C source
Patrice Mandin <patmandin@gmail.com>
parents: 962
diff changeset
77 static void Mint_GsxbNullInterrupt(void);
c83fa1c650dd Move GSXB callback to C source
Patrice Mandin <patmandin@gmail.com>
parents: 962
diff changeset
78
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
79 /*--- Audio driver bootstrap functions ---*/
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 static int
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 Audio_Available(void)
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
83 {
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
84 const char *envr = SDL_getenv("SDL_AUDIODRIVER");
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 /* Check if user asked a different audio driver */
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 ((envr) && (SDL_strcmp(envr, MINT_AUDIO_DRIVER_NAME) != 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
88 DEBUG_PRINT((DEBUG_NAME "user asked a different audio driver\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 /* 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
93 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
94 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
95 }
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
96
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
97 /* Check if we have 16 bits audio */
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 if ((cookie_snd & SND_16BIT) == 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
99 DEBUG_PRINT((DEBUG_NAME "no 16 bits sound\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
100 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
101 }
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
102
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 GSXB 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
104 cookie_gsxb = (Getcookie(C_GSXB, &cookie_gsxb) == C_FOUND);
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
105
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
106 /* Is it GSXB ? */
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 if (((cookie_snd & SND_GSXB) == 0) || (cookie_gsxb == 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
108 DEBUG_PRINT((DEBUG_NAME "no GSXB 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
109 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
110 }
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
111
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 /* Check if audio is lockable */
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 if (Locksnd() != 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
114 DEBUG_PRINT((DEBUG_NAME "audio locked by other application\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
115 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
116 }
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
117
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
118 Unlocksnd();
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
119
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
120 DEBUG_PRINT((DEBUG_NAME "GSXB 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
121 return (1);
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
122 }
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
123
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
124 static void
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
125 Audio_DeleteDevice(SDL_AudioDevice * device)
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
126 {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1107
diff changeset
127 SDL_free(device->hidden);
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1107
diff changeset
128 SDL_free(device);
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
129 }
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
130
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
131 static SDL_AudioDevice *
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
132 Audio_CreateDevice(int devindex)
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
133 {
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
134 SDL_AudioDevice *this;
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
135
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 /* Initialize all variables that we clean on shutdown */
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 this = (SDL_AudioDevice *) SDL_malloc(sizeof(SDL_AudioDevice));
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 if (this) {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1107
diff changeset
139 SDL_memset(this, 0, (sizeof *this));
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
140 this->hidden = (struct SDL_PrivateAudioData *)
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
141 SDL_malloc((sizeof *this->hidden));
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
142 }
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
143 if ((this == NULL) || (this->hidden == NULL)) {
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
144 SDL_OutOfMemory();
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
145 if (this) {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1107
diff changeset
146 SDL_free(this);
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
147 }
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
148 return (0);
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
149 }
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1107
diff changeset
150 SDL_memset(this->hidden, 0, (sizeof *this->hidden));
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
151
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
152 /* Set the function pointers */
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
153 this->OpenAudio = Mint_OpenAudio;
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
154 this->CloseAudio = Mint_CloseAudio;
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
155 this->LockAudio = Mint_LockAudio;
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
156 this->UnlockAudio = Mint_UnlockAudio;
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
157 this->free = Audio_DeleteDevice;
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
158
3796
b19680c84cdf Bunch of 1.3 audio cleanups to remove FIXMEs, get driver specific crap out of
Ryan C. Gordon <icculus@icculus.org>
parents: 2044
diff changeset
159 /* Uses interrupt driven audio, without thread */
b19680c84cdf Bunch of 1.3 audio cleanups to remove FIXMEs, get driver specific crap out of
Ryan C. Gordon <icculus@icculus.org>
parents: 2044
diff changeset
160 #if SDL_THREADS_DISABLED
b19680c84cdf Bunch of 1.3 audio cleanups to remove FIXMEs, get driver specific crap out of
Ryan C. Gordon <icculus@icculus.org>
parents: 2044
diff changeset
161 this->SkipMixerLock = 1;
b19680c84cdf Bunch of 1.3 audio cleanups to remove FIXMEs, get driver specific crap out of
Ryan C. Gordon <icculus@icculus.org>
parents: 2044
diff changeset
162 #endif
b19680c84cdf Bunch of 1.3 audio cleanups to remove FIXMEs, get driver specific crap out of
Ryan C. Gordon <icculus@icculus.org>
parents: 2044
diff changeset
163
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
164 return this;
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
165 }
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
166
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
167 AudioBootStrap MINTAUDIO_GSXB_bootstrap = {
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
168 MINT_AUDIO_DRIVER_NAME, "MiNT GSXB audio driver",
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 Audio_Available, Audio_CreateDevice
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
170 };
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
171
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
172 static void
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 Mint_LockAudio(_THIS)
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
174 {
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
175 /* 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
176 Buffoper(0);
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
177 }
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
178
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
179 static void
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 Mint_UnlockAudio(_THIS)
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
181 {
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 /* 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
183 Buffoper(SB_PLA_ENA | SB_PLA_RPT);
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
184 }
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 static void
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 Mint_CloseAudio(_THIS)
644
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 /* 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
190 Buffoper(0);
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
191
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 /* Uninstall 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
193 if (NSetinterrupt(2, SI_NONE, Mint_GsxbNullInterrupt) < 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
194 DEBUG_PRINT((DEBUG_NAME "NSetinterrupt() failed in close\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
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 /* Wait if currently playing sound */
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 while (SDL_MintAudio_mutex != 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
199 }
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 /* Clear buffers */
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 if (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
203 Mfree(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
204 SDL_MintAudio_audiobuf[0] = SDL_MintAudio_audiobuf[1] = NULL;
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 }
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 /* Unlock sound system */
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 Unlocksnd();
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
209 }
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
210
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
211 static int
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 Mint_CheckAudio(_THIS, SDL_AudioSpec * spec)
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
213 {
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
214 long snd_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
215 int i, resolution, format_signed, format_bigendian;
2005
45af7d69f8eb MiNT audio driver cleanups for clamping types and channels to supported
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
216 SDL_AudioFormat test_format = SDL_FirstAudioFormat(spec->format);
45af7d69f8eb MiNT audio driver cleanups for clamping types and channels to supported
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
217 int valid_datatype = 0;
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
218
2005
45af7d69f8eb MiNT audio driver cleanups for clamping types and channels to supported
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
219 resolution = SDL_AUDIO_BITSIZE(spec->format);
45af7d69f8eb MiNT audio driver cleanups for clamping types and channels to supported
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
220 format_signed = SDL_AUDIO_ISSIGNED(spec->format);
45af7d69f8eb MiNT audio driver cleanups for clamping types and channels to supported
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
221 format_bigendian = SDL_AUDIO_ISBIGENDIAN(spec->format);
704
c4803992e09c Small bugfixes
Patrice Mandin <patmandin@gmail.com>
parents: 644
diff changeset
222
2005
45af7d69f8eb MiNT audio driver cleanups for clamping types and channels to supported
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
223 DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ", resolution));
45af7d69f8eb MiNT audio driver cleanups for clamping types and channels to supported
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
224 DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(spec->format)));
45af7d69f8eb MiNT audio driver cleanups for clamping types and channels to supported
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
225 DEBUG_PRINT(("signed=%d, ", format_signed));
45af7d69f8eb MiNT audio driver cleanups for clamping types and channels to supported
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
226 DEBUG_PRINT(("big endian=%d, ", format_bigendian));
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
227 DEBUG_PRINT(("channels=%d, ", spec->channels));
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
228 DEBUG_PRINT(("freq=%d\n", spec->freq));
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
229
2005
45af7d69f8eb MiNT audio driver cleanups for clamping types and channels to supported
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
230 if (spec->channels > 2) {
2043
adf732f1f016 Formatting update
Sam Lantinga <slouken@libsdl.org>
parents: 2027
diff changeset
231 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
232 }
45af7d69f8eb MiNT audio driver cleanups for clamping types and channels to supported
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
233
45af7d69f8eb MiNT audio driver cleanups for clamping types and channels to supported
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
234 while ((!valid_datatype) && (test_format)) {
2044
8d5d119b1640 Minor cleanup in the mint driver that was sitting on my laptop (sorry!).
Ryan C. Gordon <icculus@icculus.org>
parents: 2043
diff changeset
235 /* Check formats available */
8d5d119b1640 Minor cleanup in the mint driver that was sitting on my laptop (sorry!).
Ryan C. Gordon <icculus@icculus.org>
parents: 2043
diff changeset
236 snd_format = Sndstatus(SND_QUERYFORMATS);
2005
45af7d69f8eb MiNT audio driver cleanups for clamping types and channels to supported
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
237 spec->format = test_format;
2044
8d5d119b1640 Minor cleanup in the mint driver that was sitting on my laptop (sorry!).
Ryan C. Gordon <icculus@icculus.org>
parents: 2043
diff changeset
238 resolution = SDL_AUDIO_BITSIZE(spec->format);
8d5d119b1640 Minor cleanup in the mint driver that was sitting on my laptop (sorry!).
Ryan C. Gordon <icculus@icculus.org>
parents: 2043
diff changeset
239 format_signed = SDL_AUDIO_ISSIGNED(spec->format);
8d5d119b1640 Minor cleanup in the mint driver that was sitting on my laptop (sorry!).
Ryan C. Gordon <icculus@icculus.org>
parents: 2043
diff changeset
240 format_bigendian = SDL_AUDIO_ISBIGENDIAN(spec->format);
2005
45af7d69f8eb MiNT audio driver cleanups for clamping types and channels to supported
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
241 switch (test_format) {
2044
8d5d119b1640 Minor cleanup in the mint driver that was sitting on my laptop (sorry!).
Ryan C. Gordon <icculus@icculus.org>
parents: 2043
diff changeset
242 case AUDIO_U8:
8d5d119b1640 Minor cleanup in the mint driver that was sitting on my laptop (sorry!).
Ryan C. Gordon <icculus@icculus.org>
parents: 2043
diff changeset
243 case AUDIO_S8:
2043
adf732f1f016 Formatting update
Sam Lantinga <slouken@libsdl.org>
parents: 2027
diff changeset
244 if (snd_format & SND_FORMAT8) {
adf732f1f016 Formatting update
Sam Lantinga <slouken@libsdl.org>
parents: 2027
diff changeset
245 valid_datatype = 1;
adf732f1f016 Formatting update
Sam Lantinga <slouken@libsdl.org>
parents: 2027
diff changeset
246 snd_format = Sndstatus(SND_QUERY8BIT);
2005
45af7d69f8eb MiNT audio driver cleanups for clamping types and channels to supported
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
247 }
2043
adf732f1f016 Formatting update
Sam Lantinga <slouken@libsdl.org>
parents: 2027
diff changeset
248 break;
2044
8d5d119b1640 Minor cleanup in the mint driver that was sitting on my laptop (sorry!).
Ryan C. Gordon <icculus@icculus.org>
parents: 2043
diff changeset
249
8d5d119b1640 Minor cleanup in the mint driver that was sitting on my laptop (sorry!).
Ryan C. Gordon <icculus@icculus.org>
parents: 2043
diff changeset
250 case AUDIO_U16LSB:
8d5d119b1640 Minor cleanup in the mint driver that was sitting on my laptop (sorry!).
Ryan C. Gordon <icculus@icculus.org>
parents: 2043
diff changeset
251 case AUDIO_S16LSB:
8d5d119b1640 Minor cleanup in the mint driver that was sitting on my laptop (sorry!).
Ryan C. Gordon <icculus@icculus.org>
parents: 2043
diff changeset
252 case AUDIO_U16MSB:
8d5d119b1640 Minor cleanup in the mint driver that was sitting on my laptop (sorry!).
Ryan C. Gordon <icculus@icculus.org>
parents: 2043
diff changeset
253 case AUDIO_S16MSB:
2043
adf732f1f016 Formatting update
Sam Lantinga <slouken@libsdl.org>
parents: 2027
diff changeset
254 if (snd_format & SND_FORMAT16) {
adf732f1f016 Formatting update
Sam Lantinga <slouken@libsdl.org>
parents: 2027
diff changeset
255 valid_datatype = 1;
adf732f1f016 Formatting update
Sam Lantinga <slouken@libsdl.org>
parents: 2027
diff changeset
256 snd_format = Sndstatus(SND_QUERY16BIT);
adf732f1f016 Formatting update
Sam Lantinga <slouken@libsdl.org>
parents: 2027
diff changeset
257 }
adf732f1f016 Formatting update
Sam Lantinga <slouken@libsdl.org>
parents: 2027
diff changeset
258 break;
2044
8d5d119b1640 Minor cleanup in the mint driver that was sitting on my laptop (sorry!).
Ryan C. Gordon <icculus@icculus.org>
parents: 2043
diff changeset
259
8d5d119b1640 Minor cleanup in the mint driver that was sitting on my laptop (sorry!).
Ryan C. Gordon <icculus@icculus.org>
parents: 2043
diff changeset
260 case AUDIO_S32LSB:
8d5d119b1640 Minor cleanup in the mint driver that was sitting on my laptop (sorry!).
Ryan C. Gordon <icculus@icculus.org>
parents: 2043
diff changeset
261 case AUDIO_S32MSB:
2043
adf732f1f016 Formatting update
Sam Lantinga <slouken@libsdl.org>
parents: 2027
diff changeset
262 if (snd_format & SND_FORMAT32) {
adf732f1f016 Formatting update
Sam Lantinga <slouken@libsdl.org>
parents: 2027
diff changeset
263 valid_datatype = 1;
adf732f1f016 Formatting update
Sam Lantinga <slouken@libsdl.org>
parents: 2027
diff changeset
264 snd_format = Sndstatus(SND_QUERY32BIT);
adf732f1f016 Formatting update
Sam Lantinga <slouken@libsdl.org>
parents: 2027
diff changeset
265 }
adf732f1f016 Formatting update
Sam Lantinga <slouken@libsdl.org>
parents: 2027
diff changeset
266 break;
2044
8d5d119b1640 Minor cleanup in the mint driver that was sitting on my laptop (sorry!).
Ryan C. Gordon <icculus@icculus.org>
parents: 2043
diff changeset
267
8d5d119b1640 Minor cleanup in the mint driver that was sitting on my laptop (sorry!).
Ryan C. Gordon <icculus@icculus.org>
parents: 2043
diff changeset
268 /* no float support... */
2005
45af7d69f8eb MiNT audio driver cleanups for clamping types and channels to supported
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
269
2044
8d5d119b1640 Minor cleanup in the mint driver that was sitting on my laptop (sorry!).
Ryan C. Gordon <icculus@icculus.org>
parents: 2043
diff changeset
270 default:
8d5d119b1640 Minor cleanup in the mint driver that was sitting on my laptop (sorry!).
Ryan C. Gordon <icculus@icculus.org>
parents: 2043
diff changeset
271 test_format = SDL_NextAudioFormat();
8d5d119b1640 Minor cleanup in the mint driver that was sitting on my laptop (sorry!).
Ryan C. Gordon <icculus@icculus.org>
parents: 2043
diff changeset
272 break;
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
273 }
2005
45af7d69f8eb MiNT audio driver cleanups for clamping types and channels to supported
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
274 }
45af7d69f8eb MiNT audio driver cleanups for clamping types and channels to supported
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
275
45af7d69f8eb MiNT audio driver cleanups for clamping types and channels to supported
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
276 if (!valid_datatype) {
45af7d69f8eb MiNT audio driver cleanups for clamping types and channels to supported
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
277 SDL_SetError("Unsupported audio format");
45af7d69f8eb MiNT audio driver cleanups for clamping types and channels to supported
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
278 return (-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
279 }
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
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 /* Check signed/unsigned 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
282 if (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
283 if (snd_format & SND_FORMATSIGNED) {
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
284 /* Ok */
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
285 } else if (snd_format & SND_FORMATUNSIGNED) {
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 /* Give unsigned format */
2005
45af7d69f8eb MiNT audio driver cleanups for clamping types and channels to supported
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
287 spec->format = spec->format & (~SDL_AUDIO_MASK_SIGNED);
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
288 }
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
289 } 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
290 if (snd_format & SND_FORMATUNSIGNED) {
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
291 /* Ok */
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
292 } else if (snd_format & SND_FORMATSIGNED) {
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
293 /* Give signed format */
2005
45af7d69f8eb MiNT audio driver cleanups for clamping types and channels to supported
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
294 spec->format |= SDL_AUDIO_MASK_SIGNED;
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
295 }
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
296 }
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
297
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
298 if (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
299 if (snd_format & SND_FORMATBIGENDIAN) {
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
300 /* Ok */
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
301 } else if (snd_format & SND_FORMATLITTLEENDIAN) {
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 /* Give little endian format */
2005
45af7d69f8eb MiNT audio driver cleanups for clamping types and channels to supported
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
303 spec->format = spec->format & (~SDL_AUDIO_MASK_ENDIAN);
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
304 }
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
305 } 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
306 if (snd_format & SND_FORMATLITTLEENDIAN) {
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
307 /* Ok */
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 } else if (snd_format & SND_FORMATBIGENDIAN) {
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
309 /* Give big endian format */
2005
45af7d69f8eb MiNT audio driver cleanups for clamping types and channels to supported
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
310 spec->format |= SDL_AUDIO_MASK_ENDIAN;
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
311 }
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
312 }
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
313
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
314 /* Calculate and select the closest 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
315 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
316 for (i = 1; i < 4; 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
317 SDL_MintAudio_AddFrequency(this,
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
318 MASTERCLOCK_44K / (MASTERPREDIV_MILAN *
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
319 (1 << 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
320 MASTERCLOCK_44K, (1 << i) - 1, -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
321 }
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
322
961
185acc07127a Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
323 #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
324 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
325 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
326 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
327 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
328 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
329 }
961
185acc07127a Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
330 #endif
185acc07127a Date: Fri, 29 Oct 2004 11:47:09 +0200
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
331
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
332 MINTAUDIO_numfreq = SDL_MintAudio_SearchFrequency(this, spec->freq);
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
333 spec->freq = MINTAUDIO_frequencies[MINTAUDIO_numfreq].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
334
2043
adf732f1f016 Formatting update
Sam Lantinga <slouken@libsdl.org>
parents: 2027
diff changeset
335 DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ",
adf732f1f016 Formatting update
Sam Lantinga <slouken@libsdl.org>
parents: 2027
diff changeset
336 SDL_AUDIO_BITSIZE(spec->format)));
2005
45af7d69f8eb MiNT audio driver cleanups for clamping types and channels to supported
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
337 DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(spec->format)));
45af7d69f8eb MiNT audio driver cleanups for clamping types and channels to supported
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
338 DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(spec->format)));
45af7d69f8eb MiNT audio driver cleanups for clamping types and channels to supported
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
339 DEBUG_PRINT(("big endian=%d, ", SDL_AUDIO_ISBIGENDIAN(spec->format)));
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
340 DEBUG_PRINT(("channels=%d, ", spec->channels));
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
341 DEBUG_PRINT(("freq=%d\n", spec->freq));
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
342
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
343 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
344 }
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
345
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
346 static void
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
347 Mint_InitAudio(_THIS, SDL_AudioSpec * spec)
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
348 {
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
349 int channels_mode, prediv;
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
350 void *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
351
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
352 /* Stop currently playing sound */
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
353 Buffoper(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
354
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
355 /* Set replay tracks */
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
356 Settracks(0, 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
357 Setmontracks(0);
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
358
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
359 /* Select replay format */
2005
45af7d69f8eb MiNT audio driver cleanups for clamping types and channels to supported
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
360 switch (SDL_AUDIO_BITSIZE(spec->format)) {
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
361 case 8:
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
362 if (spec->channels == 2) {
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
363 channels_mode = STEREO8;
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
364 } 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
365 channels_mode = MONO8;
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
366 }
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
367 break;
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
368 case 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
369 if (spec->channels == 2) {
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
370 channels_mode = STEREO16;
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
371 } 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
372 channels_mode = MONO16;
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
373 }
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
374 break;
2005
45af7d69f8eb MiNT audio driver cleanups for clamping types and channels to supported
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
375 case 32:
45af7d69f8eb MiNT audio driver cleanups for clamping types and channels to supported
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
376 if (spec->channels == 2) {
45af7d69f8eb MiNT audio driver cleanups for clamping types and channels to supported
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
377 channels_mode = STEREO32;
45af7d69f8eb MiNT audio driver cleanups for clamping types and channels to supported
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
378 } else {
45af7d69f8eb MiNT audio driver cleanups for clamping types and channels to supported
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
379 channels_mode = MONO32;
45af7d69f8eb MiNT audio driver cleanups for clamping types and channels to supported
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
380 }
45af7d69f8eb MiNT audio driver cleanups for clamping types and channels to supported
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
381 break;
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
382 default:
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
383 channels_mode = STEREO16;
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
384 break;
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
385 }
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
386 if (Setmode(channels_mode) < 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
387 DEBUG_PRINT((DEBUG_NAME "Setmode() failed\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
388 }
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
389
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
390 prediv = MINTAUDIO_frequencies[MINTAUDIO_numfreq].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
391 Devconnect(DMAPLAY, DAC, CLKEXT, prediv, 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
392
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
393 /* 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
394 buffer = SDL_MintAudio_audiobuf[SDL_MintAudio_numbuf];
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
395 if (Setbuffer(0, buffer, buffer + spec->size) < 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
396 DEBUG_PRINT((DEBUG_NAME "Setbuffer() failed\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
397 }
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
398
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
399 /* Install 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
400 if (NSetinterrupt(2, SI_PLAY, Mint_GsxbInterrupt) < 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
401 DEBUG_PRINT((DEBUG_NAME "NSetinterrupt() failed\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
402 }
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
403
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
404 /* Go */
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
405 Buffoper(SB_PLA_ENA | SB_PLA_RPT);
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
406 DEBUG_PRINT((DEBUG_NAME "hardware initialized\n"));
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
407 }
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
408
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
409 static int
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
410 Mint_OpenAudio(_THIS, SDL_AudioSpec * spec)
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
411 {
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
412 /* Lock sound system */
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
413 if (Locksnd() != 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
414 SDL_SetError("Mint_OpenAudio: Audio system already in use");
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
415 return (-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
416 }
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
417
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
418 SDL_MintAudio_device = this;
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
419
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
420 /* Check audio capabilities */
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
421 if (Mint_CheckAudio(this, spec) == -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
422 return -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
423 }
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
424
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
425 SDL_CalculateAudioSpec(spec);
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
426
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
427 /* Allocate memory for audio buffers in DMA-able RAM */
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
428 DEBUG_PRINT((DEBUG_NAME "buffer size=%d\n", spec->size));
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
429
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
430 SDL_MintAudio_audiobuf[0] = Atari_SysMalloc(spec->size * 2, MX_STRAM);
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
431 if (SDL_MintAudio_audiobuf[0] == NULL) {
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
432 SDL_SetError("MINT_OpenAudio: Not enough memory for audio 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
433 return (-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
434 }
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
435 SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + spec->size;
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
436 SDL_MintAudio_numbuf = 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
437 SDL_memset(SDL_MintAudio_audiobuf[0], spec->silence, spec->size * 2);
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
438 SDL_MintAudio_audiosize = spec->size;
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
439 SDL_MintAudio_mutex = 0;
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
440
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
441 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
442 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
443 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
444 SDL_MintAudio_audiobuf[1]));
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
445
2027
d48ead2d2ba5 Save/restore FPU registers in interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 2005
diff changeset
446 SDL_MintAudio_CheckFpu();
d48ead2d2ba5 Save/restore FPU registers in interrupt
Patrice Mandin <patmandin@gmail.com>
parents: 2005
diff changeset
447
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
448 /* Setup audio hardware */
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
449 Mint_InitAudio(this, spec);
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
450
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
451 return (1); /* We don't use threaded audio */
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
452 }
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
453
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
454 static void
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
455 Mint_GsxbInterrupt(void)
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
456 {
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
457 Uint8 *newbuf;
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
458
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
459 if (SDL_MintAudio_mutex)
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
460 return;
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
461
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
462 SDL_MintAudio_mutex = 1;
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
463
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
464 SDL_MintAudio_numbuf ^= 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
465 SDL_MintAudio_Callback();
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
466 newbuf = SDL_MintAudio_audiobuf[SDL_MintAudio_numbuf];
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
467 Setbuffer(0, newbuf, newbuf + SDL_MintAudio_audiosize);
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
468
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
469 SDL_MintAudio_mutex = 0;
644
594422ab8f9f Atari MiNT: added more audio drivers
Patrice Mandin <patmandin@gmail.com>
parents:
diff changeset
470 }
1097
c83fa1c650dd Move GSXB callback to C source
Patrice Mandin <patmandin@gmail.com>
parents: 962
diff changeset
471
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
472 static void
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
473 Mint_GsxbNullInterrupt(void)
1097
c83fa1c650dd Move GSXB callback to C source
Patrice Mandin <patmandin@gmail.com>
parents: 962
diff changeset
474 {
c83fa1c650dd Move GSXB callback to C source
Patrice Mandin <patmandin@gmail.com>
parents: 962
diff changeset
475 }
c83fa1c650dd Move GSXB callback to C source
Patrice Mandin <patmandin@gmail.com>
parents: 962
diff changeset
476
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
477 /* vi: set ts=4 sw=4 expandtab: */