Reworked Windows DirectSound code.
Now supports multiple devices, and uses DirectSound 8 instead of 5. Changed
name to "directsound" and renamed source directory.
--- a/VisualC/SDL/SDL_VS2005.vcproj Sun Jul 24 03:37:13 2011 -0700
+++ b/VisualC/SDL/SDL_VS2005.vcproj Thu Aug 04 01:26:12 2011 -0400
@@ -580,7 +580,7 @@
>
</File>
<File
- RelativePath="..\..\src\audio\windx5\directx.h"
+ RelativePath="..\..\src\audio\directsound\directx.h"
>
</File>
<File
@@ -840,11 +840,11 @@
>
</File>
<File
- RelativePath="..\..\src\audio\windx5\SDL_dx5audio.c"
+ RelativePath="..\..\src\audio\directsound\SDL_directsound.c"
>
</File>
<File
- RelativePath="..\..\src\audio\windx5\SDL_dx5audio.h"
+ RelativePath="..\..\src\audio\directsound\SDL_directsound.h"
>
</File>
<File
--- a/VisualC/SDL/SDL_VS2008.vcproj Sun Jul 24 03:37:13 2011 -0700
+++ b/VisualC/SDL/SDL_VS2008.vcproj Thu Aug 04 01:26:12 2011 -0400
@@ -569,7 +569,7 @@
>
</File>
<File
- RelativePath="..\..\src\audio\windx5\directx.h"
+ RelativePath="..\..\src\audio\directsound\directx.h"
>
</File>
<File
@@ -829,11 +829,11 @@
>
</File>
<File
- RelativePath="..\..\src\audio\windx5\SDL_dx5audio.c"
+ RelativePath="..\..\src\audio\directsound\SDL_directsound.c"
>
</File>
<File
- RelativePath="..\..\src\audio\windx5\SDL_dx5audio.h"
+ RelativePath="..\..\src\audio\directsound\SDL_directsound.h"
>
</File>
<File
--- a/VisualC/SDL/SDL_VS2010.vcxproj Sun Jul 24 03:37:13 2011 -0700
+++ b/VisualC/SDL/SDL_VS2010.vcxproj Thu Aug 04 01:26:12 2011 -0400
@@ -250,7 +250,7 @@
<ClInclude Include="..\..\src\core\windows\SDL_windows.h" />
<ClInclude Include="..\..\src\events\blank_cursor.h" />
<ClInclude Include="..\..\src\events\default_cursor.h" />
- <ClInclude Include="..\..\src\audio\windx5\directx.h" />
+ <ClInclude Include="..\..\src\audio\directsound\directx.h" />
<ClInclude Include="..\..\src\events\SDL_clipboardevents_c.h" />
<ClInclude Include="..\..\src\events\SDL_gesture_c.h" />
<ClInclude Include="..\..\src\events\SDL_touch_c.h" />
@@ -279,7 +279,7 @@
<ClInclude Include="..\..\src\audio\windib\SDL_dibaudio.h" />
<ClInclude Include="..\..\src\audio\disk\SDL_diskaudio.h" />
<ClInclude Include="..\..\src\audio\dummy\SDL_dummyaudio.h" />
- <ClInclude Include="..\..\src\audio\windx5\SDL_dx5audio.h" />
+ <ClInclude Include="..\..\src\audio\directsound\SDL_directsound.h" />
<ClInclude Include="..\..\src\SDL_error_c.h" />
<ClInclude Include="..\..\src\SDL_hints_c.h" />
<ClInclude Include="..\..\src\events\SDL_events_c.h" />
@@ -380,7 +380,7 @@
<ClCompile Include="..\..\src\audio\windib\SDL_dibaudio.c" />
<ClCompile Include="..\..\src\audio\disk\SDL_diskaudio.c" />
<ClCompile Include="..\..\src\audio\dummy\SDL_dummyaudio.c" />
- <ClCompile Include="..\..\src\audio\windx5\SDL_dx5audio.c" />
+ <ClCompile Include="..\..\src\audio\directsound\SDL_directsound.c" />
<ClCompile Include="..\..\src\joystick\windows\SDL_dxjoystick.c" />
<ClCompile Include="..\..\src\SDL_error.c" />
<ClCompile Include="..\..\src\events\SDL_events.c" />
--- a/configure.in Sun Jul 24 03:37:13 2011 -0700
+++ b/configure.in Thu Aug 04 01:26:12 2011 -0400
@@ -2061,7 +2061,7 @@
SOURCES="$SOURCES $srcdir/src/audio/windib/*.c"
if test x$have_dsound = xyes; then
AC_DEFINE(SDL_AUDIO_DRIVER_DSOUND, 1, [ ])
- SOURCES="$SOURCES $srcdir/src/audio/windx5/*.c"
+ SOURCES="$SOURCES $srcdir/src/audio/directsound/*.c"
fi
have_audio=yes
fi
@@ -2148,7 +2148,7 @@
SOURCES="$SOURCES $srcdir/src/audio/windib/*.c"
if test x$have_dsound = xyes; then
AC_DEFINE(SDL_AUDIO_DRIVER_DSOUND, 1, [ ])
- SOURCES="$SOURCES $srcdir/src/audio/windx5/*.c"
+ SOURCES="$SOURCES $srcdir/src/audio/directsound/*.c"
fi
have_audio=yes
fi
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/directsound/SDL_directsound.c Thu Aug 04 01:26:12 2011 -0400
@@ -0,0 +1,623 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+#include "SDL_config.h"
+
+/* Allow access to a raw mixing buffer */
+
+#include "SDL_timer.h"
+#include "SDL_loadso.h"
+#include "SDL_audio.h"
+#include "../SDL_audio_c.h"
+#include "SDL_directsound.h"
+
+/* DirectX function pointers for audio */
+static void* DSoundDLL = NULL;
+typedef HRESULT(WINAPI*fnDirectSoundCreate8)(LPGUID,LPDIRECTSOUND*,LPUNKNOWN);
+typedef HRESULT(WINAPI*fnDirectSoundEnumerateW)(LPDSENUMCALLBACKW, LPVOID);
+typedef HRESULT(WINAPI*fnDirectSoundCaptureEnumerateW)(LPDSENUMCALLBACKW,LPVOID);
+static fnDirectSoundCreate8 pDirectSoundCreate8 = NULL;
+static fnDirectSoundEnumerateW pDirectSoundEnumerateW = NULL;
+static fnDirectSoundCaptureEnumerateW pDirectSoundCaptureEnumerateW = NULL;
+
+static void
+DSOUND_Unload(void)
+{
+ pDirectSoundCreate8 = NULL;
+ pDirectSoundEnumerateW = NULL;
+ pDirectSoundCaptureEnumerateW = NULL;
+
+ if (DSoundDLL != NULL) {
+ SDL_UnloadObject(DSoundDLL);
+ DSoundDLL = NULL;
+ }
+}
+
+
+static int
+DSOUND_Load(void)
+{
+ int loaded = 0;
+
+ DSOUND_Unload();
+
+ DSoundDLL = SDL_LoadObject("DSOUND.DLL");
+ if (DSoundDLL == NULL) {
+ SDL_SetError("DirectSound: failed to load DSOUND.DLL");
+ } else {
+ /* Now make sure we have DirectX 8 or better... */
+ #define DSOUNDLOAD(f) { \
+ p##f = (fn##f) SDL_LoadFunction(DSoundDLL, #f); \
+ if (!p##f) loaded = 0; \
+ }
+ loaded = 1; /* will reset if necessary. */
+ DSOUNDLOAD(DirectSoundCreate8);
+ DSOUNDLOAD(DirectSoundEnumerateW);
+ DSOUNDLOAD(DirectSoundCaptureEnumerateW);
+ #undef DSOUNDLOAD
+
+ if (!loaded) {
+ SDL_SetError("DirectSound: System doesn't appear to have DX8.");
+ }
+ }
+
+ if (!loaded) {
+ DSOUND_Unload();
+ }
+
+ return loaded;
+}
+
+static __inline__ char *
+utf16_to_utf8(const WCHAR *S)
+{
+ /* !!! FIXME: this should be UTF-16, not UCS-2! */
+ return SDL_iconv_string("UTF-8", "UCS-2", (char *)(S),
+ (SDL_wcslen(S)+1)*sizeof(WCHAR));
+}
+
+static void
+SetDSerror(const char *function, int code)
+{
+ static const char *error;
+ static char errbuf[1024];
+
+ errbuf[0] = 0;
+ switch (code) {
+ case E_NOINTERFACE:
+ error = "Unsupported interface -- Is DirectX 8.0 or later installed?";
+ break;
+ case DSERR_ALLOCATED:
+ error = "Audio device in use";
+ break;
+ case DSERR_BADFORMAT:
+ error = "Unsupported audio format";
+ break;
+ case DSERR_BUFFERLOST:
+ error = "Mixing buffer was lost";
+ break;
+ case DSERR_CONTROLUNAVAIL:
+ error = "Control requested is not available";
+ break;
+ case DSERR_INVALIDCALL:
+ error = "Invalid call for the current state";
+ break;
+ case DSERR_INVALIDPARAM:
+ error = "Invalid parameter";
+ break;
+ case DSERR_NODRIVER:
+ error = "No audio device found";
+ break;
+ case DSERR_OUTOFMEMORY:
+ error = "Out of memory";
+ break;
+ case DSERR_PRIOLEVELNEEDED:
+ error = "Caller doesn't have priority";
+ break;
+ case DSERR_UNSUPPORTED:
+ error = "Function not supported";
+ break;
+ default:
+ SDL_snprintf(errbuf, SDL_arraysize(errbuf),
+ "%s: Unknown DirectSound error: 0x%x", function, code);
+ break;
+ }
+ if (!errbuf[0]) {
+ SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: %s", function,
+ error);
+ }
+ SDL_SetError("%s", errbuf);
+ return;
+}
+
+
+
+/* !!! FIXME: this is a cut and paste of SDL_FreeUnixAudioDevices(),
+ * !!! FIXME: which is more proof this needs to be managed in SDL_audio.c
+ * !!! FIXME: and not in drivers.
+ */
+static void
+FreeDSoundAudioDevices(char ***devices, int *devCount)
+{
+ int i = *devCount;
+ if ((i > 0) && (*devices != NULL)) {
+ while (i--) {
+ SDL_free((*devices)[i]);
+ }
+ }
+
+ if (*devices != NULL) {
+ SDL_free(*devices);
+ }
+
+ *devices = NULL;
+ *devCount = 0;
+}
+
+
+typedef struct FindAllDevsData
+{
+ const char **devs;
+ unsigned int devcount;
+} FindAllDevsData;
+
+static BOOL CALLBACK
+FindAllDevs(LPGUID guid, LPCWSTR desc, LPCWSTR module, LPVOID _data)
+{
+ FindAllDevsData *data = (FindAllDevsData *) _data;
+ void *ptr;
+ char *name;
+
+ if (guid == NULL)
+ return TRUE; /* skip default device, go to the next one. */
+
+ ptr = SDL_realloc(data->devs, ((data->devcount) + 1) * sizeof(char *));
+ if (ptr == NULL)
+ return TRUE; /* oh well. */
+
+ data->devs = (const char **) ptr;
+ name = utf16_to_utf8(desc);
+ if (name != NULL)
+ data->devs[data->devcount++] = name;
+
+ return TRUE; /* keep enumerating. */
+}
+
+static char **outputDevices = NULL;
+static int outputDeviceCount = 0;
+static char **inputDevices = NULL;
+static int inputDeviceCount = 0;
+
+static int
+DSOUND_DetectDevices(int iscapture)
+{
+ FindAllDevsData data;
+ data.devs = NULL;
+ data.devcount = 0;
+
+ if (iscapture) {
+ FreeDSoundAudioDevices(&inputDevices, &inputDeviceCount);
+ pDirectSoundCaptureEnumerateW(FindAllDevs, &devs);
+ inputDevices = data.devs;
+ inputDeviceCount = data.devcount;
+ } else {
+ FreeDSoundAudioDevices(&outputDevices, &outputDeviceCount);
+ pDirectSoundEnumerateW(FindAllDevs, &devs);
+ outputDevices = data.devs;
+ outputDeviceCount = data.devcount;
+ }
+
+ return data.devcount;
+}
+
+static const char *
+DSOUND_GetDeviceName(int index, int iscapture)
+{
+ if ((iscapture) && (index < inputDeviceCount)) {
+ return inputDevices[index];
+ } else if ((!iscapture) && (index < outputDeviceCount)) {
+ return outputDevices[index];
+ }
+
+ SDL_SetError("No such device");
+ return NULL;
+}
+
+
+static void
+DSOUND_WaitDevice(_THIS)
+{
+ DWORD status = 0;
+ DWORD cursor = 0;
+ DWORD junk = 0;
+ HRESULT result = DS_OK;
+
+ /* Semi-busy wait, since we have no way of getting play notification
+ on a primary mixing buffer located in hardware (DirectX 5.0)
+ */
+ result = IDirectSoundBuffer_GetCurrentPosition(this->hidden->mixbuf,
+ &junk, &cursor);
+ if (result != DS_OK) {
+ if (result == DSERR_BUFFERLOST) {
+ IDirectSoundBuffer_Restore(this->hidden->mixbuf);
+ }
+#ifdef DEBUG_SOUND
+ SetDSerror("DirectSound GetCurrentPosition", result);
+#endif
+ return;
+ }
+
+ while ((cursor / this->hidden->mixlen) == this->hidden->lastchunk) {
+ /* FIXME: find out how much time is left and sleep that long */
+ SDL_Delay(1);
+
+ /* Try to restore a lost sound buffer */
+ IDirectSoundBuffer_GetStatus(this->hidden->mixbuf, &status);
+ if ((status & DSBSTATUS_BUFFERLOST)) {
+ IDirectSoundBuffer_Restore(this->hidden->mixbuf);
+ IDirectSoundBuffer_GetStatus(this->hidden->mixbuf, &status);
+ if ((status & DSBSTATUS_BUFFERLOST)) {
+ break;
+ }
+ }
+ if (!(status & DSBSTATUS_PLAYING)) {
+ result = IDirectSoundBuffer_Play(this->hidden->mixbuf, 0, 0,
+ DSBPLAY_LOOPING);
+ if (result == DS_OK) {
+ continue;
+ }
+#ifdef DEBUG_SOUND
+ SetDSerror("DirectSound Play", result);
+#endif
+ return;
+ }
+
+ /* Find out where we are playing */
+ result = IDirectSoundBuffer_GetCurrentPosition(this->hidden->mixbuf,
+ &junk, &cursor);
+ if (result != DS_OK) {
+ SetDSerror("DirectSound GetCurrentPosition", result);
+ return;
+ }
+ }
+}
+
+static void
+DSOUND_PlayDevice(_THIS)
+{
+ /* Unlock the buffer, allowing it to play */
+ if (this->hidden->locked_buf) {
+ IDirectSoundBuffer_Unlock(this->hidden->mixbuf,
+ this->hidden->locked_buf,
+ this->hidden->mixlen, NULL, 0);
+ }
+
+}
+
+static Uint8 *
+DSOUND_GetDeviceBuf(_THIS)
+{
+ DWORD cursor = 0;
+ DWORD junk = 0;
+ HRESULT result = DS_OK;
+ DWORD rawlen = 0;
+
+ /* Figure out which blocks to fill next */
+ this->hidden->locked_buf = NULL;
+ result = IDirectSoundBuffer_GetCurrentPosition(this->hidden->mixbuf,
+ &junk, &cursor);
+ if (result == DSERR_BUFFERLOST) {
+ IDirectSoundBuffer_Restore(this->hidden->mixbuf);
+ result = IDirectSoundBuffer_GetCurrentPosition(this->hidden->mixbuf,
+ &junk, &cursor);
+ }
+ if (result != DS_OK) {
+ SetDSerror("DirectSound GetCurrentPosition", result);
+ return (NULL);
+ }
+ cursor /= this->hidden->mixlen;
+#ifdef DEBUG_SOUND
+ /* Detect audio dropouts */
+ {
+ DWORD spot = cursor;
+ if (spot < this->hidden->lastchunk) {
+ spot += this->hidden->num_buffers;
+ }
+ if (spot > this->hidden->lastchunk + 1) {
+ fprintf(stderr, "Audio dropout, missed %d fragments\n",
+ (spot - (this->hidden->lastchunk + 1)));
+ }
+ }
+#endif
+ this->hidden->lastchunk = cursor;
+ cursor = (cursor + 1) % this->hidden->num_buffers;
+ cursor *= this->hidden->mixlen;
+
+ /* Lock the audio buffer */
+ result = IDirectSoundBuffer_Lock(this->hidden->mixbuf, cursor,
+ this->hidden->mixlen,
+ (LPVOID *) & this->hidden->locked_buf,
+ &rawlen, NULL, &junk, 0);
+ if (result == DSERR_BUFFERLOST) {
+ IDirectSoundBuffer_Restore(this->hidden->mixbuf);
+ result = IDirectSoundBuffer_Lock(this->hidden->mixbuf, cursor,
+ this->hidden->mixlen,
+ (LPVOID *) & this->
+ hidden->locked_buf, &rawlen, NULL,
+ &junk, 0);
+ }
+ if (result != DS_OK) {
+ SetDSerror("DirectSound Lock", result);
+ return (NULL);
+ }
+ return (this->hidden->locked_buf);
+}
+
+static void
+DSOUND_WaitDone(_THIS)
+{
+ Uint8 *stream = DSOUND_GetDeviceBuf(this);
+
+ /* Wait for the playing chunk to finish */
+ if (stream != NULL) {
+ SDL_memset(stream, this->spec.silence, this->hidden->mixlen);
+ DSOUND_PlayDevice(this);
+ }
+ DSOUND_WaitDevice(this);
+
+ /* Stop the looping sound buffer */
+ IDirectSoundBuffer_Stop(this->hidden->mixbuf);
+}
+
+static void
+DSOUND_CloseDevice(_THIS)
+{
+ if (this->hidden != NULL) {
+ if (this->hidden->sound != NULL) {
+ if (this->hidden->mixbuf != NULL) {
+ /* Clean up the audio buffer */
+ IDirectSoundBuffer_Release(this->hidden->mixbuf);
+ this->hidden->mixbuf = NULL;
+ }
+ IDirectSound_Release(this->hidden->sound);
+ this->hidden->sound = NULL;
+ }
+
+ SDL_free(this->hidden);
+ this->hidden = NULL;
+ }
+}
+
+/* This function tries to create a secondary audio buffer, and returns the
+ number of audio chunks available in the created buffer.
+*/
+static int
+CreateSecondary(_THIS, HWND focus, WAVEFORMATEX * wavefmt)
+{
+ LPDIRECTSOUND sndObj = this->hidden->sound;
+ LPDIRECTSOUNDBUFFER *sndbuf = &this->hidden->mixbuf;
+ Uint32 chunksize = this->spec.size;
+ const int numchunks = 8;
+ HRESULT result = DS_OK;
+ DSBUFFERDESC format;
+ LPVOID pvAudioPtr1, pvAudioPtr2;
+ DWORD dwAudioBytes1, dwAudioBytes2;
+
+ /* Try to set primary mixing privileges */
+ if (focus) {
+ result = IDirectSound_SetCooperativeLevel(sndObj,
+ focus, DSSCL_PRIORITY);
+ } else {
+ result = IDirectSound_SetCooperativeLevel(sndObj,
+ GetDesktopWindow(),
+ DSSCL_NORMAL);
+ }
+ if (result != DS_OK) {
+ SetDSerror("DirectSound SetCooperativeLevel", result);
+ return (-1);
+ }
+
+ /* Try to create the secondary buffer */
+ SDL_memset(&format, 0, sizeof(format));
+ format.dwSize = sizeof(format);
+ format.dwFlags = DSBCAPS_GETCURRENTPOSITION2;
+ if (!focus) {
+ format.dwFlags |= DSBCAPS_GLOBALFOCUS;
+ } else {
+ format.dwFlags |= DSBCAPS_STICKYFOCUS;
+ }
+ format.dwBufferBytes = numchunks * chunksize;
+ if ((format.dwBufferBytes < DSBSIZE_MIN) ||
+ (format.dwBufferBytes > DSBSIZE_MAX)) {
+ SDL_SetError("Sound buffer size must be between %d and %d",
+ DSBSIZE_MIN / numchunks, DSBSIZE_MAX / numchunks);
+ return (-1);
+ }
+ format.dwReserved = 0;
+ format.lpwfxFormat = wavefmt;
+ result = IDirectSound_CreateSoundBuffer(sndObj, &format, sndbuf, NULL);
+ if (result != DS_OK) {
+ SetDSerror("DirectSound CreateSoundBuffer", result);
+ return (-1);
+ }
+ IDirectSoundBuffer_SetFormat(*sndbuf, wavefmt);
+
+ /* Silence the initial audio buffer */
+ result = IDirectSoundBuffer_Lock(*sndbuf, 0, format.dwBufferBytes,
+ (LPVOID *) & pvAudioPtr1, &dwAudioBytes1,
+ (LPVOID *) & pvAudioPtr2, &dwAudioBytes2,
+ DSBLOCK_ENTIREBUFFER);
+ if (result == DS_OK) {
+ SDL_memset(pvAudioPtr1, this->spec.silence, dwAudioBytes1);
+ IDirectSoundBuffer_Unlock(*sndbuf,
+ (LPVOID) pvAudioPtr1, dwAudioBytes1,
+ (LPVOID) pvAudioPtr2, dwAudioBytes2);
+ }
+
+ /* We're ready to go */
+ return (numchunks);
+}
+
+typedef struct FindDevGUIDData
+{
+ const char *devname;
+ GUID guid;
+ int found;
+} FindDevGUIDData;
+
+static BOOL CALLBACK
+FindDevGUID(LPGUID guid, LPCWSTR desc, LPCWSTR module, LPVOID _data)
+{
+ if (guid != NULL) { /* skip the default device. */
+ FindDevGUIDData *data = (FindDevGUIDData *) _data;
+ char *str = utf16_to_utf8(desc);
+ const int match = (SDL_strcmp(str, data->devname) == 0);
+ SDL_free(str);
+ if (match) {
+ data->found = 1;
+ SDL_memcpy(&data->guid, guid, sizeof (data->guid));
+ return FALSE; /* found it! stop enumerating. */
+ }
+ }
+ return TRUE; /* keep enumerating. */
+}
+
+static int
+DSOUND_OpenDevice(_THIS, const char *devname, int iscapture)
+{
+ HRESULT result;
+ WAVEFORMATEX waveformat;
+ int valid_format = 0;
+ SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format);
+ FindDevGUIDData devguid;
+ LPGUID guid = NULL;
+
+ if (devname != NULL) {
+ devguid.found = 0;
+ devguid.devname = devname;
+ if (iscapture)
+ pDirectSoundCaptureEnumerateW(FindDevGUID, &devguid);
+ else
+ pDirectSoundEnumerateW(FindDevGUID, &devguid);
+
+ if (!devguid.found) {
+ SDL_SetError("DirectSound: Requested device not found");
+ return 0;
+ }
+ guid = &devguid.guid;
+ }
+
+ /* Initialize all variables that we clean on shutdown */
+ this->hidden = (struct SDL_PrivateAudioData *)
+ SDL_malloc((sizeof *this->hidden));
+ if (this->hidden == NULL) {
+ SDL_OutOfMemory();
+ return 0;
+ }
+ SDL_memset(this->hidden, 0, (sizeof *this->hidden));
+
+ while ((!valid_format) && (test_format)) {
+ switch (test_format) {
+ case AUDIO_U8:
+ case AUDIO_S16:
+ case AUDIO_S32:
+ this->spec.format = test_format;
+ valid_format = 1;
+ break;
+ }
+ test_format = SDL_NextAudioFormat();
+ }
+
+ if (!valid_format) {
+ DSOUND_CloseDevice(this);
+ SDL_SetError("DirectSound: Unsupported audio format");
+ return 0;
+ }
+
+ SDL_memset(&waveformat, 0, sizeof(waveformat));
+ waveformat.wFormatTag = WAVE_FORMAT_PCM;
+ waveformat.wBitsPerSample = SDL_AUDIO_BITSIZE(this->spec.format);
+ waveformat.nChannels = this->spec.channels;
+ waveformat.nSamplesPerSec = this->spec.freq;
+ waveformat.nBlockAlign =
+ waveformat.nChannels * (waveformat.wBitsPerSample / 8);
+ waveformat.nAvgBytesPerSec =
+ waveformat.nSamplesPerSec * waveformat.nBlockAlign;
+
+ /* Update the fragment size as size in bytes */
+ SDL_CalculateAudioSpec(&this->spec);
+
+ /* Open the audio device */
+ result = pDirectSoundCreate8(guid, &this->hidden->sound, NULL);
+ if (result != DS_OK) {
+ DSOUND_CloseDevice(this);
+ SetDSerror("DirectSoundCreate", result);
+ return 0;
+ }
+
+ /* Create the audio buffer to which we write */
+ this->hidden->num_buffers = CreateSecondary(this, mainwin, &waveformat);
+ if (this->hidden->num_buffers < 0) {
+ DSOUND_CloseDevice(this);
+ return 0;
+ }
+
+ /* The buffer will auto-start playing in DSOUND_WaitDevice() */
+ this->hidden->mixlen = this->spec.size;
+
+ return 1; /* good to go. */
+}
+
+
+static void
+DSOUND_Deinitialize(void)
+{
+ FreeDSoundAudioDevices(&inputDevices, &inputDeviceCount);
+ FreeDSoundAudioDevices(&outputDevices, &outputDeviceCount);
+ DSOUND_Unload();
+}
+
+
+static int
+DSOUND_Init(SDL_AudioDriverImpl * impl)
+{
+ if (!DSOUND_Load()) {
+ return 0;
+ }
+
+ /* Set the function pointers */
+ impl->DetectDevices = DSOUND_DetectDevices;
+ impl->GetDeviceName = DSOUND_GetDeviceName;
+ impl->OpenDevice = DSOUND_OpenDevice;
+ impl->PlayDevice = DSOUND_PlayDevice;
+ impl->WaitDevice = DSOUND_WaitDevice;
+ impl->WaitDone = DSOUND_WaitDone;
+ impl->GetDeviceBuf = DSOUND_GetDeviceBuf;
+ impl->CloseDevice = DSOUND_CloseDevice;
+ impl->Deinitialize = DSOUND_Deinitialize;
+
+ return 1; /* this audio target is available. */
+}
+
+AudioBootStrap DSOUND_bootstrap = {
+ "directsound", "DirectSound", DSOUND_Init, 0
+};
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/directsound/SDL_directsound.h Thu Aug 04 01:26:12 2011 -0400
@@ -0,0 +1,46 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+#include "SDL_config.h"
+
+#ifndef _SDL_directsound_h
+#define _SDL_directsound_h
+
+#include "directx.h"
+
+#include "../SDL_sysaudio.h"
+
+/* Hidden "this" pointer for the audio functions */
+#define _THIS SDL_AudioDevice *this
+
+/* The DirectSound objects */
+struct SDL_PrivateAudioData
+{
+ LPDIRECTSOUND sound;
+ LPDIRECTSOUNDBUFFER mixbuf;
+ int num_buffers;
+ int mixlen;
+ DWORD lastchunk;
+ Uint8 *locked_buf;
+};
+
+#endif /* _SDL_directsound_h */
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/directsound/directx.h Thu Aug 04 01:26:12 2011 -0400
@@ -0,0 +1,81 @@
+
+#ifndef _directx_h
+#define _directx_h
+
+/* Include all of the DirectX 8.0 headers and adds any necessary tweaks */
+
+#include "../../core/windows/SDL_windows.h"
+#include <mmsystem.h>
+#ifndef WIN32
+#define WIN32
+#endif
+#undef WINNT
+
+/* Far pointers don't exist in 32-bit code */
+#ifndef FAR
+#define FAR
+#endif
+
+/* Error codes not yet included in Win32 API header files */
+#ifndef MAKE_HRESULT
+#define MAKE_HRESULT(sev,fac,code) \
+ ((HRESULT)(((unsigned long)(sev)<<31) | ((unsigned long)(fac)<<16) | ((unsigned long)(code))))
+#endif
+
+#ifndef S_OK
+#define S_OK (HRESULT)0x00000000L
+#endif
+
+#ifndef SUCCEEDED
+#define SUCCEEDED(x) ((HRESULT)(x) >= 0)
+#endif
+#ifndef FAILED
+#define FAILED(x) ((HRESULT)(x)<0)
+#endif
+
+#ifndef E_FAIL
+#define E_FAIL (HRESULT)0x80000008L
+#endif
+#ifndef E_NOINTERFACE
+#define E_NOINTERFACE (HRESULT)0x80004002L
+#endif
+#ifndef E_OUTOFMEMORY
+#define E_OUTOFMEMORY (HRESULT)0x8007000EL
+#endif
+#ifndef E_INVALIDARG
+#define E_INVALIDARG (HRESULT)0x80070057L
+#endif
+#ifndef E_NOTIMPL
+#define E_NOTIMPL (HRESULT)0x80004001L
+#endif
+#ifndef REGDB_E_CLASSNOTREG
+#define REGDB_E_CLASSNOTREG (HRESULT)0x80040154L
+#endif
+
+/* Severity codes */
+#ifndef SEVERITY_ERROR
+#define SEVERITY_ERROR 1
+#endif
+
+/* Error facility codes */
+#ifndef FACILITY_WIN32
+#define FACILITY_WIN32 7
+#endif
+
+#ifndef FIELD_OFFSET
+#define FIELD_OFFSET(type, field) ((LONG)&(((type *)0)->field))
+#endif
+
+/* DirectX headers (if it isn't included, I haven't tested it yet)
+ */
+/* We need these defines to mark what version of DirectX API we use */
+#define DIRECTDRAW_VERSION 0x0700
+#define DIRECTSOUND_VERSION 0x0800
+#define DIRECTINPUT_VERSION 0x0500
+
+#include <ddraw.h>
+#include <dsound.h>
+#include <dinput.h>
+
+#endif /* _directx_h */
+/* vi: set ts=4 sw=4 expandtab: */
--- a/src/audio/windx5/SDL_dx5audio.c Sun Jul 24 03:37:13 2011 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,517 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "SDL_config.h"
-
-/* Allow access to a raw mixing buffer */
-
-#include "SDL_timer.h"
-#include "SDL_loadso.h"
-#include "SDL_audio.h"
-#include "../SDL_audio_c.h"
-#include "SDL_dx5audio.h"
-
-/* !!! FIXME: move this somewhere that other drivers can use it... */
-#if defined(_WIN32_WCE)
-#define WINDOWS_OS_NAME "Windows CE/PocketPC"
-#elif defined(WIN64)
-#define WINDOWS_OS_NAME "Win64"
-#else
-#define WINDOWS_OS_NAME "Win32"
-#endif
-
-/* DirectX function pointers for audio */
-static void* DSoundDLL = NULL;
-static HRESULT(WINAPI * DSoundCreate) (LPGUID, LPDIRECTSOUND *, LPUNKNOWN) =
- NULL;
-
-static void
-DSOUND_Unload(void)
-{
- DSoundCreate = NULL;
-
- if (DSoundDLL != NULL) {
- SDL_UnloadObject(DSoundDLL);
- DSoundDLL = NULL;
- }
-}
-
-
-static int
-DSOUND_Load(void)
-{
- int loaded = 0;
-
- DSOUND_Unload();
-
- DSoundDLL = SDL_LoadObject("DSOUND.DLL");
- if (DSoundDLL == NULL) {
- SDL_SetError("DirectSound: failed to load DSOUND.DLL");
- } else {
- /* Now make sure we have DirectX 5 or better... */
- /* (DirectSoundCaptureCreate was added in DX5) */
- if (!SDL_LoadFunction(DSoundDLL, "DirectSoundCaptureCreate")) {
- SDL_SetError("DirectSound: System doesn't appear to have DX5.");
- } else {
- DSoundCreate = SDL_LoadFunction(DSoundDLL, "DirectSoundCreate");
- }
-
- if (!DSoundCreate) {
- SDL_SetError("DirectSound: Failed to find DirectSoundCreate");
- } else {
- loaded = 1;
- }
- }
-
- if (!loaded) {
- DSOUND_Unload();
- }
-
- return loaded;
-}
-
-
-static void
-SetDSerror(const char *function, int code)
-{
- static const char *error;
- static char errbuf[1024];
-
- errbuf[0] = 0;
- switch (code) {
- case E_NOINTERFACE:
- error = "Unsupported interface -- Is DirectX 5.0 or later installed?";
- break;
- case DSERR_ALLOCATED:
- error = "Audio device in use";
- break;
- case DSERR_BADFORMAT:
- error = "Unsupported audio format";
- break;
- case DSERR_BUFFERLOST:
- error = "Mixing buffer was lost";
- break;
- case DSERR_CONTROLUNAVAIL:
- error = "Control requested is not available";
- break;
- case DSERR_INVALIDCALL:
- error = "Invalid call for the current state";
- break;
- case DSERR_INVALIDPARAM:
- error = "Invalid parameter";
- break;
- case DSERR_NODRIVER:
- error = "No audio device found";
- break;
- case DSERR_OUTOFMEMORY:
- error = "Out of memory";
- break;
- case DSERR_PRIOLEVELNEEDED:
- error = "Caller doesn't have priority";
- break;
- case DSERR_UNSUPPORTED:
- error = "Function not supported";
- break;
- default:
- SDL_snprintf(errbuf, SDL_arraysize(errbuf),
- "%s: Unknown DirectSound error: 0x%x", function, code);
- break;
- }
- if (!errbuf[0]) {
- SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: %s", function,
- error);
- }
- SDL_SetError("%s", errbuf);
- return;
-}
-
-/* DirectSound needs to be associated with a window */
-static HWND mainwin = NULL;
-/* */
-
-void
-DSOUND_SoundFocus(HWND hwnd)
-{
- /* !!! FIXME: probably broken with multi-window support in SDL 1.3 ... */
- mainwin = hwnd;
-}
-
-static void
-DSOUND_ThreadInit(_THIS)
-{
- SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST);
-}
-
-static void
-DSOUND_WaitDevice(_THIS)
-{
- DWORD status = 0;
- DWORD cursor = 0;
- DWORD junk = 0;
- HRESULT result = DS_OK;
-
- /* Semi-busy wait, since we have no way of getting play notification
- on a primary mixing buffer located in hardware (DirectX 5.0)
- */
- result = IDirectSoundBuffer_GetCurrentPosition(this->hidden->mixbuf,
- &junk, &cursor);
- if (result != DS_OK) {
- if (result == DSERR_BUFFERLOST) {
- IDirectSoundBuffer_Restore(this->hidden->mixbuf);
- }
-#ifdef DEBUG_SOUND
- SetDSerror("DirectSound GetCurrentPosition", result);
-#endif
- return;
- }
-
- while ((cursor / this->hidden->mixlen) == this->hidden->lastchunk) {
- /* FIXME: find out how much time is left and sleep that long */
- SDL_Delay(1);
-
- /* Try to restore a lost sound buffer */
- IDirectSoundBuffer_GetStatus(this->hidden->mixbuf, &status);
- if ((status & DSBSTATUS_BUFFERLOST)) {
- IDirectSoundBuffer_Restore(this->hidden->mixbuf);
- IDirectSoundBuffer_GetStatus(this->hidden->mixbuf, &status);
- if ((status & DSBSTATUS_BUFFERLOST)) {
- break;
- }
- }
- if (!(status & DSBSTATUS_PLAYING)) {
- result = IDirectSoundBuffer_Play(this->hidden->mixbuf, 0, 0,
- DSBPLAY_LOOPING);
- if (result == DS_OK) {
- continue;
- }
-#ifdef DEBUG_SOUND
- SetDSerror("DirectSound Play", result);
-#endif
- return;
- }
-
- /* Find out where we are playing */
- result = IDirectSoundBuffer_GetCurrentPosition(this->hidden->mixbuf,
- &junk, &cursor);
- if (result != DS_OK) {
- SetDSerror("DirectSound GetCurrentPosition", result);
- return;
- }
- }
-}
-
-static void
-DSOUND_PlayDevice(_THIS)
-{
- /* Unlock the buffer, allowing it to play */
- if (this->hidden->locked_buf) {
- IDirectSoundBuffer_Unlock(this->hidden->mixbuf,
- this->hidden->locked_buf,
- this->hidden->mixlen, NULL, 0);
- }
-
-}
-
-static Uint8 *
-DSOUND_GetDeviceBuf(_THIS)
-{
- DWORD cursor = 0;
- DWORD junk = 0;
- HRESULT result = DS_OK;
- DWORD rawlen = 0;
-
- /* Figure out which blocks to fill next */
- this->hidden->locked_buf = NULL;
- result = IDirectSoundBuffer_GetCurrentPosition(this->hidden->mixbuf,
- &junk, &cursor);
- if (result == DSERR_BUFFERLOST) {
- IDirectSoundBuffer_Restore(this->hidden->mixbuf);
- result = IDirectSoundBuffer_GetCurrentPosition(this->hidden->mixbuf,
- &junk, &cursor);
- }
- if (result != DS_OK) {
- SetDSerror("DirectSound GetCurrentPosition", result);
- return (NULL);
- }
- cursor /= this->hidden->mixlen;
-#ifdef DEBUG_SOUND
- /* Detect audio dropouts */
- {
- DWORD spot = cursor;
- if (spot < this->hidden->lastchunk) {
- spot += this->hidden->num_buffers;
- }
- if (spot > this->hidden->lastchunk + 1) {
- fprintf(stderr, "Audio dropout, missed %d fragments\n",
- (spot - (this->hidden->lastchunk + 1)));
- }
- }
-#endif
- this->hidden->lastchunk = cursor;
- cursor = (cursor + 1) % this->hidden->num_buffers;
- cursor *= this->hidden->mixlen;
-
- /* Lock the audio buffer */
- result = IDirectSoundBuffer_Lock(this->hidden->mixbuf, cursor,
- this->hidden->mixlen,
- (LPVOID *) & this->hidden->locked_buf,
- &rawlen, NULL, &junk, 0);
- if (result == DSERR_BUFFERLOST) {
- IDirectSoundBuffer_Restore(this->hidden->mixbuf);
- result = IDirectSoundBuffer_Lock(this->hidden->mixbuf, cursor,
- this->hidden->mixlen,
- (LPVOID *) & this->
- hidden->locked_buf, &rawlen, NULL,
- &junk, 0);
- }
- if (result != DS_OK) {
- SetDSerror("DirectSound Lock", result);
- return (NULL);
- }
- return (this->hidden->locked_buf);
-}
-
-static void
-DSOUND_WaitDone(_THIS)
-{
- Uint8 *stream = DSOUND_GetDeviceBuf(this);
-
- /* Wait for the playing chunk to finish */
- if (stream != NULL) {
- SDL_memset(stream, this->spec.silence, this->hidden->mixlen);
- DSOUND_PlayDevice(this);
- }
- DSOUND_WaitDevice(this);
-
- /* Stop the looping sound buffer */
- IDirectSoundBuffer_Stop(this->hidden->mixbuf);
-}
-
-static void
-DSOUND_CloseDevice(_THIS)
-{
- if (this->hidden != NULL) {
- if (this->hidden->sound != NULL) {
- if (this->hidden->mixbuf != NULL) {
- /* Clean up the audio buffer */
- IDirectSoundBuffer_Release(this->hidden->mixbuf);
- this->hidden->mixbuf = NULL;
- }
- IDirectSound_Release(this->hidden->sound);
- this->hidden->sound = NULL;
- }
-
- SDL_free(this->hidden);
- this->hidden = NULL;
- }
-}
-
-/* This function tries to create a secondary audio buffer, and returns the
- number of audio chunks available in the created buffer.
-*/
-static int
-CreateSecondary(_THIS, HWND focus, WAVEFORMATEX * wavefmt)
-{
- LPDIRECTSOUND sndObj = this->hidden->sound;
- LPDIRECTSOUNDBUFFER *sndbuf = &this->hidden->mixbuf;
- Uint32 chunksize = this->spec.size;
- const int numchunks = 8;
- HRESULT result = DS_OK;
- DSBUFFERDESC format;
- LPVOID pvAudioPtr1, pvAudioPtr2;
- DWORD dwAudioBytes1, dwAudioBytes2;
-
- /* Try to set primary mixing privileges */
- if (focus) {
- result = IDirectSound_SetCooperativeLevel(sndObj,
- focus, DSSCL_PRIORITY);
- } else {
- result = IDirectSound_SetCooperativeLevel(sndObj,
- GetDesktopWindow(),
- DSSCL_NORMAL);
- }
- if (result != DS_OK) {
- SetDSerror("DirectSound SetCooperativeLevel", result);
- return (-1);
- }
-
- /* Try to create the secondary buffer */
- SDL_memset(&format, 0, sizeof(format));
- format.dwSize = sizeof(format);
- format.dwFlags = DSBCAPS_GETCURRENTPOSITION2;
- if (!focus) {
- format.dwFlags |= DSBCAPS_GLOBALFOCUS;
- } else {
- format.dwFlags |= DSBCAPS_STICKYFOCUS;
- }
- format.dwBufferBytes = numchunks * chunksize;
- if ((format.dwBufferBytes < DSBSIZE_MIN) ||
- (format.dwBufferBytes > DSBSIZE_MAX)) {
- SDL_SetError("Sound buffer size must be between %d and %d",
- DSBSIZE_MIN / numchunks, DSBSIZE_MAX / numchunks);
- return (-1);
- }
- format.dwReserved = 0;
- format.lpwfxFormat = wavefmt;
- result = IDirectSound_CreateSoundBuffer(sndObj, &format, sndbuf, NULL);
- if (result != DS_OK) {
- SetDSerror("DirectSound CreateSoundBuffer", result);
- return (-1);
- }
- IDirectSoundBuffer_SetFormat(*sndbuf, wavefmt);
-
- /* Silence the initial audio buffer */
- result = IDirectSoundBuffer_Lock(*sndbuf, 0, format.dwBufferBytes,
- (LPVOID *) & pvAudioPtr1, &dwAudioBytes1,
- (LPVOID *) & pvAudioPtr2, &dwAudioBytes2,
- DSBLOCK_ENTIREBUFFER);
- if (result == DS_OK) {
- SDL_memset(pvAudioPtr1, this->spec.silence, dwAudioBytes1);
- IDirectSoundBuffer_Unlock(*sndbuf,
- (LPVOID) pvAudioPtr1, dwAudioBytes1,
- (LPVOID) pvAudioPtr2, dwAudioBytes2);
- }
-
- /* We're ready to go */
- return (numchunks);
-}
-
-static int
-DSOUND_OpenDevice(_THIS, const char *devname, int iscapture)
-{
- HRESULT result;
- WAVEFORMATEX waveformat;
- int valid_format = 0;
- SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format);
-
- /* !!! FIXME: handle devname */
- /* !!! FIXME: handle iscapture */
-
- /* Initialize all variables that we clean on shutdown */
- this->hidden = (struct SDL_PrivateAudioData *)
- SDL_malloc((sizeof *this->hidden));
- if (this->hidden == NULL) {
- SDL_OutOfMemory();
- return 0;
- }
- SDL_memset(this->hidden, 0, (sizeof *this->hidden));
-
- while ((!valid_format) && (test_format)) {
- switch (test_format) {
- case AUDIO_U8:
- case AUDIO_S16:
- case AUDIO_S32:
- this->spec.format = test_format;
- valid_format = 1;
- break;
- }
- test_format = SDL_NextAudioFormat();
- }
-
- if (!valid_format) {
- DSOUND_CloseDevice(this);
- SDL_SetError("DirectSound: Unsupported audio format");
- return 0;
- }
-
- SDL_memset(&waveformat, 0, sizeof(waveformat));
- waveformat.wFormatTag = WAVE_FORMAT_PCM;
- waveformat.wBitsPerSample = SDL_AUDIO_BITSIZE(this->spec.format);
- waveformat.nChannels = this->spec.channels;
- waveformat.nSamplesPerSec = this->spec.freq;
- waveformat.nBlockAlign =
- waveformat.nChannels * (waveformat.wBitsPerSample / 8);
- waveformat.nAvgBytesPerSec =
- waveformat.nSamplesPerSec * waveformat.nBlockAlign;
-
- /* Update the fragment size as size in bytes */
- SDL_CalculateAudioSpec(&this->spec);
-
- /* Open the audio device */
- result = DSoundCreate(NULL, &this->hidden->sound, NULL);
- if (result != DS_OK) {
- DSOUND_CloseDevice(this);
- SetDSerror("DirectSoundCreate", result);
- return 0;
- }
-
- /* Create the audio buffer to which we write */
- this->hidden->num_buffers = CreateSecondary(this, mainwin, &waveformat);
- if (this->hidden->num_buffers < 0) {
- DSOUND_CloseDevice(this);
- return 0;
- }
-
- /* The buffer will auto-start playing in DSOUND_WaitDevice() */
- this->hidden->mixlen = this->spec.size;
-
- return 1; /* good to go. */
-}
-
-
-static void
-DSOUND_Deinitialize(void)
-{
- DSOUND_Unload();
-}
-
-
-static int
-DSOUND_Init(SDL_AudioDriverImpl * impl)
-{
- OSVERSIONINFO ver;
-
- /*
- * Unfortunately, the sound drivers on NT have higher latencies than the
- * audio buffers used by many SDL applications, so there are gaps in the
- * audio - it sounds terrible. Punt for now.
- */
- SDL_memset(&ver, '\0', sizeof(OSVERSIONINFO));
- ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
- GetVersionEx(&ver);
- if (ver.dwPlatformId == VER_PLATFORM_WIN32_NT) {
- if (ver.dwMajorVersion <= 4) {
- return 0; /* NT4.0 or earlier. Disable dsound support. */
- }
- }
-
- if (!DSOUND_Load()) {
- return 0;
- }
-
- /* Set the function pointers */
- impl->OpenDevice = DSOUND_OpenDevice;
- impl->PlayDevice = DSOUND_PlayDevice;
- impl->WaitDevice = DSOUND_WaitDevice;
- impl->WaitDone = DSOUND_WaitDone;
- impl->ThreadInit = DSOUND_ThreadInit;
- impl->GetDeviceBuf = DSOUND_GetDeviceBuf;
- impl->CloseDevice = DSOUND_CloseDevice;
- impl->Deinitialize = DSOUND_Deinitialize;
- impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME */
-
- return 1; /* this audio target is available. */
-}
-
-AudioBootStrap DSOUND_bootstrap = {
- "dsound", WINDOWS_OS_NAME "DirectSound", DSOUND_Init, 0
-};
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/audio/windx5/SDL_dx5audio.h Sun Jul 24 03:37:13 2011 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "SDL_config.h"
-
-#ifndef _SDL_dx5audio_h
-#define _SDL_dx5audio_h
-
-#include "directx.h"
-
-#include "../SDL_sysaudio.h"
-
-/* Hidden "this" pointer for the audio functions */
-#define _THIS SDL_AudioDevice *this
-
-/* The DirectSound objects */
-struct SDL_PrivateAudioData
-{
- LPDIRECTSOUND sound;
- LPDIRECTSOUNDBUFFER mixbuf;
- int num_buffers;
- int mixlen;
- DWORD lastchunk;
- Uint8 *locked_buf;
-};
-
-#endif /* _SDL_dx5audio_h */
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/audio/windx5/directx.h Sun Jul 24 03:37:13 2011 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-
-#ifndef _directx_h
-#define _directx_h
-
-/* Include all of the DirectX 5.0 headers and adds any necessary tweaks */
-
-#include "../../core/windows/SDL_windows.h"
-#include <mmsystem.h>
-#ifndef WIN32
-#define WIN32
-#endif
-#undef WINNT
-
-/* Far pointers don't exist in 32-bit code */
-#ifndef FAR
-#define FAR
-#endif
-
-/* Error codes not yet included in Win32 API header files */
-#ifndef MAKE_HRESULT
-#define MAKE_HRESULT(sev,fac,code) \
- ((HRESULT)(((unsigned long)(sev)<<31) | ((unsigned long)(fac)<<16) | ((unsigned long)(code))))
-#endif
-
-#ifndef S_OK
-#define S_OK (HRESULT)0x00000000L
-#endif
-
-#ifndef SUCCEEDED
-#define SUCCEEDED(x) ((HRESULT)(x) >= 0)
-#endif
-#ifndef FAILED
-#define FAILED(x) ((HRESULT)(x)<0)
-#endif
-
-#ifndef E_FAIL
-#define E_FAIL (HRESULT)0x80000008L
-#endif
-#ifndef E_NOINTERFACE
-#define E_NOINTERFACE (HRESULT)0x80004002L
-#endif
-#ifndef E_OUTOFMEMORY
-#define E_OUTOFMEMORY (HRESULT)0x8007000EL
-#endif
-#ifndef E_INVALIDARG
-#define E_INVALIDARG (HRESULT)0x80070057L
-#endif
-#ifndef E_NOTIMPL
-#define E_NOTIMPL (HRESULT)0x80004001L
-#endif
-#ifndef REGDB_E_CLASSNOTREG
-#define REGDB_E_CLASSNOTREG (HRESULT)0x80040154L
-#endif
-
-/* Severity codes */
-#ifndef SEVERITY_ERROR
-#define SEVERITY_ERROR 1
-#endif
-
-/* Error facility codes */
-#ifndef FACILITY_WIN32
-#define FACILITY_WIN32 7
-#endif
-
-#ifndef FIELD_OFFSET
-#define FIELD_OFFSET(type, field) ((LONG)&(((type *)0)->field))
-#endif
-
-/* DirectX headers (if it isn't included, I haven't tested it yet)
- */
-/* We need these defines to mark what version of DirectX API we use */
-#define DIRECTDRAW_VERSION 0x0700
-#define DIRECTSOUND_VERSION 0x0500
-#define DIRECTINPUT_VERSION 0x0500
-
-#include <ddraw.h>
-#include <dsound.h>
-#include <dinput.h>
-
-#endif /* _directx_h */
-/* vi: set ts=4 sw=4 expandtab: */