Mercurial > sdl-ios-xcode
annotate src/audio/dmedia/SDL_irixaudio.c @ 4324:1496aa09e41e SDL-1.2
Steven Noonan to sdl
While trying to build the SDLMain.m included with SDL 1.2.14, with
#define SDL_USE_NIB_FILE 1:
/Users/steven/Development/darwinia/targets/macosx/Darwinia/SDLMain.m:
In function '-[SDLMain fixMenu:withAppName:]':
/Users/steven/Development/darwinia/targets/macosx/Darwinia/SDLMain.m:122:
warning: 'sizeToFit' is deprecated (declared at
/Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSMenu.h:281)
/Users/steven/Development/darwinia/targets/macosx/Darwinia/SDLMain.m:
In function 'main':
/Users/steven/Development/darwinia/targets/macosx/Darwinia/SDLMain.m:376:
warning: 'poseAsClass:' is deprecated (declared at
/Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:127)
/Users/steven/Development/darwinia/targets/macosx/Darwinia/SDLMain.m:376:
error: 'poseAsClass:' is unavailable (declared at
/Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:127)
/Users/steven/Development/darwinia/targets/macosx/Darwinia/SDLMain.m:377:
warning: passing argument 2 of 'NSApplicationMain' from incompatible
pointer type
Eric Wing to Sam
I don't have time today to look at this in detail, but the problem is definitely the poseAsClass: method.
This was deprecated in Obj-C 2.0 and not retained in 64-bit.
I've never used this method and it has always been limited to esoteric uses. I think this is why Apple wanted to dump it (among complicating some other things they do). I have read about others getting bit by this when migrating. Long story short, there really isn't a migration path for this method. The question that then must be asked is why are we using it (what does it accomplish), and then figure out the 'proper' way of accomplishing that.
Glancing at SDLMain.m, it's not obvious to me why it is there or what it is really accomplishing. My only speculation is that NSApplicationMain hardcodes something to look for NSApplication and a subclass (SDLApplication) fails for some reason (assuming that the original coder did this for good reason).
Three thoughts come to mind.
1) The Info.plist has properties to control things related to the startup class and nib.
NSPrincipalClass, NSMainNibFile
Maybe principle class needs to be SDLApplication and we can delete the poseAs
2) I was told that 10.6 introduced new APIs to make programatic NIB wrangling and avoidance easier. Unfortunately, I don't know the specifics.
3) Instead of subclassing NSApplication in SDLMain.m, maybe we can just add a category. It looks like the following is the only thing that is done (quick glance):
@interface SDLApplication : NSApplication
@end
@implementation SDLApplication
/* Invoked from the Quit menu item */
- (void)terminate:(id)sender
{
/* Post a SDL_QUIT event */
SDL_Event event;
event.type = SDL_QUIT;
SDL_PushEvent(&event);
}
@end
So instead, we change this to: (warning written in mail and untested)
@interface NSApplication (SDLApplication)
- (void) terminate:(id)sender;
@end
@implementation NSApplication (SDLApplication)
/* Invoked from the Quit menu item */
- (void)terminate:(id)sender
{
/* Post a SDL_QUIT event */
SDL_Event event;
event.type = SDL_QUIT;
SDL_PushEvent(&event);
}
@end
Then everywhere SDLApplication is used, we change it to NSApplication (and remove the poseAsClass line).
Perhaps you could ask the bug reporter to try this solution (#3).
And if that fails, maybe try #1.
-Eric
Steven Noonan to Sam
The suggested change (diff below) seems to work fine.
- Steven
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 12 Oct 2009 21:07:12 +0000 |
parents | a1b03ba2fcd0 |
children |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
4159 | 3 Copyright (C) 1997-2009 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 */ |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1361
diff
changeset
|
22 #include "SDL_config.h" |
0 | 23 |
24 /* 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
|
25 /* patch for IRIX 5 by Georg Schwarz 18/07/2004 */ |
0 | 26 |
27 #include "SDL_timer.h" | |
28 #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
|
29 #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
|
30 #include "../SDL_audio_c.h" |
0 | 31 #include "SDL_irixaudio.h" |
32 | |
33 | |
903
6e6248801043
Date: Sun, 18 Jul 2004 16:46:44 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
605
diff
changeset
|
34 #ifndef AL_RESOURCE /* as a test whether we use the old IRIX audio libraries */ |
6e6248801043
Date: Sun, 18 Jul 2004 16:46:44 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
605
diff
changeset
|
35 #define OLD_IRIX_AUDIO |
6e6248801043
Date: Sun, 18 Jul 2004 16:46:44 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
605
diff
changeset
|
36 #define alClosePort(x) ALcloseport(x) |
6e6248801043
Date: Sun, 18 Jul 2004 16:46:44 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
605
diff
changeset
|
37 #define alFreeConfig(x) ALfreeconfig(x) |
6e6248801043
Date: Sun, 18 Jul 2004 16:46:44 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
605
diff
changeset
|
38 #define alGetFillable(x) ALgetfillable(x) |
6e6248801043
Date: Sun, 18 Jul 2004 16:46:44 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
605
diff
changeset
|
39 #define alNewConfig() ALnewconfig() |
6e6248801043
Date: Sun, 18 Jul 2004 16:46:44 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
605
diff
changeset
|
40 #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
|
41 #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
|
42 #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
|
43 #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
|
44 #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
|
45 #endif |
6e6248801043
Date: Sun, 18 Jul 2004 16:46:44 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
605
diff
changeset
|
46 |
0 | 47 /* Audio driver functions */ |
48 static int AL_OpenAudio(_THIS, SDL_AudioSpec *spec); | |
49 static void AL_WaitAudio(_THIS); | |
50 static void AL_PlayAudio(_THIS); | |
51 static Uint8 *AL_GetAudioBuf(_THIS); | |
52 static void AL_CloseAudio(_THIS); | |
53 | |
54 /* Audio driver bootstrap functions */ | |
55 | |
56 static int Audio_Available(void) | |
57 { | |
58 return 1; | |
59 } | |
60 | |
61 static void Audio_DeleteDevice(SDL_AudioDevice *device) | |
62 { | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
63 SDL_free(device->hidden); |
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
64 SDL_free(device); |
0 | 65 } |
66 | |
67 static SDL_AudioDevice *Audio_CreateDevice(int devindex) | |
68 { | |
69 SDL_AudioDevice *this; | |
70 | |
71 /* Initialize all variables that we clean on shutdown */ | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
72 this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice)); |
0 | 73 if ( this ) { |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
74 SDL_memset(this, 0, (sizeof *this)); |
0 | 75 this->hidden = (struct SDL_PrivateAudioData *) |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
76 SDL_malloc((sizeof *this->hidden)); |
0 | 77 } |
78 if ( (this == NULL) || (this->hidden == NULL) ) { | |
79 SDL_OutOfMemory(); | |
80 if ( this ) { | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
81 SDL_free(this); |
0 | 82 } |
83 return(0); | |
84 } | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
85 SDL_memset(this->hidden, 0, (sizeof *this->hidden)); |
0 | 86 |
87 /* Set the function pointers */ | |
88 this->OpenAudio = AL_OpenAudio; | |
89 this->WaitAudio = AL_WaitAudio; | |
90 this->PlayAudio = AL_PlayAudio; | |
91 this->GetAudioBuf = AL_GetAudioBuf; | |
92 this->CloseAudio = AL_CloseAudio; | |
93 | |
94 this->free = Audio_DeleteDevice; | |
95 | |
96 return this; | |
97 } | |
98 | |
148
8758b8d42cd9
Audio subsystem no longer assumes sun audio API on UNIX systems
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
99 AudioBootStrap DMEDIA_bootstrap = { |
0 | 100 "AL", "IRIX DMedia audio", |
101 Audio_Available, Audio_CreateDevice | |
102 }; | |
103 | |
104 | |
105 void static AL_WaitAudio(_THIS) | |
106 { | |
107 Sint32 timeleft; | |
108 | |
109 timeleft = this->spec.samples - alGetFillable(audio_port); | |
110 if ( timeleft > 0 ) { | |
111 timeleft /= (this->spec.freq/1000); | |
112 SDL_Delay((Uint32)timeleft); | |
113 } | |
114 } | |
115 | |
116 static void AL_PlayAudio(_THIS) | |
117 { | |
118 /* Write the audio data out */ | |
119 if ( alWriteFrames(audio_port, mixbuf, this->spec.samples) < 0 ) { | |
120 /* Assume fatal error, for now */ | |
121 this->enabled = 0; | |
122 } | |
123 } | |
124 | |
125 static Uint8 *AL_GetAudioBuf(_THIS) | |
126 { | |
127 return(mixbuf); | |
128 } | |
129 | |
130 static void AL_CloseAudio(_THIS) | |
131 { | |
132 if ( mixbuf != NULL ) { | |
133 SDL_FreeAudioMem(mixbuf); | |
134 mixbuf = NULL; | |
135 } | |
136 if ( audio_port != NULL ) { | |
605
6399f4e90211
IRIX patches from Andrea Suatoni
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
137 alClosePort(audio_port); |
0 | 138 audio_port = NULL; |
139 } | |
140 } | |
141 | |
3851
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
142 static int AL_OpenAudio(_THIS, SDL_AudioSpec * spec) |
0 | 143 { |
3852
5b5e549382b3
Removed some new 1.3 symbols from code backported to 1.2.
Ryan C. Gordon <icculus@icculus.org>
parents:
3851
diff
changeset
|
144 Uint16 test_format = SDL_FirstAudioFormat(spec->format); |
3851
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
145 long width = 0; |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
146 long fmt = 0; |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
147 int valid = 0; |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
148 |
903
6e6248801043
Date: Sun, 18 Jul 2004 16:46:44 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
605
diff
changeset
|
149 #ifdef OLD_IRIX_AUDIO |
3851
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
150 { |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
151 long audio_param[2]; |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
152 audio_param[0] = AL_OUTPUT_RATE; |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
153 audio_param[1] = spec->freq; |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
154 valid = (ALsetparams(AL_DEFAULT_DEVICE, audio_param, 2) < 0); |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
155 } |
903
6e6248801043
Date: Sun, 18 Jul 2004 16:46:44 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
605
diff
changeset
|
156 #else |
3851
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
157 { |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
158 ALpv audio_param; |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
159 audio_param.param = AL_RATE; |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
160 audio_param.value.i = spec->freq; |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
161 valid = (alSetParams(AL_DEFAULT_OUTPUT, &audio_param, 1) < 0); |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
162 } |
903
6e6248801043
Date: Sun, 18 Jul 2004 16:46:44 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
605
diff
changeset
|
163 #endif |
3851
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
164 |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
165 while ((!valid) && (test_format)) { |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
166 valid = 1; |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
167 spec->format = test_format; |
0 | 168 |
3851
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
169 switch (test_format) { |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
170 case AUDIO_S8: |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
171 width = AL_SAMPLE_8; |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
172 fmt = AL_SAMPFMT_TWOSCOMP; |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
173 break; |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
174 |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
175 case AUDIO_S16SYS: |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
176 width = AL_SAMPLE_16; |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
177 fmt = AL_SAMPFMT_TWOSCOMP; |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
178 break; |
0 | 179 |
3851
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
180 default: |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
181 valid = 0; |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
182 test_format = SDL_NextAudioFormat(); |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
183 break; |
0 | 184 } |
3851
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
185 |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
186 if (valid) { |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
187 ALconfig audio_config = alNewConfig(); |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
188 valid = 0; |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
189 if (audio_config) { |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
190 if (alSetChannels(audio_config, spec->channels) < 0) { |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
191 if (spec->channels > 2) { /* can't handle > stereo? */ |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
192 spec->channels = 2; /* try again below. */ |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
193 } |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
194 } |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
195 |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
196 if ((alSetSampFmt(audio_config, fmt) >= 0) && |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
197 ((!width) || (alSetWidth(audio_config, width) >= 0)) && |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
198 (alSetQueueSize(audio_config, spec->samples * 2) >= 0) && |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
199 (alSetChannels(audio_config, spec->channels) >= 0)) { |
0 | 200 |
3851
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
201 audio_port = alOpenPort("SDL audio", "w", audio_config); |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
202 if (audio_port == NULL) { |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
203 /* docs say AL_BAD_CHANNELS happens here, too. */ |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
204 int err = oserror(); |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
205 if (err == AL_BAD_CHANNELS) { |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
206 spec->channels = 2; |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
207 alSetChannels(audio_config, spec->channels); |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
208 audio_port = alOpenPort("SDL audio", "w", |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
209 audio_config); |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
210 } |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
211 } |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
212 |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
213 if (audio_port != NULL) { |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
214 valid = 1; |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
215 } |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
216 } |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
217 |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
218 alFreeConfig(audio_config); |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
219 } |
0 | 220 } |
3851
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
221 } |
0 | 222 |
3851
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
223 if (!valid) { |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
224 SDL_SetError("Unsupported audio format"); |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
225 return (-1); |
0 | 226 } |
227 | |
228 /* Update the fragment size as size in bytes */ | |
229 SDL_CalculateAudioSpec(spec); | |
230 | |
231 /* Allocate mixing buffer */ | |
3851
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
232 mixbuf = (Uint8 *) SDL_AllocAudioMem(spec->size); |
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
233 if (mixbuf == NULL) { |
0 | 234 SDL_OutOfMemory(); |
3851
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
235 return (-1); |
0 | 236 } |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
237 SDL_memset(mixbuf, spec->silence, spec->size); |
0 | 238 |
239 /* We're ready to rock and roll. :-) */ | |
3851
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
240 return (0); |
0 | 241 } |
3851
405a192b68e7
Backport from 1.3: most of the audio drivers can now handle data
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
242 |