Mercurial > sdl-ios-xcode
annotate src/audio/dmedia/SDL_irixaudio.c @ 4724:d86332c0fb9b
Working on the sound system
author | Paul Hunkin <paul@bieh.net> |
---|---|
date | Sat, 14 Aug 2010 12:35:21 +1200 |
parents | 4160ba33b597 |
children | b530ef003506 |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
3697 | 3 Copyright (C) 1997-2010 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 |
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
|
48 void static |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
49 IRIXAUDIO_WaitDevice(_THIS) |
0 | 50 { |
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
|
51 Sint32 timeleft; |
0 | 52 |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
53 timeleft = this->spec.samples - alGetFillable(this->hidden->audio_port); |
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
|
54 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
|
55 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
|
56 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
|
57 } |
0 | 58 } |
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 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
|
61 IRIXAUDIO_PlayDevice(_THIS) |
0 | 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 /* Write the audio data out */ |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
64 ALport port = this->hidden->audio_port; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
65 Uint8 *mixbuf = this->hidden->mixbuf; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
66 if (alWriteFrames(port, mixbuf, this->spec.samples) < 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:
1402
diff
changeset
|
67 /* 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
|
68 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
|
69 } |
0 | 70 } |
71 | |
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
|
72 static Uint8 * |
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 IRIXAUDIO_GetDeviceBuf(_THIS) |
0 | 74 { |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
75 return (this->hidden->mixbuf); |
0 | 76 } |
77 | |
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
|
78 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
|
79 IRIXAUDIO_CloseDevice(_THIS) |
0 | 80 { |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
81 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
|
82 if (this->hidden->mixbuf != NULL) { |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
83 SDL_FreeAudioMem(this->hidden->mixbuf); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
84 this->hidden->mixbuf = NULL; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
85 } |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
86 if (this->hidden->audio_port != NULL) { |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
87 alClosePort(this->hidden->audio_port); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
88 this->hidden->audio_port = NULL; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
89 } |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
90 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
|
91 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:
1402
diff
changeset
|
92 } |
0 | 93 } |
94 | |
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
|
95 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
|
96 IRIXAUDIO_OpenDevice(_THIS, const char *devname, int iscapture) |
0 | 97 { |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
98 SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format); |
2002
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
99 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
|
100 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
|
101 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
|
102 |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
103 /* !!! FIXME: Handle multiple devices and capture? */ |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
104 |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
105 /* 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
|
106 this->hidden = (struct SDL_PrivateAudioData *) |
2060 | 107 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
|
108 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
|
109 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
|
110 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
|
111 } |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
112 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
|
113 |
903
6e6248801043
Date: Sun, 18 Jul 2004 16:46:44 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
605
diff
changeset
|
114 #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
|
115 { |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
116 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
|
117 audio_param[0] = AL_OUTPUT_RATE; |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
118 audio_param[1] = this->spec.freq; |
2002
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
119 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
|
120 } |
903
6e6248801043
Date: Sun, 18 Jul 2004 16:46:44 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
605
diff
changeset
|
121 #else |
2002
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
122 { |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
123 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
|
124 audio_param.param = AL_RATE; |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
125 audio_param.value.i = this->spec.freq; |
2002
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
126 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
|
127 } |
903
6e6248801043
Date: Sun, 18 Jul 2004 16:46:44 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
605
diff
changeset
|
128 #endif |
2002
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
129 |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
130 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
|
131 valid = 1; |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
132 this->spec.format = test_format; |
2002
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
133 |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
134 switch (test_format) { |
2043 | 135 case AUDIO_S8: |
136 width = AL_SAMPLE_8; | |
137 fmt = AL_SAMPFMT_TWOSCOMP; | |
138 break; | |
0 | 139 |
2043 | 140 case AUDIO_S16SYS: |
141 width = AL_SAMPLE_16; | |
142 fmt = AL_SAMPFMT_TWOSCOMP; | |
143 break; | |
2002
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
144 |
2043 | 145 case AUDIO_F32SYS: |
146 width = 0; /* not used here... */ | |
147 fmt = AL_SAMPFMT_FLOAT; | |
148 break; | |
2002
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
149 |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
150 /* Docs say there is int24, but not int32.... */ |
0 | 151 |
2043 | 152 default: |
153 valid = 0; | |
154 test_format = SDL_NextAudioFormat(); | |
155 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
|
156 } |
2002
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
157 |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
158 if (valid) { |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
159 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
|
160 valid = 0; |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
161 if (audio_config) { |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
162 if (alSetChannels(audio_config, this->spec.channels) < 0) { |
2060 | 163 if (this->spec.channels > 2) { /* can't handle > stereo? */ |
164 this->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
|
165 } |
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 |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
168 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
|
169 ((!width) || (alSetWidth(audio_config, width) >= 0)) && |
2060 | 170 (alSetQueueSize(audio_config, this->spec.samples * 2) >= |
171 0) | |
172 && (alSetChannels(audio_config, this->spec.channels) >= | |
173 0)) { | |
0 | 174 |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
175 this->hidden->audio_port = alOpenPort("SDL audio", "w", |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
176 audio_config); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
177 if (this->hidden->audio_port == NULL) { |
2002
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
178 /* 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
|
179 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
|
180 if (err == AL_BAD_CHANNELS) { |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
181 this->spec.channels = 2; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
182 alSetChannels(audio_config, this->spec.channels); |
2060 | 183 this->hidden->audio_port = |
184 alOpenPort("SDL audio", "w", audio_config); | |
2002
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
185 } |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
186 } |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
187 |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
188 if (this->hidden->audio_port != NULL) { |
2002
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
189 valid = 1; |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
190 } |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
191 } |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
192 |
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
193 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
|
194 } |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
195 } |
2002
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
196 } |
0 | 197 |
2002
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
198 if (!valid) { |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
199 IRIXAUDIO_CloseDevice(this); |
2002
7590aaf89a60
Cleaned up IRIX audio driver, added float32 support and fallbacks when
Ryan C. Gordon <icculus@icculus.org>
parents:
1895
diff
changeset
|
200 SDL_SetError("Unsupported audio 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
|
201 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:
1402
diff
changeset
|
202 } |
0 | 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:
1402
diff
changeset
|
204 /* Update the fragment size as size in bytes */ |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
205 SDL_CalculateAudioSpec(&this->spec); |
0 | 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:
1402
diff
changeset
|
207 /* Allocate mixing 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
|
208 this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->spec.size); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
209 if (this->hidden->mixbuf == NULL) { |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
210 IRIXAUDIO_CloseDevice(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:
1402
diff
changeset
|
211 SDL_OutOfMemory(); |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
212 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:
1402
diff
changeset
|
213 } |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
214 SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size); |
0 | 215 |
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
|
216 /* We're ready to rock and roll. :-) */ |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
217 return 1; |
0 | 218 } |
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
|
219 |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
220 static int |
2060 | 221 IRIXAUDIO_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
|
222 { |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
223 /* 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
|
224 impl->OpenDevice = DSP_OpenDevice; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
225 impl->PlayDevice = DSP_PlayDevice; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
226 impl->WaitDevice = DSP_WaitDevice; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
227 impl->GetDeviceBuf = DSP_GetDeviceBuf; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
228 impl->CloseDevice = DSP_CloseDevice; |
2060 | 229 impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME: not true, I think. */ |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
230 |
3699
4160ba33b597
Removed test for "driver is valid, but doesn't see any audio devices."
Ryan C. Gordon <icculus@icculus.org>
parents:
3697
diff
changeset
|
231 return 1; /* this audio target is available. */ |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
232 } |
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 AudioBootStrap IRIXAUDIO_bootstrap = { |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
235 "AL", "IRIX DMedia audio", IRIXAUDIO_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
|
236 }; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
2043
diff
changeset
|
237 |
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
|
238 /* vi: set ts=4 sw=4 expandtab: */ |