Mercurial > sdl-ios-xcode
annotate src/audio/dmedia/SDL_irixaudio.c @ 3787:8d74a4721ca9 SDL-ryan-multiple-audio-device
Added deinitialize hook.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Tue, 03 Oct 2006 16:26:42 +0000 |
parents | adf732f1f016 |
children | 5f6550e5184f c8b3d3d13ed1 |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
903
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
903
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
0 | 7 License as published by the Free Software Foundation; either |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
903
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
0 | 9 |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
903
diff
changeset
|
13 Lesser General Public License for more details. |
0 | 14 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
903
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
903
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
903
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
0 | 18 |
19 Sam Lantinga | |
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
148
diff
changeset
|
20 slouken@libsdl.org |
0 | 21 */ |
2002
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
22 #include <errno.h> |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1361
diff
changeset
|
23 #include "SDL_config.h" |
0 | 24 |
25 /* Allow access to a raw mixing buffer (For IRIX 6.5 and higher) */ | |
903
6e6248801043
Date: Sun, 18 Jul 2004 16:46:44 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
605
diff
changeset
|
26 /* patch for IRIX 5 by Georg Schwarz 18/07/2004 */ |
0 | 27 |
28 #include "SDL_timer.h" | |
29 #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
|
30 #include "../SDL_audiomem.h" |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
31 #include "../SDL_audio_c.h" |
0 | 32 #include "SDL_irixaudio.h" |
33 | |
34 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
35 #ifndef AL_RESOURCE /* as a test whether we use the old IRIX audio libraries */ |
903
6e6248801043
Date: Sun, 18 Jul 2004 16:46:44 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
605
diff
changeset
|
36 #define OLD_IRIX_AUDIO |
6e6248801043
Date: Sun, 18 Jul 2004 16:46:44 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
605
diff
changeset
|
37 #define alClosePort(x) ALcloseport(x) |
6e6248801043
Date: Sun, 18 Jul 2004 16:46:44 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
605
diff
changeset
|
38 #define alFreeConfig(x) ALfreeconfig(x) |
6e6248801043
Date: Sun, 18 Jul 2004 16:46:44 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
605
diff
changeset
|
39 #define alGetFillable(x) ALgetfillable(x) |
6e6248801043
Date: Sun, 18 Jul 2004 16:46:44 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
605
diff
changeset
|
40 #define alNewConfig() ALnewconfig() |
6e6248801043
Date: Sun, 18 Jul 2004 16:46:44 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
605
diff
changeset
|
41 #define alOpenPort(x,y,z) ALopenport(x,y,z) |
6e6248801043
Date: Sun, 18 Jul 2004 16:46:44 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
605
diff
changeset
|
42 #define alSetChannels(x,y) ALsetchannels(x,y) |
6e6248801043
Date: Sun, 18 Jul 2004 16:46:44 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
605
diff
changeset
|
43 #define alSetQueueSize(x,y) ALsetqueuesize(x,y) |
6e6248801043
Date: Sun, 18 Jul 2004 16:46:44 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
605
diff
changeset
|
44 #define alSetSampFmt(x,y) ALsetsampfmt(x,y) |
6e6248801043
Date: Sun, 18 Jul 2004 16:46:44 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
605
diff
changeset
|
45 #define alSetWidth(x,y) ALsetwidth(x,y) |
6e6248801043
Date: Sun, 18 Jul 2004 16:46:44 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
605
diff
changeset
|
46 #endif |
6e6248801043
Date: Sun, 18 Jul 2004 16:46:44 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
605
diff
changeset
|
47 |
0 | 48 /* Audio driver functions */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
49 static int AL_OpenAudio(_THIS, SDL_AudioSpec * spec); |
0 | 50 static void AL_WaitAudio(_THIS); |
51 static void AL_PlayAudio(_THIS); | |
52 static Uint8 *AL_GetAudioBuf(_THIS); | |
53 static void AL_CloseAudio(_THIS); | |
54 | |
55 /* Audio driver bootstrap functions */ | |
56 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
57 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:
1402
diff
changeset
|
58 Audio_Available(void) |
0 | 59 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
60 return 1; |
0 | 61 } |
62 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
63 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:
1402
diff
changeset
|
64 Audio_DeleteDevice(SDL_AudioDevice * device) |
0 | 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:
1402
diff
changeset
|
66 SDL_free(device->hidden); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
67 SDL_free(device); |
0 | 68 } |
69 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
70 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:
1402
diff
changeset
|
71 Audio_CreateDevice(int devindex) |
0 | 72 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
73 SDL_AudioDevice *this; |
0 | 74 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
75 /* 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:
1402
diff
changeset
|
76 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:
1402
diff
changeset
|
77 if (this) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
78 SDL_memset(this, 0, (sizeof *this)); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
79 this->hidden = (struct SDL_PrivateAudioData *) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
80 SDL_malloc((sizeof *this->hidden)); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
81 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
82 if ((this == NULL) || (this->hidden == NULL)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
83 SDL_OutOfMemory(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
84 if (this) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
85 SDL_free(this); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
86 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
87 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:
1402
diff
changeset
|
88 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
89 SDL_memset(this->hidden, 0, (sizeof *this->hidden)); |
0 | 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:
1402
diff
changeset
|
91 /* Set the function pointers */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
92 this->OpenAudio = AL_OpenAudio; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
93 this->WaitAudio = AL_WaitAudio; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
94 this->PlayAudio = AL_PlayAudio; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
95 this->GetAudioBuf = AL_GetAudioBuf; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
96 this->CloseAudio = AL_CloseAudio; |
0 | 97 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
98 this->free = Audio_DeleteDevice; |
0 | 99 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
100 return this; |
0 | 101 } |
102 | |
148
8758b8d42cd9
Audio subsystem no longer assumes sun audio API on UNIX systems
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
103 AudioBootStrap DMEDIA_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:
1402
diff
changeset
|
104 "AL", "IRIX DMedia audio", |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
105 Audio_Available, Audio_CreateDevice |
0 | 106 }; |
107 | |
108 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
109 void static |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
110 AL_WaitAudio(_THIS) |
0 | 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:
1402
diff
changeset
|
112 Sint32 timeleft; |
0 | 113 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
114 timeleft = this->spec.samples - alGetFillable(audio_port); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
115 if (timeleft > 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
116 timeleft /= (this->spec.freq / 1000); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
117 SDL_Delay((Uint32) timeleft); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
118 } |
0 | 119 } |
120 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
121 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:
1402
diff
changeset
|
122 AL_PlayAudio(_THIS) |
0 | 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:
1402
diff
changeset
|
124 /* Write the audio data out */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
125 if (alWriteFrames(audio_port, mixbuf, this->spec.samples) < 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
126 /* Assume fatal error, for now */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
127 this->enabled = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
128 } |
0 | 129 } |
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:
1402
diff
changeset
|
131 static Uint8 * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
132 AL_GetAudioBuf(_THIS) |
0 | 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:
1402
diff
changeset
|
134 return (mixbuf); |
0 | 135 } |
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:
1402
diff
changeset
|
137 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:
1402
diff
changeset
|
138 AL_CloseAudio(_THIS) |
0 | 139 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
140 if (mixbuf != NULL) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
141 SDL_FreeAudioMem(mixbuf); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
142 mixbuf = NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
143 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
144 if (audio_port != NULL) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
145 alClosePort(audio_port); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
146 audio_port = NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
147 } |
0 | 148 } |
149 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
150 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:
1402
diff
changeset
|
151 AL_OpenAudio(_THIS, SDL_AudioSpec * spec) |
0 | 152 { |
2002
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
153 SDL_AudioFormat test_format = SDL_FirstAudioFormat(spec->format); |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
154 long width = 0; |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
155 long fmt = 0; |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
156 int valid = 0; |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
157 |
903
6e6248801043
Date: Sun, 18 Jul 2004 16:46:44 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
605
diff
changeset
|
158 #ifdef OLD_IRIX_AUDIO |
2002
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
159 { |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
160 long audio_param[2]; |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
161 audio_param[0] = AL_OUTPUT_RATE; |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
162 audio_param[1] = spec->freq; |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
163 valid = (ALsetparams(AL_DEFAULT_DEVICE, audio_param, 2) < 0); |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
164 } |
903
6e6248801043
Date: Sun, 18 Jul 2004 16:46:44 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
605
diff
changeset
|
165 #else |
2002
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
166 { |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
167 ALpv audio_param; |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
168 audio_param.param = AL_RATE; |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
169 audio_param.value.i = spec->freq; |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
170 valid = (alSetParams(AL_DEFAULT_OUTPUT, &audio_param, 1) < 0); |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
171 } |
903
6e6248801043
Date: Sun, 18 Jul 2004 16:46:44 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
605
diff
changeset
|
172 #endif |
2002
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
173 |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
174 while ((!valid) && (test_format)) { |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
175 valid = 1; |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
176 spec->format = test_format; |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
177 |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
178 switch (test_format) { |
2043 | 179 case AUDIO_S8: |
180 width = AL_SAMPLE_8; | |
181 fmt = AL_SAMPFMT_TWOSCOMP; | |
182 break; | |
0 | 183 |
2043 | 184 case AUDIO_S16SYS: |
185 width = AL_SAMPLE_16; | |
186 fmt = AL_SAMPFMT_TWOSCOMP; | |
187 break; | |
2002
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
188 |
2043 | 189 case AUDIO_F32SYS: |
190 width = 0; /* not used here... */ | |
191 fmt = AL_SAMPFMT_FLOAT; | |
192 break; | |
2002
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
193 |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
194 /* Docs say there is int24, but not int32.... */ |
0 | 195 |
2043 | 196 default: |
197 valid = 0; | |
198 test_format = SDL_NextAudioFormat(); | |
199 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:
1402
diff
changeset
|
200 } |
2002
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
201 |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
202 if (valid) { |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
203 ALconfig audio_config = alNewConfig(); |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
204 valid = 0; |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
205 if (audio_config) { |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
206 if (alSetChannels(audio_config, spec->channels) < 0) { |
2043 | 207 if (spec->channels > 2) { /* can't handle > stereo? */ |
208 spec->channels = 2; /* try again below. */ | |
2002
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
209 } |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
210 } |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
211 |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
212 if ((alSetSampFmt(audio_config, fmt) >= 0) && |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
213 ((!width) || (alSetWidth(audio_config, width) >= 0)) && |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
214 (alSetQueueSize(audio_config, spec->samples * 2) >= 0) && |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
215 (alSetChannels(audio_config, spec->channels) >= 0)) { |
0 | 216 |
2002
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
217 audio_port = alOpenPort("SDL audio", "w", audio_config); |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
218 if (audio_port == NULL) { |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
219 /* docs say AL_BAD_CHANNELS happens here, too. */ |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
220 int err = oserror(); |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
221 if (err == AL_BAD_CHANNELS) { |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
222 spec->channels = 2; |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
223 alSetChannels(audio_config, spec->channels); |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
224 audio_port = alOpenPort("SDL audio", "w", |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
225 audio_config); |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
226 } |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
227 } |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
228 |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
229 if (audio_port != NULL) { |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
230 valid = 1; |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
231 } |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
232 } |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
233 |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
234 alFreeConfig(audio_config); |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
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:
1402
diff
changeset
|
236 } |
2002
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
237 } |
0 | 238 |
2002
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
239 if (!valid) { |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
240 SDL_SetError("Unsupported audio format"); |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
241 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:
1402
diff
changeset
|
242 } |
0 | 243 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
244 /* Update the fragment size as size in bytes */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
245 SDL_CalculateAudioSpec(spec); |
0 | 246 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
247 /* Allocate mixing buffer */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
248 mixbuf = (Uint8 *) SDL_AllocAudioMem(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:
1402
diff
changeset
|
249 if (mixbuf == NULL) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
250 SDL_OutOfMemory(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
251 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:
1402
diff
changeset
|
252 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
253 SDL_memset(mixbuf, spec->silence, spec->size); |
0 | 254 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
255 /* We're ready to rock and roll. :-) */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
256 return (0); |
0 | 257 } |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
258 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
259 /* vi: set ts=4 sw=4 expandtab: */ |