Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Make sure XAudio2 is supported by the DirectX headers at compile time.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Aug 21, 2011
1 parent 5e2fe8b commit b48b60e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/audio/xaudio2/SDL_xaudio2.c
Expand Up @@ -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)
{
Expand Down Expand Up @@ -370,9 +372,15 @@ XAUDIO2_Deinitialize(void)
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())) {
Expand All @@ -398,6 +406,7 @@ XAUDIO2_Init(SDL_AudioDriverImpl * impl)
impl->Deinitialize = XAUDIO2_Deinitialize;

return 1; /* this audio target is available. */
#endif
}

AudioBootStrap XAUDIO2_bootstrap = {
Expand Down
10 changes: 10 additions & 0 deletions src/audio/xaudio2/SDL_xaudio2.h
Expand Up @@ -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 */
Expand All @@ -40,6 +49,7 @@ struct SDL_PrivateAudioData
int mixlen;
Uint8 *nextbuf;
};
#endif

#endif /* _SDL_xaudio2_h */

Expand Down

0 comments on commit b48b60e

Please sign in to comment.