Mercurial > sdl-ios-xcode
annotate src/audio/windx5/SDL_dx5audio.c @ 3842:6b04ca2f1016 SDL-ryan-multiple-audio-device
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Tue, 17 Oct 2006 06:37:42 +0000 |
parents | c8b3d3d13ed1 |
children | 66fb40445587 |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
0 | 7 License as published by the Free Software Foundation; either |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
0 | 9 |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
13 Lesser General Public License for more details. |
0 | 14 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
0 | 18 |
19 Sam Lantinga | |
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
217
diff
changeset
|
20 slouken@libsdl.org |
0 | 21 */ |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1361
diff
changeset
|
22 #include "SDL_config.h" |
0 | 23 |
24 /* Allow access to a raw mixing buffer */ | |
25 | |
26 #include "SDL_timer.h" | |
27 #include "SDL_audio.h" | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
28 #include "../SDL_audio_c.h" |
0 | 29 #include "SDL_dx5audio.h" |
30 | |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
31 /* !!! FIXME: move this somewhere that other drivers can use it... */ |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
32 #if defined(_WIN32_WCE) |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
33 #define WINDOWS_OS_NAME "Windows CE/PocketPC" |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
34 #elif defined(WIN64) |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
35 #define WINDOWS_OS_NAME "Win64" |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
36 #else |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
37 #define WINDOWS_OS_NAME "Win32" |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
38 #endif |
0 | 39 |
40 /* DirectX function pointers for audio */ | |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
41 static HINSTANCE DSoundDLL = NULL; |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
42 static HRESULT (WINAPI *DSoundCreate)(LPGUID,LPDIRECTSOUND*,LPUNKNOWN) = NULL; |
0 | 43 |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
44 static void |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
45 DSOUND_Unload(void) |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
46 { |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
47 if (DSoundDLL != NULL) { |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
48 FreeLibrary(DSoundDLL); |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
49 } |
0 | 50 |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
51 DSoundCreate = NULL; |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
52 DSoundDLL = NULL; |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
53 } |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
54 |
0 | 55 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
56 static int |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
57 DSOUND_Load(void) |
0 | 58 { |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
59 int loaded = 0; |
0 | 60 |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
61 DSOUND_Unload(); |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
62 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
63 DSoundDLL = LoadLibrary(TEXT("DSOUND.DLL")); |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
64 if (DSoundDLL == NULL) { |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
65 SDL_SetError("DirectSound: failed to load DSOUND.DLL"); |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
66 } else { |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
67 /* Now make sure we have DirectX 5 or better... */ |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
68 /* (DirectSoundCaptureCreate was added in DX5) */ |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
69 if (!GetProcAddress(DSoundDLL, TEXT("DirectSoundCaptureCreate"))) { |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
70 SDL_SetError("DirectSound: System doesn't appear to have DX5."); |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
71 } else { |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
72 DSoundCreate = (void *) GetProcAddress(DSoundDLL, |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
73 TEXT("DirectSoundCreate")); |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
74 } |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
75 |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
76 if (!DSoundCreate) { |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
77 SDL_SetError("DirectSound: Failed to find DirectSoundCreate"); |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
78 } else { |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
79 loaded = 1; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
80 } |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
81 } |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
82 |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
83 if (!loaded) { |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
84 DSOUND_Unload(); |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
85 } |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
86 |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
87 return loaded; |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
88 } |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
89 |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
90 |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
91 |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
92 |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
93 static int |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
94 DSOUND_Available(void) |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
95 { |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
96 int dsound_ok = 1; |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
97 OSVERSIONINFO ver; |
0 | 98 |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
99 /* |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
100 * Unfortunately, the sound drivers on NT have higher latencies than the |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
101 * audio buffers used by many SDL applications, so there are gaps in the |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
102 * audio - it sounds terrible. Punt for now. |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
103 */ |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
104 SDL_memset(&ver, '\0', sizeof (OSVERSIONINFO)); |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
105 ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
106 GetVersionEx(&ver); |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
107 if (ver.dwPlatformId == VER_PLATFORM_WIN32_NT) |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
108 if (ver.dwMajorVersion <= 4) { |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
109 dsound_ok = 0; /* NT4.0 or earlier. Disable dsound support. */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
110 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
111 } |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
112 |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
113 if (dsound_ok) { |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
114 dsound_ok = DSOUND_Load(); /* make sure we really have DX5. */ |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
115 DSOUND_Unload(); |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
116 } |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
117 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
118 return (dsound_ok); |
0 | 119 } |
120 | |
121 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
122 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
123 SetDSerror(const char *function, int code) |
0 | 124 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
125 static const char *error; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
126 static char errbuf[1024]; |
0 | 127 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
128 errbuf[0] = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
129 switch (code) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
130 case E_NOINTERFACE: |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
131 error = "Unsupported interface -- Is DirectX 5.0 or later installed?"; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
132 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
133 case DSERR_ALLOCATED: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
134 error = "Audio device in use"; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
135 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
136 case DSERR_BADFORMAT: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
137 error = "Unsupported audio format"; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
138 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
139 case DSERR_BUFFERLOST: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
140 error = "Mixing buffer was lost"; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
141 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
142 case DSERR_CONTROLUNAVAIL: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
143 error = "Control requested is not available"; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
144 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
145 case DSERR_INVALIDCALL: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
146 error = "Invalid call for the current state"; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
147 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
148 case DSERR_INVALIDPARAM: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
149 error = "Invalid parameter"; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
150 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
151 case DSERR_NODRIVER: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
152 error = "No audio device found"; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
153 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
154 case DSERR_OUTOFMEMORY: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
155 error = "Out of memory"; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
156 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
157 case DSERR_PRIOLEVELNEEDED: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
158 error = "Caller doesn't have priority"; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
159 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
160 case DSERR_UNSUPPORTED: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
161 error = "Function not supported"; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
162 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
163 default: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
164 SDL_snprintf(errbuf, SDL_arraysize(errbuf), |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
165 "%s: Unknown DirectSound error: 0x%x", function, code); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
166 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
167 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
168 if (!errbuf[0]) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
169 SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: %s", function, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
170 error); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
171 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
172 SDL_SetError("%s", errbuf); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
173 return; |
0 | 174 } |
175 | |
176 /* DirectSound needs to be associated with a window */ | |
177 static HWND mainwin = NULL; | |
178 /* */ | |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
179 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
180 void |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
181 DSOUND_SoundFocus(HWND hwnd) |
0 | 182 { |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
183 /* !!! FIXME: probably broken with multi-window support in SDL 1.3 ... */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
184 mainwin = hwnd; |
0 | 185 } |
186 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
187 static void |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
188 DSOUND_ThreadInit(_THIS) |
0 | 189 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
190 SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST); |
0 | 191 } |
192 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
193 static void |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
194 DSOUND_WaitDevice(_THIS) |
0 | 195 { |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
196 DWORD status = 0; |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
197 DWORD cursor = 0; |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
198 DWORD junk = 0; |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
199 HRESULT result = DS_OK; |
0 | 200 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
201 /* Semi-busy wait, since we have no way of getting play notification |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
202 on a primary mixing buffer located in hardware (DirectX 5.0) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
203 */ |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
204 result = IDirectSoundBuffer_GetCurrentPosition(this->hidden->mixbuf, |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
205 &junk, &cursor); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
206 if (result != DS_OK) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
207 if (result == DSERR_BUFFERLOST) { |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
208 IDirectSoundBuffer_Restore(this->hidden->mixbuf); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
209 } |
0 | 210 #ifdef DEBUG_SOUND |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
211 SetDSerror("DirectSound GetCurrentPosition", result); |
0 | 212 #endif |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
213 return; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
214 } |
0 | 215 |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
216 while ((cursor / this->hidden->mixlen) == this->hidden->lastchunk) { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
217 /* FIXME: find out how much time is left and sleep that long */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
218 SDL_Delay(1); |
0 | 219 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
220 /* Try to restore a lost sound buffer */ |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
221 IDirectSoundBuffer_GetStatus(this->hidden->mixbuf, &status); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
222 if ((status & DSBSTATUS_BUFFERLOST)) { |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
223 IDirectSoundBuffer_Restore(this->hidden->mixbuf); |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
224 IDirectSoundBuffer_GetStatus(this->hidden->mixbuf, &status); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
225 if ((status & DSBSTATUS_BUFFERLOST)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
226 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
227 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
228 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
229 if (!(status & DSBSTATUS_PLAYING)) { |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
230 result = IDirectSoundBuffer_Play(this->hidden->mixbuf, 0, 0, |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
231 DSBPLAY_LOOPING); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
232 if (result == DS_OK) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
233 continue; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
234 } |
0 | 235 #ifdef DEBUG_SOUND |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
236 SetDSerror("DirectSound Play", result); |
0 | 237 #endif |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
238 return; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
239 } |
0 | 240 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
241 /* Find out where we are playing */ |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
242 result = IDirectSoundBuffer_GetCurrentPosition(this->hidden->mixbuf, |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
243 &junk, &cursor); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
244 if (result != DS_OK) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
245 SetDSerror("DirectSound GetCurrentPosition", result); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
246 return; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
247 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
248 } |
0 | 249 } |
250 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
251 static void |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
252 DSOUND_PlayDevice(_THIS) |
0 | 253 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
254 /* Unlock the buffer, allowing it to play */ |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
255 if (this->hidden->locked_buf) { |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
256 IDirectSoundBuffer_Unlock(this->hidden->mixbuf, |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
257 this->hidden->locked_buf, |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
258 this->hidden->mixlen, NULL, 0); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
259 } |
0 | 260 |
261 } | |
262 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
263 static Uint8 * |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
264 DSOUND_GetDeviceBuf(_THIS) |
0 | 265 { |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
266 DWORD cursor = 0; |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
267 DWORD junk = 0; |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
268 HRESULT result = DS_OK; |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
269 DWORD rawlen = 0; |
0 | 270 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
271 /* Figure out which blocks to fill next */ |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
272 this->hidden->locked_buf = NULL; |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
273 result = IDirectSoundBuffer_GetCurrentPosition(this->hidden->mixbuf, |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
274 &junk, &cursor); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
275 if (result == DSERR_BUFFERLOST) { |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
276 IDirectSoundBuffer_Restore(this->hidden->mixbuf); |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
277 result = IDirectSoundBuffer_GetCurrentPosition(this->hidden->mixbuf, |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
278 &junk, &cursor); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
279 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
280 if (result != DS_OK) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
281 SetDSerror("DirectSound GetCurrentPosition", result); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
282 return (NULL); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
283 } |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
284 cursor /= this->hidden->mixlen; |
1877 | 285 #ifdef DEBUG_SOUND |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
286 /* Detect audio dropouts */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
287 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
288 DWORD spot = cursor; |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
289 if (spot < this->hidden->lastchunk) { |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
290 spot += this->hidden->num_buffers; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
291 } |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
292 if (spot > this->hidden->lastchunk + 1) { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
293 fprintf(stderr, "Audio dropout, missed %d fragments\n", |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
294 (spot - (this->hidden->lastchunk + 1))); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
295 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
296 } |
1877 | 297 #endif |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
298 this->hidden->lastchunk = cursor; |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
299 cursor = (cursor + 1) % this->hidden->num_buffers; |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
300 cursor *= this->hidden->mixlen; |
0 | 301 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
302 /* Lock the audio buffer */ |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
303 result = IDirectSoundBuffer_Lock(this->hidden->mixbuf, cursor, |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
304 this->hidden->mixlen, |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
305 (LPVOID *) &this->hidden->locked_buf, |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
306 &rawlen, NULL, &junk, 0); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
307 if (result == DSERR_BUFFERLOST) { |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
308 IDirectSoundBuffer_Restore(this->hidden->mixbuf); |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
309 result = IDirectSoundBuffer_Lock(this->hidden->mixbuf, cursor, |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
310 this->hidden->mixlen, |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
311 (LPVOID *) &this->hidden->locked_buf, |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
312 &rawlen, NULL, &junk, 0); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
313 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
314 if (result != DS_OK) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
315 SetDSerror("DirectSound Lock", result); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
316 return (NULL); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
317 } |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
318 return (this->hidden->locked_buf); |
0 | 319 } |
320 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
321 static void |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
322 DSOUND_WaitDone(_THIS) |
0 | 323 { |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
324 Uint8 *stream = DSOUND_GetDeviceBuf(this); |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
325 |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
326 /* Wait for the playing chunk to finish */ |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
327 if (stream != NULL) { |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
328 SDL_memset(stream, this->spec.silence, this->hidden->mixlen); |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
329 DSOUND_PlayDevice(this); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
330 } |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
331 DSOUND_WaitDevice(this); |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
332 |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
333 /* Stop the looping sound buffer */ |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
334 IDirectSoundBuffer_Stop(this->hidden->mixbuf); |
0 | 335 } |
336 | |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
337 static void |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
338 DSOUND_CloseDevice(_THIS) |
0 | 339 { |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
340 if (this->hidden != NULL) { |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
341 if (this->hidden->sound != NULL) { |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
342 if (this->hidden->mixbuf != NULL) { |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
343 /* Clean up the audio buffer */ |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
344 IDirectSoundBuffer_Release(this->hidden->mixbuf); |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
345 this->hidden->mixbuf = NULL; |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
346 } |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
347 IDirectSound_Release(this->hidden->sound); |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
348 this->hidden->sound = NULL; |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
349 } |
0 | 350 |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
351 SDL_free(this->hidden); |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
352 this->hidden = NULL; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
353 } |
0 | 354 } |
355 | |
356 /* This function tries to create a secondary audio buffer, and returns the | |
357 number of audio chunks available in the created buffer. | |
358 */ | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
359 static int |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
360 CreateSecondary(_THIS, HWND focus, WAVEFORMATEX *wavefmt) |
0 | 361 { |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
362 LPDIRECTSOUND sndObj = this->hidden->sound; |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
363 LPDIRECTSOUNDBUFFER *sndbuf = this->hidden->mixbuf; |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
364 Uint32 chunksize = this->spec.size; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
365 const int numchunks = 8; |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
366 HRESULT result = DS_OK; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
367 DSBUFFERDESC format; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
368 LPVOID pvAudioPtr1, pvAudioPtr2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
369 DWORD dwAudioBytes1, dwAudioBytes2; |
0 | 370 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
371 /* Try to set primary mixing privileges */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
372 if (focus) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
373 result = IDirectSound_SetCooperativeLevel(sndObj, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
374 focus, DSSCL_PRIORITY); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
375 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
376 result = IDirectSound_SetCooperativeLevel(sndObj, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
377 GetDesktopWindow(), |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
378 DSSCL_NORMAL); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
379 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
380 if (result != DS_OK) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
381 SetDSerror("DirectSound SetCooperativeLevel", result); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
382 return (-1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
383 } |
0 | 384 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
385 /* Try to create the secondary buffer */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
386 SDL_memset(&format, 0, sizeof(format)); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
387 format.dwSize = sizeof(format); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
388 format.dwFlags = DSBCAPS_GETCURRENTPOSITION2; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
389 if (!focus) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
390 format.dwFlags |= DSBCAPS_GLOBALFOCUS; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
391 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
392 format.dwFlags |= DSBCAPS_STICKYFOCUS; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
393 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
394 format.dwBufferBytes = numchunks * chunksize; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
395 if ((format.dwBufferBytes < DSBSIZE_MIN) || |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
396 (format.dwBufferBytes > DSBSIZE_MAX)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
397 SDL_SetError("Sound buffer size must be between %d and %d", |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
398 DSBSIZE_MIN / numchunks, DSBSIZE_MAX / numchunks); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
399 return (-1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
400 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
401 format.dwReserved = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
402 format.lpwfxFormat = wavefmt; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
403 result = IDirectSound_CreateSoundBuffer(sndObj, &format, sndbuf, NULL); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
404 if (result != DS_OK) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
405 SetDSerror("DirectSound CreateSoundBuffer", result); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
406 return (-1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
407 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
408 IDirectSoundBuffer_SetFormat(*sndbuf, wavefmt); |
0 | 409 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
410 /* Silence the initial audio buffer */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
411 result = IDirectSoundBuffer_Lock(*sndbuf, 0, format.dwBufferBytes, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
412 (LPVOID *) & pvAudioPtr1, &dwAudioBytes1, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
413 (LPVOID *) & pvAudioPtr2, &dwAudioBytes2, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
414 DSBLOCK_ENTIREBUFFER); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
415 if (result == DS_OK) { |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
416 SDL_memset(pvAudioPtr1, this->spec.silence, dwAudioBytes1); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
417 IDirectSoundBuffer_Unlock(*sndbuf, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
418 (LPVOID) pvAudioPtr1, dwAudioBytes1, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
419 (LPVOID) pvAudioPtr2, dwAudioBytes2); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
420 } |
118
7c47e511459d
Fix noise when starting audio under DX5 (thanks Jesse!)
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
421 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
422 /* We're ready to go */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
423 return (numchunks); |
0 | 424 } |
425 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
426 static int |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
427 DSOUND_OpenDevice(_THIS, const char *devname, int iscapture) |
0 | 428 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
429 HRESULT result; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
430 WAVEFORMATEX waveformat; |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
431 int valid_format = 0; |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
432 SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format); |
0 | 433 |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
434 /* !!! FIXME: handle devname */ |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
435 /* !!! FIXME: handle iscapture */ |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
436 |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
437 /* Initialize all variables that we clean on shutdown */ |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
438 this->hidden = (struct SDL_PrivateAudioData *) |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
439 SDL_malloc((sizeof *this->hidden)); |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
440 if (this->hidden == NULL) { |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
441 SDL_OutOfMemory(); |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
442 return 0; |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
443 } |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
444 SDL_memset(this->hidden, 0, (sizeof *this->hidden)); |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
445 |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
446 while ((!valid_format) && (test_format)) { |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
447 switch (test_format) { |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
448 case AUDIO_U8: |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
449 case AUDIO_S16: |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
450 case AUDIO_S32: |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
451 this->spec.format = test_format; |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
452 valid_format = 1; |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
453 break; |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
454 } |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
455 test_format = SDL_NextAudioFormat(); |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
456 } |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
457 |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
458 if (!valid_format) { |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
459 DSOUND_CloseDevice(this); |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
460 SDL_SetError("DirectSound: Unsupported audio format"); |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
461 return 0; |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
462 } |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
463 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
464 SDL_memset(&waveformat, 0, sizeof(waveformat)); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
465 waveformat.wFormatTag = WAVE_FORMAT_PCM; |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
466 waveformat.wBitsPerSample = SDL_AUDIO_BITSIZE(this->spec.format); |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
467 waveformat.nChannels = this->spec.channels; |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
468 waveformat.nSamplesPerSec = this->spec.freq; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
469 waveformat.nBlockAlign = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
470 waveformat.nChannels * (waveformat.wBitsPerSample / 8); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
471 waveformat.nAvgBytesPerSec = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
472 waveformat.nSamplesPerSec * waveformat.nBlockAlign; |
0 | 473 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
474 /* Update the fragment size as size in bytes */ |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
475 SDL_CalculateAudioSpec(&this->spec); |
0 | 476 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
477 /* Open the audio device */ |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
478 result = DSoundCreate(NULL, &this->hidden->sound, NULL); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
479 if (result != DS_OK) { |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
480 DSOUND_CloseDevice(this); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
481 SetDSerror("DirectSoundCreate", result); |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
482 return 0; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
483 } |
0 | 484 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
485 /* Create the audio buffer to which we write */ |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
486 this->hidden->num_buffers = CreateSecondary(this, mainwin, &waveformat); |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
487 if (this->hidden->num_buffers < 0) { |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
488 DSOUND_CloseDevice(this); |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
489 return 0; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
490 } |
0 | 491 |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
492 /* The buffer will auto-start playing in DSOUND_WaitDevice() */ |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
493 this->hidden->mixlen = this->spec.size; |
0 | 494 |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
495 return 1; /* good to go. */ |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
496 } |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
497 |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
498 |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
499 static void |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
500 DSOUND_Deinitialize(void) |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
501 { |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
502 DSOUND_Unload(); |
0 | 503 } |
504 | |
3842
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
505 |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
506 static int |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
507 DSOUND_Init(SDL_AudioDriverImpl *impl) |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
508 { |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
509 /* Load DirectX */ |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
510 if (DSOUND_Load() < 0) { |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
511 return 0; |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
512 } |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
513 |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
514 /* Set the function pointers */ |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
515 impl->OpenDevice = DSOUND_OpenDevice; |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
516 impl->PlayDevice = DSOUND_PlayDevice; |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
517 impl->WaitDevice = DSOUND_WaitDevice; |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
518 impl->WaitDone = DSOUND_WaitDone; |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
519 impl->ThreadInit = DSOUND_ThreadInit; |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
520 impl->GetDeviceBuf = DSOUND_GetDeviceBuf; |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
521 impl->CloseDevice = DSOUND_CloseDevice; |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
522 impl->Deinitialize = DSOUND_Deinitialize; |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
523 impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME */ |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
524 |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
525 return 1; |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
526 } |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
527 |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
528 AudioBootStrap DSOUND_bootstrap = { |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
529 "dsound", WINDOWS_OS_NAME "DirectSound", |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
530 DSOUND_Available, DSOUND_Init, 0 |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
531 }; |
6b04ca2f1016
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
Ryan C. Gordon <icculus@icculus.org>
parents:
3798
diff
changeset
|
532 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1877
diff
changeset
|
533 /* vi: set ts=4 sw=4 expandtab: */ |