#include "quakedef.h"
#include "snd_main.h"
+#ifdef SUPPORTDIRECTX
#ifndef DIRECTSOUND_VERSION
# define DIRECTSOUND_VERSION 0x0500 /* Version 5.0 */
#endif
+#endif
#include <windows.h>
#include <mmsystem.h>
+#ifdef SUPPORTDIRECTX
#include <dsound.h>
+#endif
// ==============================================================================
extern HWND mainwindow;
+#ifdef SUPPORTDIRECTX
HRESULT (WINAPI *pDirectSoundCreate)(GUID FAR *lpGUID, LPDIRECTSOUND FAR *lplpDS, IUnknown FAR *pUnkOuter);
+#endif
// Wave output: 64KB in 64 buffers of 1KB
// (64KB is > 1 sec at 16-bit 22050 Hz mono, and is 1/3 sec at 16-bit 44100 Hz stereo)
typedef enum sndinitstat_e {SIS_SUCCESS, SIS_FAILURE, SIS_NOTAVAIL} sndinitstat;
+#ifdef SUPPORTDIRECTX
static qboolean dsound_init;
-static qboolean wav_init;
+static unsigned int dsound_time;
static qboolean primary_format_set;
+#endif
+
+static qboolean wav_init;
static int snd_sent, snd_completed;
static int prev_painted;
static unsigned int paintpot;
-static unsigned int dsound_time;
/*
DWORD dwStartTime;
+#ifdef SUPPORTDIRECTX
LPDIRECTSOUND pDS;
LPDIRECTSOUNDBUFFER pDSBuf, pDSPBuf;
HINSTANCE hInstDS;
+#endif
qboolean SNDDMA_InitWav (void);
+#ifdef SUPPORTDIRECTX
sndinitstat SNDDMA_InitDirect (void);
+#endif
/*
}
+#ifdef SUPPORTDIRECTX
/*
==================
SndSys_InitDirectSound
return SIS_SUCCESS;
}
+#endif
/*
*/
qboolean SndSys_Init (const snd_format_t* requested, snd_format_t* suggested)
{
+#ifdef SUPPORTDIRECTX
qboolean wavonly;
+#endif
sndinitstat stat;
Con_Print ("SndSys_Init: using the Win32 module\n");
+#ifdef SUPPORTDIRECTX
// COMMANDLINEOPTION: Windows Sound: -wavonly uses wave sound instead of DirectSound
wavonly = (COM_CheckParm ("-wavonly") != 0);
dsound_init = false;
+#endif
wav_init = false;
stat = SIS_FAILURE; // assume DirectSound won't initialize
+#ifdef SUPPORTDIRECTX
// Init DirectSound
if (!wavonly)
{
else
Con_Print("DirectSound failed to init\n");
}
+#endif
// if DirectSound didn't succeed in initializing, try to initialize
// waveOut sound, unless DirectSound failed because the hardware is
// already allocated (in which case the user has already chosen not
// to have sound)
+#ifdef SUPPORTDIRECTX
if (!dsound_init && (stat != SIS_NOTAVAIL))
+#endif
{
if (SndSys_InitMmsystem (requested))
Con_Print("Wave sound (MMSYSTEM) initialized\n");
Con_Print("Wave sound failed to init\n");
}
+#ifdef SUPPORTDIRECTX
return (dsound_init || wav_init);
+#else
+ return wav_init;
+#endif
}
*/
void SndSys_Shutdown (void)
{
+#ifdef SUPPORTDIRECTX
if (pDSBuf)
{
IDirectSoundBuffer_Stop(pDSBuf);
IDirectSound_SetCooperativeLevel (pDS, mainwindow, DSSCL_NORMAL);
IDirectSound_Release(pDS);
}
+#endif
if (hWaveOut)
{
snd_renderbuffer = NULL;
}
+#ifdef SUPPORTDIRECTX
pDS = NULL;
pDSBuf = NULL;
pDSPBuf = NULL;
+ dsound_init = false;
+#endif
hWaveOut = 0;
hData = 0;
hWaveHdr = 0;
lpData = NULL;
lpWaveHdr = NULL;
- dsound_init = false;
wav_init = false;
}
factor = snd_renderbuffer->format.width * snd_renderbuffer->format.channels;
+#ifdef SUPPORTDIRECTX
if (dsound_init)
{
DWORD dwTime;
dsound_time += diff / factor;
return dsound_time;
}
+#endif
if (wav_init)
{
}
+#ifdef SUPPORTDIRECTX
static DWORD dsound_dwSize;
static DWORD dsound_dwSize2;
static DWORD *dsound_pbuf;
static DWORD *dsound_pbuf2;
+#endif
/*
====================
*/
qboolean SndSys_LockRenderBuffer (void)
{
+#ifdef SUPPORTDIRECTX
int reps;
HRESULT hresult;
DWORD dwStatus;
Sys_Error("SndSys_LockRenderBuffer: the ring address has changed!!!\n");
return true;
}
+#endif
return wav_init;
}
*/
void SndSys_UnlockRenderBuffer (void)
{
+#ifdef SUPPORTDIRECTX
if (pDSBuf)
IDirectSoundBuffer_Unlock(pDSBuf, dsound_pbuf, dsound_dwSize, dsound_pbuf2, dsound_dwSize2);
+#endif
}