Mercurial > sdl-ios-xcode
annotate src/audio/mme/SDL_mmeaudio.c @ 1361:19418e4422cb
New configure-based build system. Still work in progress, but much improved
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 16 Feb 2006 10:11:48 +0000 |
parents | c71e05b4dc2e |
children | d910939febfa |
rev | line source |
---|---|
654
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
769
b8d311d90021
Updated copyright information for 2004 (Happy New Year!)
Sam Lantinga <slouken@libsdl.org>
parents:
755
diff
changeset
|
3 Copyright (C) 1997-2004 Sam Lantinga |
654
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Library General Public |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 version 2 of the License, or (at your option) any later version. |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 Library General Public License for more details. |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Library General Public |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 Sam Lantinga |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 */ |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 /* Tru64 UNIX MME support */ |
1342
d73be99e9420
Fixed it Hayashi Naoyuki's way. :)
Sam Lantinga <slouken@libsdl.org>
parents:
1338
diff
changeset
|
24 #include <mme_api.h> |
d73be99e9420
Fixed it Hayashi Naoyuki's way. :)
Sam Lantinga <slouken@libsdl.org>
parents:
1338
diff
changeset
|
25 |
1358
c71e05b4dc2e
More header massaging... works great on Windows. ;-)
Sam Lantinga <slouken@libsdl.org>
parents:
1342
diff
changeset
|
26 #include "SDL_timer.h" |
1342
d73be99e9420
Fixed it Hayashi Naoyuki's way. :)
Sam Lantinga <slouken@libsdl.org>
parents:
1338
diff
changeset
|
27 #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
|
28 #include "../SDL_audio_c.h" |
654
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 #include "SDL_mmeaudio.h" |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 static BOOL inUse[NUM_BUFFERS]; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
33 /* Audio driver functions */ |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 static int MME_OpenAudio(_THIS, SDL_AudioSpec *spec); |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
35 static void MME_WaitAudio(_THIS); |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 static Uint8 *MME_GetAudioBuf(_THIS); |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
37 static void MME_PlayAudio(_THIS); |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
38 static void MME_WaitDone(_THIS); |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
39 static void MME_CloseAudio(_THIS); |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
41 /* Audio driver bootstrap functions */ |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
42 static int Audio_Available(void) |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
43 { |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
44 return(1); |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
45 } |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
46 |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 static void Audio_DeleteDevice(SDL_AudioDevice *device) |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 { |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 if ( device ) { |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 if ( device->hidden ) { |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
51 SDL_free(device->hidden); |
654
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
52 device->hidden = NULL; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 } |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
54 SDL_free(device); |
654
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
55 device = NULL; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
56 } |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
57 } |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
58 |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
59 static SDL_AudioDevice *Audio_CreateDevice(int devindex) |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
60 { |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
61 SDL_AudioDevice *this; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
62 |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
63 /* Initialize all variables that we clean on shutdown */ |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
64 this = SDL_malloc(sizeof(SDL_AudioDevice)); |
654
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
65 if ( this ) { |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
66 SDL_memset(this, 0, (sizeof *this)); |
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
67 this->hidden = SDL_malloc((sizeof *this->hidden)); |
654
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
68 } |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
69 if ( (this == NULL) || (this->hidden == NULL) ) { |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
70 SDL_OutOfMemory(); |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
71 if ( this ) { |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
72 SDL_free(this); |
654
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
73 } |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
74 return(0); |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
75 } |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
76 SDL_memset(this->hidden, 0, (sizeof *this->hidden)); |
654
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
77 /* Set the function pointers */ |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
78 this->OpenAudio = MME_OpenAudio; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
79 this->WaitAudio = MME_WaitAudio; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
80 this->PlayAudio = MME_PlayAudio; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
81 this->GetAudioBuf = MME_GetAudioBuf; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
82 this->WaitDone = MME_WaitDone; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
83 this->CloseAudio = MME_CloseAudio; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
84 this->free = Audio_DeleteDevice; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
85 |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
86 return this; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
87 } |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
88 |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
89 AudioBootStrap MMEAUDIO_bootstrap = { |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
90 "waveout", "Tru64 MME WaveOut", |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
91 Audio_Available, Audio_CreateDevice |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
92 }; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
93 |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
94 static void SetMMerror(char *function, MMRESULT code) |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
95 { |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
96 int len; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
97 char errbuf[MAXERRORLENGTH]; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 |
1338
604d73db6802
Removed uses of stdlib.h and string.h
Sam Lantinga <slouken@libsdl.org>
parents:
1336
diff
changeset
|
99 SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: ", function); |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
100 len = SDL_strlen(errbuf); |
654
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
101 waveOutGetErrorText(code, errbuf+len, MAXERRORLENGTH-len); |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
102 SDL_SetError("%s",errbuf); |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
103 } |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
104 |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
105 static void CALLBACK MME_CALLBACK(HWAVEOUT hwo, |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
106 UINT uMsg, |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
107 DWORD dwInstance, |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
108 LPARAM dwParam1, |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
109 LPARAM dwParam2) |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
110 { |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
111 WAVEHDR *wp = (WAVEHDR *) dwParam1; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
112 |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
113 if ( uMsg == WOM_DONE ) |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
114 inUse[wp->dwUser] = FALSE; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
115 } |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
116 |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
117 static int MME_OpenAudio(_THIS, SDL_AudioSpec *spec) |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
118 { |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
119 MMRESULT result; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
120 int i; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
121 |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
122 mixbuf = NULL; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
123 |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
124 /* Set basic WAVE format parameters */ |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
125 shm = mmeAllocMem(sizeof(*shm)); |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
126 if ( shm == NULL ) { |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
127 SDL_SetError("Out of memory: shm"); |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
128 return(-1); |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
129 } |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
130 shm->sound = 0; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
131 shm->wFmt.wf.wFormatTag = WAVE_FORMAT_PCM; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
132 |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
133 /* Determine the audio parameters from the AudioSpec */ |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
134 switch ( spec->format & 0xFF ) { |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
135 case 8: |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
136 /* Unsigned 8 bit audio data */ |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
137 spec->format = AUDIO_U8; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
138 shm->wFmt.wBitsPerSample = 8; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
139 break; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
140 case 16: |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
141 /* Signed 16 bit audio data */ |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
142 spec->format = AUDIO_S16; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
143 shm->wFmt.wBitsPerSample = 16; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
144 break; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
145 default: |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
146 SDL_SetError("Unsupported audio format"); |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
147 return(-1); |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
148 } |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
149 |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
150 shm->wFmt.wf.nChannels = spec->channels; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
151 shm->wFmt.wf.nSamplesPerSec = spec->freq; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
152 shm->wFmt.wf.nBlockAlign = |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
153 shm->wFmt.wf.nChannels * shm->wFmt.wBitsPerSample / 8; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
154 shm->wFmt.wf.nAvgBytesPerSec = |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
155 shm->wFmt.wf.nSamplesPerSec * shm->wFmt.wf.nBlockAlign; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
156 |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
157 /* Check the buffer size -- minimum of 1/4 second (word aligned) */ |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
158 if ( spec->samples < (spec->freq/4) ) |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
159 spec->samples = ((spec->freq/4)+3)&~3; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
160 |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
161 /* Update the fragment size as size in bytes */ |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
162 SDL_CalculateAudioSpec(spec); |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
163 |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
164 /* Open the audio device */ |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
165 result = waveOutOpen(&(shm->sound), |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
166 WAVE_MAPPER, |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
167 &(shm->wFmt.wf), |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
168 MME_CALLBACK, |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
169 NULL, |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
170 (CALLBACK_FUNCTION|WAVE_OPEN_SHAREABLE)); |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
171 if ( result != MMSYSERR_NOERROR ) { |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
172 SetMMerror("waveOutOpen()", result); |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
173 return(-1); |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
174 } |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
175 |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
176 /* Create the sound buffers */ |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
177 mixbuf = (Uint8 *)mmeAllocBuffer(NUM_BUFFERS * (spec->size)); |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
178 if ( mixbuf == NULL ) { |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
179 SDL_SetError("Out of memory: mixbuf"); |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
180 return(-1); |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
181 } |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
182 |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
183 for (i = 0; i < NUM_BUFFERS; i++) { |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
184 shm->wHdr[i].lpData = &mixbuf[i * (spec->size)]; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
185 shm->wHdr[i].dwBufferLength = spec->size; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
186 shm->wHdr[i].dwFlags = 0; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
187 shm->wHdr[i].dwUser = i; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
188 shm->wHdr[i].dwLoops = 0; /* loop control counter */ |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
189 shm->wHdr[i].lpNext = NULL; /* reserved for driver */ |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
190 shm->wHdr[i].reserved = 0; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
191 inUse[i] = FALSE; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
192 } |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
193 next_buffer = 0; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
194 return 0; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
195 } |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
196 |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
197 static void MME_WaitAudio(_THIS) |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
198 { |
755
b1595db396a7
Date: Fri, 12 Dec 2003 11:51:21 +0900
Sam Lantinga <slouken@libsdl.org>
parents:
654
diff
changeset
|
199 while ( inUse[next_buffer] ) { |
b1595db396a7
Date: Fri, 12 Dec 2003 11:51:21 +0900
Sam Lantinga <slouken@libsdl.org>
parents:
654
diff
changeset
|
200 mmeWaitForCallbacks(); |
b1595db396a7
Date: Fri, 12 Dec 2003 11:51:21 +0900
Sam Lantinga <slouken@libsdl.org>
parents:
654
diff
changeset
|
201 mmeProcessCallbacks(); |
b1595db396a7
Date: Fri, 12 Dec 2003 11:51:21 +0900
Sam Lantinga <slouken@libsdl.org>
parents:
654
diff
changeset
|
202 } |
654
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
203 } |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
204 |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
205 static Uint8 *MME_GetAudioBuf(_THIS) |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
206 { |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
207 Uint8 *retval; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
208 |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
209 inUse[next_buffer] = TRUE; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
210 retval = (Uint8 *)(shm->wHdr[next_buffer].lpData); |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
211 return retval; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
212 } |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
213 |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
214 static void MME_PlayAudio(_THIS) |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
215 { |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
216 /* Queue it up */ |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
217 waveOutWrite(shm->sound, &(shm->wHdr[next_buffer]), sizeof(WAVEHDR)); |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
218 next_buffer = (next_buffer+1)%NUM_BUFFERS; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
219 } |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
220 |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
221 static void MME_WaitDone(_THIS) |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
222 { |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
223 MMRESULT result; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
224 int i; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
225 |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
226 if ( shm->sound ) { |
755
b1595db396a7
Date: Fri, 12 Dec 2003 11:51:21 +0900
Sam Lantinga <slouken@libsdl.org>
parents:
654
diff
changeset
|
227 for (i = 0; i < NUM_BUFFERS; i++) |
b1595db396a7
Date: Fri, 12 Dec 2003 11:51:21 +0900
Sam Lantinga <slouken@libsdl.org>
parents:
654
diff
changeset
|
228 while ( inUse[i] ) { |
b1595db396a7
Date: Fri, 12 Dec 2003 11:51:21 +0900
Sam Lantinga <slouken@libsdl.org>
parents:
654
diff
changeset
|
229 mmeWaitForCallbacks(); |
b1595db396a7
Date: Fri, 12 Dec 2003 11:51:21 +0900
Sam Lantinga <slouken@libsdl.org>
parents:
654
diff
changeset
|
230 mmeProcessCallbacks(); |
b1595db396a7
Date: Fri, 12 Dec 2003 11:51:21 +0900
Sam Lantinga <slouken@libsdl.org>
parents:
654
diff
changeset
|
231 } |
654
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
232 result = waveOutReset(shm->sound); |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
233 if ( result != MMSYSERR_NOERROR ) |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
234 SetMMerror("waveOutReset()", result); |
755
b1595db396a7
Date: Fri, 12 Dec 2003 11:51:21 +0900
Sam Lantinga <slouken@libsdl.org>
parents:
654
diff
changeset
|
235 mmeProcessCallbacks(); |
654
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
236 } |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
237 } |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
238 |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
239 static void MME_CloseAudio(_THIS) |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
240 { |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
241 MMRESULT result; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
242 |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
243 if ( mixbuf ) { |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
244 result = mmeFreeBuffer(mixbuf); |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
245 if (result != MMSYSERR_NOERROR ) |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
246 SetMMerror("mmeFreeBuffer", result); |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
247 mixbuf = NULL; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
248 } |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
249 |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
250 if ( shm ) { |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
251 if ( shm->sound ) { |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
252 result = waveOutClose(shm->sound); |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
253 if (result != MMSYSERR_NOERROR ) |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
254 SetMMerror("waveOutClose()", result); |
755
b1595db396a7
Date: Fri, 12 Dec 2003 11:51:21 +0900
Sam Lantinga <slouken@libsdl.org>
parents:
654
diff
changeset
|
255 mmeProcessCallbacks(); |
654
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
256 } |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
257 result = mmeFreeMem(shm); |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
258 if (result != MMSYSERR_NOERROR ) |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
259 SetMMerror("mmeFreeMem()", result); |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
260 shm = NULL; |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
261 } |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
262 } |
e92bcf2573cb
Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
263 |