annotate src/audio/mme/SDL_mmeaudio.c @ 1402:d910939febfa

Use consistent identifiers for the various platforms we support. Make sure every source file includes SDL_config.h, so the proper system headers are chosen.
author Sam Lantinga <slouken@libsdl.org>
date Tue, 21 Feb 2006 08:46:50 +0000
parents 19418e4422cb
children 782fd950bd46 c121d94672cb a1b03ba2fcd0
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 */
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"
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24 /* Tru64 UNIX MME support */
1342
d73be99e9420 Fixed it Hayashi Naoyuki's way. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1338
diff changeset
25 #include <mme_api.h>
d73be99e9420 Fixed it Hayashi Naoyuki's way. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1338
diff changeset
26
1358
c71e05b4dc2e More header massaging... works great on Windows. ;-)
Sam Lantinga <slouken@libsdl.org>
parents: 1342
diff changeset
27 #include "SDL_timer.h"
1342
d73be99e9420 Fixed it Hayashi Naoyuki's way. :)
Sam Lantinga <slouken@libsdl.org>
parents: 1338
diff changeset
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_audio_c.h"
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30 #include "SDL_mmeaudio.h"
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
32 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
33
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
34 /* Audio driver functions */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35 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
36 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
37 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
38 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
39 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
40 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
41
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
42 /* Audio driver bootstrap functions */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
43 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
44 {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
45 return(1);
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
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
48 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
49 {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
50 if ( device ) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
51 if ( device->hidden ) {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
52 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
53 device->hidden = NULL;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
54 }
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
55 SDL_free(device);
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
56 device = NULL;
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
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
60 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
61 {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
62 SDL_AudioDevice *this;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
63
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64 /* 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
65 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
66 if ( this ) {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
67 SDL_memset(this, 0, (sizeof *this));
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
68 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
69 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
70 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
71 SDL_OutOfMemory();
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72 if ( this ) {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
73 SDL_free(this);
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
74 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75 return(0);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76 }
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
77 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
78 /* Set the function pointers */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79 this->OpenAudio = MME_OpenAudio;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
80 this->WaitAudio = MME_WaitAudio;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
81 this->PlayAudio = MME_PlayAudio;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
82 this->GetAudioBuf = MME_GetAudioBuf;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
83 this->WaitDone = MME_WaitDone;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
84 this->CloseAudio = MME_CloseAudio;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85 this->free = Audio_DeleteDevice;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
86
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
87 return this;
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
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90 AudioBootStrap MMEAUDIO_bootstrap = {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91 "waveout", "Tru64 MME WaveOut",
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92 Audio_Available, Audio_CreateDevice
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
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95 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
96 {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97 int len;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98 char errbuf[MAXERRORLENGTH];
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
99
1338
604d73db6802 Removed uses of stdlib.h and string.h
Sam Lantinga <slouken@libsdl.org>
parents: 1336
diff changeset
100 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
101 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
102 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
103 SDL_SetError("%s",errbuf);
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
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106 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
107 UINT uMsg,
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
108 DWORD dwInstance,
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
109 LPARAM dwParam1,
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
110 LPARAM dwParam2)
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
111 {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
112 WAVEHDR *wp = (WAVEHDR *) dwParam1;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
113
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
114 if ( uMsg == WOM_DONE )
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
115 inUse[wp->dwUser] = FALSE;
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
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118 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
119 {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
120 MMRESULT result;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
121 int i;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
123 mixbuf = NULL;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
124
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125 /* 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
126 shm = mmeAllocMem(sizeof(*shm));
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127 if ( shm == NULL ) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
128 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
129 return(-1);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131 shm->sound = 0;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
132 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
133
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
134 /* 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
135 switch ( spec->format & 0xFF ) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
136 case 8:
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
137 /* 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
138 spec->format = AUDIO_U8;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
139 shm->wFmt.wBitsPerSample = 8;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
140 break;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
141 case 16:
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
142 /* 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
143 spec->format = AUDIO_S16;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
144 shm->wFmt.wBitsPerSample = 16;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
145 break;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
146 default:
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
147 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
148 return(-1);
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
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
151 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
152 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
153 shm->wFmt.wf.nBlockAlign =
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
154 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
155 shm->wFmt.wf.nAvgBytesPerSec =
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
156 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
157
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
158 /* 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
159 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
160 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
161
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
162 /* 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
163 SDL_CalculateAudioSpec(spec);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
164
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165 /* Open the audio device */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
166 result = waveOutOpen(&(shm->sound),
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
167 WAVE_MAPPER,
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
168 &(shm->wFmt.wf),
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
169 MME_CALLBACK,
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
170 NULL,
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
171 (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
172 if ( result != MMSYSERR_NOERROR ) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
173 SetMMerror("waveOutOpen()", result);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
174 return(-1);
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
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
177 /* Create the sound buffers */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
178 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
179 if ( mixbuf == NULL ) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
180 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
181 return(-1);
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
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
184 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
185 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
186 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
187 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
188 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
189 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
190 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
191 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
192 inUse[i] = FALSE;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
193 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
194 next_buffer = 0;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
195 return 0;
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
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
198 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
199 {
755
b1595db396a7 Date: Fri, 12 Dec 2003 11:51:21 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
200 while ( inUse[next_buffer] ) {
b1595db396a7 Date: Fri, 12 Dec 2003 11:51:21 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
201 mmeWaitForCallbacks();
b1595db396a7 Date: Fri, 12 Dec 2003 11:51:21 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
202 mmeProcessCallbacks();
b1595db396a7 Date: Fri, 12 Dec 2003 11:51:21 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
203 }
654
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
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
206 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
207 {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
208 Uint8 *retval;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
209
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
210 inUse[next_buffer] = TRUE;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
211 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
212 return retval;
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
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
215 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
216 {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
217 /* Queue it up */
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
218 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
219 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
220 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
221
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
222 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
223 {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
224 MMRESULT result;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
225 int i;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
226
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
227 if ( shm->sound ) {
755
b1595db396a7 Date: Fri, 12 Dec 2003 11:51:21 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
228 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
229 while ( inUse[i] ) {
b1595db396a7 Date: Fri, 12 Dec 2003 11:51:21 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
230 mmeWaitForCallbacks();
b1595db396a7 Date: Fri, 12 Dec 2003 11:51:21 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
231 mmeProcessCallbacks();
b1595db396a7 Date: Fri, 12 Dec 2003 11:51:21 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
232 }
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
233 result = waveOutReset(shm->sound);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
234 if ( result != MMSYSERR_NOERROR )
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
235 SetMMerror("waveOutReset()", result);
755
b1595db396a7 Date: Fri, 12 Dec 2003 11:51:21 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
236 mmeProcessCallbacks();
654
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
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
240 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
241 {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
242 MMRESULT result;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
243
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
244 if ( mixbuf ) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
245 result = mmeFreeBuffer(mixbuf);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
246 if (result != MMSYSERR_NOERROR )
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
247 SetMMerror("mmeFreeBuffer", result);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
248 mixbuf = NULL;
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
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
251 if ( shm ) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
252 if ( shm->sound ) {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
253 result = waveOutClose(shm->sound);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
254 if (result != MMSYSERR_NOERROR )
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
255 SetMMerror("waveOutClose()", result);
755
b1595db396a7 Date: Fri, 12 Dec 2003 11:51:21 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
256 mmeProcessCallbacks();
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
257 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
258 result = mmeFreeMem(shm);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
259 if (result != MMSYSERR_NOERROR )
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
260 SetMMerror("mmeFreeMem()", result);
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
261 shm = NULL;
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 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
264