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