WinRT: removed chunks of C++ hack code from SDL_xaudio2.c

This commit is contained in:
David Ludwig 2013-09-06 19:23:42 -04:00
parent fff780818d
commit 9de76eb526
1 changed files with 9 additions and 49 deletions

View File

@ -49,17 +49,11 @@
#if SDL_AUDIO_DRIVER_XAUDIO2 #if SDL_AUDIO_DRIVER_XAUDIO2
#ifdef __cplusplus
extern "C" {
#endif
#include "../../core/windows/SDL_windows.h" #include "../../core/windows/SDL_windows.h"
#include "SDL_audio.h" #include "SDL_audio.h"
#include "../SDL_audio_c.h" #include "../SDL_audio_c.h"
#include "../SDL_sysaudio.h" #include "../SDL_sysaudio.h"
#include "SDL_assert.h" #include "SDL_assert.h"
#ifdef __cplusplus
}
#endif
#ifdef __GNUC__ #ifdef __GNUC__
/* The configure script already did any necessary checking */ /* The configure script already did any necessary checking */
@ -81,7 +75,7 @@ extern "C" {
/* Check to see if we're compiling for XAudio 2.8, or higher. */ /* Check to see if we're compiling for XAudio 2.8, or higher. */
#ifdef WINVER #ifdef WINVER
#if WINVER >= 0x0602 /* Windows 8 SDK or higher? */ #if WINVER >= 0x0602 /* Windows 8 SDK or higher? */
#define SDL_XAUDIO2_2_8 1 #define SDL_XAUDIO2_WIN8 1
#endif #endif
#endif #endif
@ -171,33 +165,6 @@ static void STDMETHODCALLTYPE VoiceCBOnVoiceProcessPassEnd(THIS) {}
static void STDMETHODCALLTYPE VoiceCBOnBufferStart(THIS_ void *data) {} static void STDMETHODCALLTYPE VoiceCBOnBufferStart(THIS_ void *data) {}
static void STDMETHODCALLTYPE VoiceCBOnLoopEnd(THIS_ void *data) {} static void STDMETHODCALLTYPE VoiceCBOnLoopEnd(THIS_ void *data) {}
#if defined(__cplusplus)
class SDL_XAudio2VoiceCallback : public IXAudio2VoiceCallback
{
public:
STDMETHOD_(void, OnBufferEnd)(void *pBufferContext) {
VoiceCBOnBufferEnd(pBufferContext);
}
STDMETHOD_(void, OnBufferStart)(void *pBufferContext) {
VoiceCBOnBufferStart(pBufferContext);
}
STDMETHOD_(void, OnLoopEnd)(void *pBufferContext) {
VoiceCBOnLoopEnd(pBufferContext);
}
STDMETHOD_(void, OnStreamEnd)() {
VoiceCBOnStreamEnd();
}
STDMETHOD_(void, OnVoiceError)(void *pBufferContext, HRESULT Error) {
VoiceCBOnVoiceError(pBufferContext, Error);
}
STDMETHOD_(void, OnVoiceProcessingPassEnd)() {
VoiceCBOnVoiceProcessPassEnd();
}
STDMETHOD_(void, OnVoiceProcessingPassStart)(UINT32 BytesRequired) {
VoiceCBOnVoiceProcessPassStart(BytesRequired);
}
};
#endif
static Uint8 * static Uint8 *
XAUDIO2_GetDeviceBuf(_THIS) XAUDIO2_GetDeviceBuf(_THIS)
@ -258,14 +225,14 @@ XAUDIO2_WaitDone(_THIS)
XAUDIO2_VOICE_STATE state; XAUDIO2_VOICE_STATE state;
SDL_assert(!this->enabled); /* flag that stops playing. */ SDL_assert(!this->enabled); /* flag that stops playing. */
IXAudio2SourceVoice_Discontinuity(source); IXAudio2SourceVoice_Discontinuity(source);
#if SDL_XAUDIO2_2_8 #if SDL_XAUDIO2_WIN8
IXAudio2SourceVoice_GetState(source, &state, 0); IXAudio2SourceVoice_GetState(source, &state, 0);
#else #else
IXAudio2SourceVoice_GetState(source, &state); IXAudio2SourceVoice_GetState(source, &state);
#endif #endif
while (state.BuffersQueued > 0) { while (state.BuffersQueued > 0) {
SDL_SemWait(this->hidden->semaphore); SDL_SemWait(this->hidden->semaphore);
#if SDL_XAUDIO2_2_8 #if SDL_XAUDIO2_WIN8
IXAudio2SourceVoice_GetState(source, &state, 0); IXAudio2SourceVoice_GetState(source, &state, 0);
#else #else
IXAudio2SourceVoice_GetState(source, &state); IXAudio2SourceVoice_GetState(source, &state);
@ -317,15 +284,12 @@ XAUDIO2_OpenDevice(_THIS, const char *devname, int iscapture)
SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format); SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format);
IXAudio2 *ixa2 = NULL; IXAudio2 *ixa2 = NULL;
IXAudio2SourceVoice *source = NULL; IXAudio2SourceVoice *source = NULL;
#if defined(__WINRT__) #if defined(SDL_XAUDIO2_WIN8)
LPCWSTR devId = 0; LPCWSTR devId = NULL;
#else #else
UINT32 devId = 0; /* 0 == system default device. */ UINT32 devId = 0; /* 0 == system default device. */
#endif #endif
#if defined(__cplusplus)
static SDL_XAudio2VoiceCallback callbacks;
#else
static IXAudio2VoiceCallbackVtbl callbacks_vtable = { static IXAudio2VoiceCallbackVtbl callbacks_vtable = {
VoiceCBOnVoiceProcessPassStart, VoiceCBOnVoiceProcessPassStart,
VoiceCBOnVoiceProcessPassEnd, VoiceCBOnVoiceProcessPassEnd,
@ -337,7 +301,6 @@ XAUDIO2_OpenDevice(_THIS, const char *devname, int iscapture)
}; };
static IXAudio2VoiceCallback callbacks = { &callbacks_vtable }; static IXAudio2VoiceCallback callbacks = { &callbacks_vtable };
#endif // ! defined(__cplusplus)
if (iscapture) { if (iscapture) {
return SDL_SetError("XAudio2: capture devices unsupported."); return SDL_SetError("XAudio2: capture devices unsupported.");
@ -440,7 +403,7 @@ XAUDIO2_OpenDevice(_THIS, const char *devname, int iscapture)
stereo output to appropriate surround sound configurations stereo output to appropriate surround sound configurations
instead of clamping to 2 channels, even though we'll configure the instead of clamping to 2 channels, even though we'll configure the
Source Voice for whatever number of channels you supply. */ Source Voice for whatever number of channels you supply. */
#if SDL_XAUDIO2_2_8 #if SDL_XAUDIO2_WIN8
result = IXAudio2_CreateMasteringVoice(ixa2, &this->hidden->mastering, result = IXAudio2_CreateMasteringVoice(ixa2, &this->hidden->mastering,
XAUDIO2_DEFAULT_CHANNELS, XAUDIO2_DEFAULT_CHANNELS,
this->spec.freq, 0, devId, NULL, AudioCategory_GameEffects); this->spec.freq, 0, devId, NULL, AudioCategory_GameEffects);
@ -557,9 +520,6 @@ XAUDIO2_Init(SDL_AudioDriverImpl * impl)
#endif #endif
} }
#if defined(__cplusplus)
extern "C"
#endif
AudioBootStrap XAUDIO2_bootstrap = { AudioBootStrap XAUDIO2_bootstrap = {
"xaudio2", "XAudio2", XAUDIO2_Init, 0 "xaudio2", "XAudio2", XAUDIO2_Init, 0
}; };