Make sure XAudio2 is supported by the DirectX headers at compile time.
authorRyan C. Gordon <icculus@icculus.org>
Sun, 21 Aug 2011 02:35:13 -0400
changeset 5615 5e060b67c73d
parent 5614 50bf98210aae
child 5622 08e941dad8e9
Make sure XAudio2 is supported by the DirectX headers at compile time.
src/audio/xaudio2/SDL_xaudio2.c
src/audio/xaudio2/SDL_xaudio2.h
--- a/src/audio/xaudio2/SDL_xaudio2.c	Thu Aug 18 22:43:37 2011 +0200
+++ b/src/audio/xaudio2/SDL_xaudio2.c	Sun Aug 21 02:35:13 2011 -0400
@@ -27,6 +27,8 @@
 #define INITGUID 1
 #include "SDL_xaudio2.h"
 
+#if SDL_HAVE_XAUDIO2_H
+
 static __inline__ char *
 utf16_to_utf8(const WCHAR *S)
 {
@@ -370,9 +372,15 @@
     WIN_CoUninitialize();
 }
 
+#endif  /* SDL_HAVE_XAUDIO2_H */
+
+
 static int
 XAUDIO2_Init(SDL_AudioDriverImpl * impl)
 {
+#if !SDL_HAVE_XAUDIO2_H
+    return 0;  /* no XAudio2 support, ever. Update your SDK! */
+#else
     /* XAudio2Create() is a macro that uses COM; we don't load the .dll */
     IXAudio2 *ixa2 = NULL;
     if (FAILED(WIN_CoInitialize())) {
@@ -398,6 +406,7 @@
     impl->Deinitialize = XAUDIO2_Deinitialize;
 
     return 1;   /* this audio target is available. */
+#endif
 }
 
 AudioBootStrap XAUDIO2_bootstrap = {
--- a/src/audio/xaudio2/SDL_xaudio2.h	Thu Aug 18 22:43:37 2011 +0200
+++ b/src/audio/xaudio2/SDL_xaudio2.h	Sun Aug 21 02:35:13 2011 -0400
@@ -25,6 +25,15 @@
 
 #include "../SDL_sysaudio.h"
 
+/* XAudio2 is available as of the March 2008 DirectX SDK */
+#include <dxsdkver.h>
+#if (defined(_DXSDK_BUILD_MAJOR) && (_DXSDK_BUILD_MAJOR >= 1284))
+#   define SDL_HAVE_XAUDIO2_H 1
+#else
+#   define SDL_HAVE_XAUDIO2_H 0
+#endif
+
+#if SDL_HAVE_XAUDIO2_H
 #include <XAudio2.h>
 
 /* Hidden "this" pointer for the audio functions */
@@ -40,6 +49,7 @@
     int mixlen;
     Uint8 *nextbuf;
 };
+#endif
 
 #endif /* _SDL_xaudio2_h */