Make sure XAudio2 is supported by the DirectX headers at compile time.
authorRyan C. Gordon
Sun, 21 Aug 2011 02:35:13 -0400
changeset 56155e060b67c73d
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
     1.1 --- a/src/audio/xaudio2/SDL_xaudio2.c	Thu Aug 18 22:43:37 2011 +0200
     1.2 +++ b/src/audio/xaudio2/SDL_xaudio2.c	Sun Aug 21 02:35:13 2011 -0400
     1.3 @@ -27,6 +27,8 @@
     1.4  #define INITGUID 1
     1.5  #include "SDL_xaudio2.h"
     1.6  
     1.7 +#if SDL_HAVE_XAUDIO2_H
     1.8 +
     1.9  static __inline__ char *
    1.10  utf16_to_utf8(const WCHAR *S)
    1.11  {
    1.12 @@ -370,9 +372,15 @@
    1.13      WIN_CoUninitialize();
    1.14  }
    1.15  
    1.16 +#endif  /* SDL_HAVE_XAUDIO2_H */
    1.17 +
    1.18 +
    1.19  static int
    1.20  XAUDIO2_Init(SDL_AudioDriverImpl * impl)
    1.21  {
    1.22 +#if !SDL_HAVE_XAUDIO2_H
    1.23 +    return 0;  /* no XAudio2 support, ever. Update your SDK! */
    1.24 +#else
    1.25      /* XAudio2Create() is a macro that uses COM; we don't load the .dll */
    1.26      IXAudio2 *ixa2 = NULL;
    1.27      if (FAILED(WIN_CoInitialize())) {
    1.28 @@ -398,6 +406,7 @@
    1.29      impl->Deinitialize = XAUDIO2_Deinitialize;
    1.30  
    1.31      return 1;   /* this audio target is available. */
    1.32 +#endif
    1.33  }
    1.34  
    1.35  AudioBootStrap XAUDIO2_bootstrap = {
     2.1 --- a/src/audio/xaudio2/SDL_xaudio2.h	Thu Aug 18 22:43:37 2011 +0200
     2.2 +++ b/src/audio/xaudio2/SDL_xaudio2.h	Sun Aug 21 02:35:13 2011 -0400
     2.3 @@ -25,6 +25,15 @@
     2.4  
     2.5  #include "../SDL_sysaudio.h"
     2.6  
     2.7 +/* XAudio2 is available as of the March 2008 DirectX SDK */
     2.8 +#include <dxsdkver.h>
     2.9 +#if (defined(_DXSDK_BUILD_MAJOR) && (_DXSDK_BUILD_MAJOR >= 1284))
    2.10 +#   define SDL_HAVE_XAUDIO2_H 1
    2.11 +#else
    2.12 +#   define SDL_HAVE_XAUDIO2_H 0
    2.13 +#endif
    2.14 +
    2.15 +#if SDL_HAVE_XAUDIO2_H
    2.16  #include <XAudio2.h>
    2.17  
    2.18  /* Hidden "this" pointer for the audio functions */
    2.19 @@ -40,6 +49,7 @@
    2.20      int mixlen;
    2.21      Uint8 *nextbuf;
    2.22  };
    2.23 +#endif
    2.24  
    2.25  #endif /* _SDL_xaudio2_h */
    2.26