annotate src/audio/mme/SDL_mmeaudio.c @ 1662:782fd950bd46 SDL-1.3

Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API. WARNING: None of the video drivers have been updated for the new API yet! The API is still under design and very fluid. The code is now run through a consistent indent format: indent -i4 -nut -nsc -br -ce The headers are being converted to automatically generate doxygen documentation.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 28 May 2006 13:04:16 +0000
parents d910939febfa
children 4da1ee79c9af
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 */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
35 static int MME_OpenAudio (_THIS, SDL_AudioSpec * spec);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
36 static void MME_WaitAudio (_THIS);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
37 static Uint8 *MME_GetAudioBuf (_THIS);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
38 static void MME_PlayAudio (_THIS);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
39 static void MME_WaitDone (_THIS);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
40 static void MME_CloseAudio (_THIS);
654
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 */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
43 static int
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
44 Audio_Available (void)
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
45 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
46 return (1);
654
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
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
49 static void
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
50 Audio_DeleteDevice (SDL_AudioDevice * device)
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
51 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
52 if (device) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
53 if (device->hidden) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
54 SDL_free (device->hidden);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
55 device->hidden = NULL;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
56 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
57 SDL_free (device);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
58 device = NULL;
654
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 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
61
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
62 static SDL_AudioDevice *
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
63 Audio_CreateDevice (int devindex)
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64 {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
65 SDL_AudioDevice *this;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
66
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67 /* Initialize all variables that we clean on shutdown */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
68 this = SDL_malloc (sizeof (SDL_AudioDevice));
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
69 if (this) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
70 SDL_memset (this, 0, (sizeof *this));
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
71 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
72 }
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
73 if ((this == NULL) || (this->hidden == NULL)) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
74 SDL_OutOfMemory ();
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
75 if (this) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
76 SDL_free (this);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
77 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
78 return (0);
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79 }
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
80 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
81 /* Set the function pointers */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
82 this->OpenAudio = MME_OpenAudio;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
83 this->WaitAudio = MME_WaitAudio;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
84 this->PlayAudio = MME_PlayAudio;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
85 this->GetAudioBuf = MME_GetAudioBuf;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
86 this->WaitDone = MME_WaitDone;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
87 this->CloseAudio = MME_CloseAudio;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
88 this->free = Audio_DeleteDevice;
654
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 return this;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91 }
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 AudioBootStrap MMEAUDIO_bootstrap = {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94 "waveout", "Tru64 MME WaveOut",
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95 Audio_Available, Audio_CreateDevice
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
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
98 static void
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
99 SetMMerror (char *function, MMRESULT code)
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
100 {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101 int len;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102 char errbuf[MAXERRORLENGTH];
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
103
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
104 SDL_snprintf (errbuf, SDL_arraysize (errbuf), "%s: ", function);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
105 len = SDL_strlen (errbuf);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
106 waveOutGetErrorText (code, errbuf + len, MAXERRORLENGTH - len);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
107 SDL_SetError ("%s", errbuf);
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
108 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
109
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
110 static void CALLBACK
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
111 MME_CALLBACK (HWAVEOUT hwo,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
112 UINT uMsg, DWORD dwInstance, LPARAM dwParam1, LPARAM dwParam2)
654
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 WAVEHDR *wp = (WAVEHDR *) dwParam1;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
115
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
116 if (uMsg == WOM_DONE)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
117 inUse[wp->dwUser] = FALSE;
654
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
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
120 static int
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
121 MME_OpenAudio (_THIS, SDL_AudioSpec * spec)
654
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 MMRESULT result;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
124 int i;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126 mixbuf = NULL;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
128 /* Set basic WAVE format parameters */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
129 shm = mmeAllocMem (sizeof (*shm));
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
130 if (shm == NULL) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
131 SDL_SetError ("Out of memory: shm");
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
132 return (-1);
654
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 shm->sound = 0;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
135 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
136
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
137 /* Determine the audio parameters from the AudioSpec */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
138 switch (spec->format & 0xFF) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
139 case 8:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
140 /* Unsigned 8 bit audio data */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
141 spec->format = AUDIO_U8;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
142 shm->wFmt.wBitsPerSample = 8;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
143 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
144 case 16:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
145 /* Signed 16 bit audio data */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
146 spec->format = AUDIO_S16;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
147 shm->wFmt.wBitsPerSample = 16;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
148 break;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
149 default:
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
150 SDL_SetError ("Unsupported audio format");
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
151 return (-1);
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
152 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
153
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 = spec->channels;
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 = spec->freq;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
156 shm->wFmt.wf.nBlockAlign =
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
157 shm->wFmt.wf.nChannels * shm->wFmt.wBitsPerSample / 8;
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
158 shm->wFmt.wf.nAvgBytesPerSec =
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
159 shm->wFmt.wf.nSamplesPerSec * shm->wFmt.wf.nBlockAlign;
654
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 /* Check the buffer size -- minimum of 1/4 second (word aligned) */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
162 if (spec->samples < (spec->freq / 4))
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
163 spec->samples = ((spec->freq / 4) + 3) & ~3;
654
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 /* Update the fragment size as size in bytes */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
166 SDL_CalculateAudioSpec (spec);
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
167
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
168 /* Open the audio device */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
169 result = waveOutOpen (&(shm->sound),
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
170 WAVE_MAPPER,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
171 &(shm->wFmt.wf),
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
172 MME_CALLBACK,
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
173 NULL, (CALLBACK_FUNCTION | WAVE_OPEN_SHAREABLE));
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
174 if (result != MMSYSERR_NOERROR) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
175 SetMMerror ("waveOutOpen()", result);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
176 return (-1);
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
177 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
178
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
179 /* Create the sound buffers */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
180 mixbuf = (Uint8 *) mmeAllocBuffer (NUM_BUFFERS * (spec->size));
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
181 if (mixbuf == NULL) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
182 SDL_SetError ("Out of memory: mixbuf");
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
183 return (-1);
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
184 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
185
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
186 for (i = 0; i < NUM_BUFFERS; i++) {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
187 shm->wHdr[i].lpData = &mixbuf[i * (spec->size)];
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
188 shm->wHdr[i].dwBufferLength = spec->size;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
189 shm->wHdr[i].dwFlags = 0;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
190 shm->wHdr[i].dwUser = i;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
191 shm->wHdr[i].dwLoops = 0; /* loop control counter */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
192 shm->wHdr[i].lpNext = NULL; /* reserved for driver */
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
193 shm->wHdr[i].reserved = 0;
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
194 inUse[i] = FALSE;
654
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 next_buffer = 0;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
197 return 0;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
198 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
199
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
200 static void
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
201 MME_WaitAudio (_THIS)
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
202 {
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
203 while (inUse[next_buffer]) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
204 mmeWaitForCallbacks ();
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
205 mmeProcessCallbacks ();
755
b1595db396a7 Date: Fri, 12 Dec 2003 11:51:21 +0900
Sam Lantinga <slouken@libsdl.org>
parents: 654
diff changeset
206 }
654
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
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
209 static Uint8 *
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
210 MME_GetAudioBuf (_THIS)
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
211 {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
212 Uint8 *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 inUse[next_buffer] = TRUE;
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
215 retval = (Uint8 *) (shm->wHdr[next_buffer].lpData);
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
216 return retval;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
217 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
218
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
219 static void
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
220 MME_PlayAudio (_THIS)
654
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 /* Queue it up */
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
223 waveOutWrite (shm->sound, &(shm->wHdr[next_buffer]), sizeof (WAVEHDR));
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
224 next_buffer = (next_buffer + 1) % NUM_BUFFERS;
654
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
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
227 static void
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
228 MME_WaitDone (_THIS)
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
229 {
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
230 MMRESULT result;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
231 int i;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
232
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
233 if (shm->sound) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
234 for (i = 0; i < NUM_BUFFERS; i++)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
235 while (inUse[i]) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
236 mmeWaitForCallbacks ();
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
237 mmeProcessCallbacks ();
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
238 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
239 result = waveOutReset (shm->sound);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
240 if (result != MMSYSERR_NOERROR)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
241 SetMMerror ("waveOutReset()", result);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
242 mmeProcessCallbacks ();
654
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 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
245
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
246 static void
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
247 MME_CloseAudio (_THIS)
654
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 MMRESULT result;
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
250
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
251 if (mixbuf) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
252 result = mmeFreeBuffer (mixbuf);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
253 if (result != MMSYSERR_NOERROR)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
254 SetMMerror ("mmeFreeBuffer", result);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
255 mixbuf = NULL;
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
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
258 if (shm) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
259 if (shm->sound) {
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
260 result = waveOutClose (shm->sound);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
261 if (result != MMSYSERR_NOERROR)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
262 SetMMerror ("waveOutClose()", result);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
263 mmeProcessCallbacks ();
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
264 }
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
265 result = mmeFreeMem (shm);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
266 if (result != MMSYSERR_NOERROR)
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
267 SetMMerror ("mmeFreeMem()", result);
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
268 shm = NULL;
654
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
269 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
270 }
e92bcf2573cb Added audio and CD-ROM support for OSF/Tru64 (thanks Hayashi!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
271
1662
782fd950bd46 Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
272 /* vi: set ts=4 sw=4 expandtab: */