mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-29 07:32:02 +00:00
[win] Fix a pile of bitrot
Man, those bits rot quickly. Must be stored with a rotfish.
This commit is contained in:
parent
c636f7413d
commit
6db6f8f0e2
7 changed files with 170 additions and 161 deletions
|
@ -56,7 +56,6 @@ static qboolean snd_firsttime = true;
|
||||||
static qboolean primary_format_set;
|
static qboolean primary_format_set;
|
||||||
|
|
||||||
static int sample16;
|
static int sample16;
|
||||||
static volatile dma_t sn;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Global variables. Must be visible to window-procedure function
|
Global variables. Must be visible to window-procedure function
|
||||||
|
@ -82,21 +81,13 @@ static LPDIRECTSOUNDBUFFER pDSBuf, pDSPBuf;
|
||||||
|
|
||||||
static HINSTANCE hInstDS;
|
static HINSTANCE hInstDS;
|
||||||
|
|
||||||
static sndinitstat SNDDMA_InitDirect (void);
|
static sndinitstat SNDDMA_InitDirect (snd_t *snd);
|
||||||
|
|
||||||
static cvar_t *snd_stereo;
|
static cvar_t *snd_stereo;
|
||||||
static cvar_t *snd_rate;
|
static cvar_t *snd_rate;
|
||||||
static cvar_t *snd_bits;
|
static cvar_t *snd_bits;
|
||||||
|
|
||||||
static plugin_t plugin_info;
|
static DWORD *DSOUND_LockBuffer (snd_t *snd, qboolean lockit);
|
||||||
static plugin_data_t plugin_info_data;
|
|
||||||
static plugin_funcs_t plugin_info_funcs;
|
|
||||||
static general_data_t plugin_info_general_data;
|
|
||||||
static general_funcs_t plugin_info_general_funcs;
|
|
||||||
static snd_output_data_t plugin_info_snd_output_data;
|
|
||||||
static snd_output_funcs_t plugin_info_snd_output_funcs;
|
|
||||||
|
|
||||||
static DWORD *DSOUND_LockBuffer (qboolean lockit);
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
SNDDMA_Init_Cvars (void)
|
SNDDMA_Init_Cvars (void)
|
||||||
|
@ -110,12 +101,12 @@ SNDDMA_Init_Cvars (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
SNDDMA_BlockSound (void)
|
SNDDMA_BlockSound (snd_t *snd)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
SNDDMA_UnblockSound (void)
|
SNDDMA_UnblockSound (snd_t *snd)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,7 +142,7 @@ FreeSound (void)
|
||||||
Direct-Sound support
|
Direct-Sound support
|
||||||
*/
|
*/
|
||||||
static sndinitstat
|
static sndinitstat
|
||||||
SNDDMA_InitDirect (void)
|
SNDDMA_InitDirect (snd_t *snd)
|
||||||
{
|
{
|
||||||
int reps;
|
int reps;
|
||||||
DSBUFFERDESC dsbuf;
|
DSBUFFERDESC dsbuf;
|
||||||
|
@ -161,22 +152,20 @@ SNDDMA_InitDirect (void)
|
||||||
HRESULT hresult;
|
HRESULT hresult;
|
||||||
WAVEFORMATEX format, pformat;
|
WAVEFORMATEX format, pformat;
|
||||||
|
|
||||||
memset ((void *) &sn, 0, sizeof (sn));
|
|
||||||
|
|
||||||
if (!snd_stereo->int_val) {
|
if (!snd_stereo->int_val) {
|
||||||
sn.channels = 1;
|
snd->channels = 1;
|
||||||
} else {
|
} else {
|
||||||
sn.channels = 2;
|
snd->channels = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
sn.samplebits = snd_bits->int_val;
|
snd->samplebits = snd_bits->int_val;
|
||||||
sn.speed = snd_rate->int_val;
|
snd->speed = snd_rate->int_val;
|
||||||
|
|
||||||
memset (&format, 0, sizeof (format));
|
memset (&format, 0, sizeof (format));
|
||||||
format.wFormatTag = WAVE_FORMAT_PCM;
|
format.wFormatTag = WAVE_FORMAT_PCM;
|
||||||
format.nChannels = sn.channels;
|
format.nChannels = snd->channels;
|
||||||
format.wBitsPerSample = sn.samplebits;
|
format.wBitsPerSample = snd->samplebits;
|
||||||
format.nSamplesPerSec = sn.speed;
|
format.nSamplesPerSec = snd->speed;
|
||||||
format.nBlockAlign = format.nChannels * format.wBitsPerSample / 8;
|
format.nBlockAlign = format.nChannels * format.wBitsPerSample / 8;
|
||||||
format.cbSize = 0;
|
format.cbSize = 0;
|
||||||
format.nAvgBytesPerSec = format.nSamplesPerSec * format.nBlockAlign;
|
format.nAvgBytesPerSec = format.nSamplesPerSec * format.nBlockAlign;
|
||||||
|
@ -267,9 +256,9 @@ SNDDMA_InitDirect (void)
|
||||||
return SIS_FAILURE;
|
return SIS_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
sn.channels = format.nChannels;
|
snd->channels = format.nChannels;
|
||||||
sn.samplebits = format.wBitsPerSample;
|
snd->samplebits = format.wBitsPerSample;
|
||||||
sn.speed = format.nSamplesPerSec;
|
snd->speed = format.nSamplesPerSec;
|
||||||
|
|
||||||
if (DS_OK != IDirectSound_GetCaps (pDSBuf, &dsbcaps)) {
|
if (DS_OK != IDirectSound_GetCaps (pDSBuf, &dsbcaps)) {
|
||||||
Sys_Printf ("DS:GetCaps failed\n");
|
Sys_Printf ("DS:GetCaps failed\n");
|
||||||
|
@ -331,11 +320,11 @@ SNDDMA_InitDirect (void)
|
||||||
&dwWrite);
|
&dwWrite);
|
||||||
IDirectSoundBuffer_Play (pDSBuf, 0, 0, DSBPLAY_LOOPING);
|
IDirectSoundBuffer_Play (pDSBuf, 0, 0, DSBPLAY_LOOPING);
|
||||||
|
|
||||||
sn.frames = gSndBufSize / (sn.samplebits / 8) / sn.channels;
|
snd->frames = gSndBufSize / (snd->samplebits / 8) / snd->channels;
|
||||||
sn.framepos = 0;
|
snd->framepos = 0;
|
||||||
sn.submission_chunk = 1;
|
snd->submission_chunk = 1;
|
||||||
sn.buffer = (byte *) lpData;
|
snd->buffer = (byte *) lpData;
|
||||||
sample16 = (sn.samplebits / 8) - 1;
|
sample16 = (snd->samplebits / 8) - 1;
|
||||||
|
|
||||||
dsound_init = true;
|
dsound_init = true;
|
||||||
|
|
||||||
|
@ -349,10 +338,11 @@ SNDDMA_InitDirect (void)
|
||||||
Try to find a sound device to mix for.
|
Try to find a sound device to mix for.
|
||||||
Returns false if nothing is found.
|
Returns false if nothing is found.
|
||||||
*/
|
*/
|
||||||
static volatile dma_t *
|
static int
|
||||||
SNDDMA_Init (void)
|
SNDDMA_Init (snd_t *snd)
|
||||||
{
|
{
|
||||||
sndinitstat stat;
|
sndinitstat stat;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
stat = SIS_FAILURE; // assume DirectSound won't
|
stat = SIS_FAILURE; // assume DirectSound won't
|
||||||
// initialize
|
// initialize
|
||||||
|
@ -360,17 +350,16 @@ SNDDMA_Init (void)
|
||||||
/* Init DirectSound */
|
/* Init DirectSound */
|
||||||
if (snd_firsttime) {
|
if (snd_firsttime) {
|
||||||
snd_firsttime = false;
|
snd_firsttime = false;
|
||||||
stat = SNDDMA_InitDirect ();
|
stat = SNDDMA_InitDirect (snd);
|
||||||
|
|
||||||
if (stat == SIS_SUCCESS) {
|
if ((ret = (stat == SIS_SUCCESS))) {
|
||||||
Sys_Printf ("DirectSound initialized\n");
|
Sys_Printf ("DirectSound initialized\n");
|
||||||
} else {
|
} else {
|
||||||
Sys_Printf ("DirectSound failed to init\n");
|
Sys_Printf ("DirectSound failed to init\n");
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return &sn;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -381,31 +370,31 @@ SNDDMA_Init (void)
|
||||||
how many sample are required to fill it up.
|
how many sample are required to fill it up.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
SNDDMA_GetDMAPos (void)
|
SNDDMA_GetDMAPos (snd_t *snd)
|
||||||
{
|
{
|
||||||
int s = 0;
|
int s = 0;
|
||||||
DWORD dwWrite;
|
DWORD dwWrite;
|
||||||
MMTIME mmtime;
|
MMTIME mmtime;
|
||||||
unsigned long *pbuf;
|
unsigned long *pbuf;
|
||||||
|
|
||||||
pbuf = DSOUND_LockBuffer (true);
|
pbuf = DSOUND_LockBuffer (snd, true);
|
||||||
if (!pbuf) {
|
if (!pbuf) {
|
||||||
Sys_Printf ("DSOUND_LockBuffer fails!\n");
|
Sys_Printf ("DSOUND_LockBuffer fails!\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
sn.buffer = (unsigned char *) pbuf;
|
snd->buffer = (unsigned char *) pbuf;
|
||||||
mmtime.wType = TIME_SAMPLES;
|
mmtime.wType = TIME_SAMPLES;
|
||||||
IDirectSoundBuffer_GetCurrentPosition (pDSBuf, &mmtime.u.sample,
|
IDirectSoundBuffer_GetCurrentPosition (pDSBuf, &mmtime.u.sample,
|
||||||
&dwWrite);
|
&dwWrite);
|
||||||
s = mmtime.u.sample - mmstarttime.u.sample;
|
s = mmtime.u.sample - mmstarttime.u.sample;
|
||||||
|
|
||||||
s >>= sample16;
|
s >>= sample16;
|
||||||
s /= sn.channels;
|
s /= snd->channels;
|
||||||
|
|
||||||
s %= sn.frames;
|
s %= snd->frames;
|
||||||
sn.framepos = s;
|
snd->framepos = s;
|
||||||
|
|
||||||
return sn.framepos;
|
return snd->framepos;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -414,19 +403,19 @@ SNDDMA_GetDMAPos (void)
|
||||||
Send sound to device if buffer isn't really the dma buffer
|
Send sound to device if buffer isn't really the dma buffer
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
SNDDMA_Submit (void)
|
SNDDMA_Submit (snd_t *snd)
|
||||||
{
|
{
|
||||||
DSOUND_LockBuffer (false);
|
DSOUND_LockBuffer (snd, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
SNDDMA_shutdown (void)
|
SNDDMA_shutdown (snd_t *snd)
|
||||||
{
|
{
|
||||||
FreeSound ();
|
FreeSound ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static DWORD *
|
static DWORD *
|
||||||
DSOUND_LockBuffer (qboolean lockit)
|
DSOUND_LockBuffer (snd_t *snd, qboolean lockit)
|
||||||
{
|
{
|
||||||
int reps;
|
int reps;
|
||||||
|
|
||||||
|
@ -447,16 +436,16 @@ DSOUND_LockBuffer (qboolean lockit)
|
||||||
if (hresult != DSERR_BUFFERLOST) {
|
if (hresult != DSERR_BUFFERLOST) {
|
||||||
Sys_Printf
|
Sys_Printf
|
||||||
("S_TransferStereo16: DS::Lock Sound Buffer Failed\n");
|
("S_TransferStereo16: DS::Lock Sound Buffer Failed\n");
|
||||||
SNDDMA_shutdown ();
|
SNDDMA_shutdown (snd);
|
||||||
SNDDMA_Init ();
|
SNDDMA_Init (snd);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (++reps > 10000) {
|
if (++reps > 10000) {
|
||||||
Sys_Printf
|
Sys_Printf
|
||||||
("S_TransferStereo16: DS: couldn't restore buffer\n");
|
("S_TransferStereo16: DS: couldn't restore buffer\n");
|
||||||
SNDDMA_shutdown ();
|
SNDDMA_shutdown (snd);
|
||||||
SNDDMA_Init ();
|
SNDDMA_Init (snd);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -471,14 +460,14 @@ DSOUND_LockBuffer (qboolean lockit)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __attribute__((used)) //FIXME make it true
|
static void __attribute__((used)) //FIXME make it true
|
||||||
DSOUND_ClearBuffer (int clear)
|
DSOUND_ClearBuffer (snd_t *snd, int clear)
|
||||||
{
|
{
|
||||||
DWORD *pData;
|
DWORD *pData;
|
||||||
|
|
||||||
// FIXME: this should be called with 2nd pbuf2 = NULL, dwsize =0
|
// FIXME: this should be called with 2nd pbuf2 = NULL, dwsize =0
|
||||||
pData = DSOUND_LockBuffer (true);
|
pData = DSOUND_LockBuffer (snd, true);
|
||||||
memset (pData, clear, sn.frames * sn.channels * sn.samplebits / 8);
|
memset (pData, clear, snd->frames * snd->channels * snd->samplebits / 8);
|
||||||
DSOUND_LockBuffer (false);
|
DSOUND_LockBuffer (snd, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __attribute__((used)) //FIXME make it true
|
static void __attribute__((used)) //FIXME make it true
|
||||||
|
@ -502,35 +491,49 @@ DSOUND_Restore (void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static snd_output_data_t plugin_info_snd_output_data = {
|
||||||
|
};
|
||||||
|
|
||||||
|
static snd_output_funcs_t plugin_info_snd_output_funcs = {
|
||||||
|
.init = SNDDMA_Init,
|
||||||
|
.shutdown = SNDDMA_shutdown,
|
||||||
|
.get_dma_pos = SNDDMA_GetDMAPos,
|
||||||
|
.submit = SNDDMA_Submit,
|
||||||
|
.block_sound = SNDDMA_BlockSound,
|
||||||
|
.unblock_sound = SNDDMA_UnblockSound,
|
||||||
|
};
|
||||||
|
|
||||||
|
static general_data_t plugin_info_general_data = {
|
||||||
|
};
|
||||||
|
|
||||||
|
static general_funcs_t plugin_info_general_funcs = {
|
||||||
|
.init = SNDDMA_Init_Cvars,
|
||||||
|
};
|
||||||
|
|
||||||
|
static plugin_data_t plugin_info_data = {
|
||||||
|
.general = &plugin_info_general_data,
|
||||||
|
.snd_output = &plugin_info_snd_output_data,
|
||||||
|
};
|
||||||
|
|
||||||
|
static plugin_funcs_t plugin_info_funcs = {
|
||||||
|
.general = &plugin_info_general_funcs,
|
||||||
|
.snd_output = &plugin_info_snd_output_funcs,
|
||||||
|
};
|
||||||
|
|
||||||
|
static plugin_t plugin_info = {
|
||||||
|
.type = qfp_snd_output,
|
||||||
|
.api_version = QFPLUGIN_VERSION,
|
||||||
|
.plugin_version = "0.1",
|
||||||
|
.description = "Windows DirectX output",
|
||||||
|
.copyright = "Copyright (C) 1996-1997 id Software, Inc.\n"
|
||||||
|
"Copyright (C) 1999,2000,2001,2002,2003 contributors of the "
|
||||||
|
"QuakeForge project\n"
|
||||||
|
"Please see the file \"AUTHORS\" for a list of contributors",
|
||||||
|
.functions = &plugin_info_funcs,
|
||||||
|
.data = &plugin_info_data,
|
||||||
|
};
|
||||||
|
|
||||||
PLUGIN_INFO(snd_output, dx)
|
PLUGIN_INFO(snd_output, dx)
|
||||||
{
|
{
|
||||||
plugin_info.type = qfp_snd_output;
|
|
||||||
plugin_info.api_version = QFPLUGIN_VERSION;
|
|
||||||
plugin_info.plugin_version = "0.1";
|
|
||||||
plugin_info.description = "Windows DirectX output";
|
|
||||||
plugin_info.copyright = "Copyright (C) 1996-1997 id Software, Inc.\n"
|
|
||||||
"Copyright (C) 1999,2000,2001,2002,2003 contributors of the QuakeForge "
|
|
||||||
"project\n"
|
|
||||||
"Please see the file \"AUTHORS\" for a list of contributors";
|
|
||||||
plugin_info.functions = &plugin_info_funcs;
|
|
||||||
plugin_info.data = &plugin_info_data;
|
|
||||||
|
|
||||||
plugin_info_data.general = &plugin_info_general_data;
|
|
||||||
plugin_info_data.input = NULL;
|
|
||||||
plugin_info_data.snd_output = &plugin_info_snd_output_data;
|
|
||||||
|
|
||||||
plugin_info_funcs.general = &plugin_info_general_funcs;
|
|
||||||
plugin_info_funcs.input = NULL;
|
|
||||||
plugin_info_funcs.snd_output = &plugin_info_snd_output_funcs;
|
|
||||||
|
|
||||||
plugin_info_general_funcs.p_Init = SNDDMA_Init_Cvars;
|
|
||||||
plugin_info_general_funcs.p_Shutdown = NULL;
|
|
||||||
plugin_info_snd_output_funcs.pS_O_Init = SNDDMA_Init;
|
|
||||||
plugin_info_snd_output_funcs.pS_O_Shutdown = SNDDMA_shutdown;
|
|
||||||
plugin_info_snd_output_funcs.pS_O_GetDMAPos = SNDDMA_GetDMAPos;
|
|
||||||
plugin_info_snd_output_funcs.pS_O_Submit = SNDDMA_Submit;
|
|
||||||
plugin_info_snd_output_funcs.pS_O_BlockSound = SNDDMA_BlockSound;
|
|
||||||
plugin_info_snd_output_funcs.pS_O_UnblockSound = SNDDMA_UnblockSound;
|
|
||||||
|
|
||||||
return &plugin_info;
|
return &plugin_info;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,6 @@ static qboolean snd_firsttime = true;
|
||||||
static int sample16;
|
static int sample16;
|
||||||
static int snd_sent, snd_completed;
|
static int snd_sent, snd_completed;
|
||||||
static int snd_blocked = 0;
|
static int snd_blocked = 0;
|
||||||
static volatile dma_t sn;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Global variables. Must be visible to window-procedure function
|
Global variables. Must be visible to window-procedure function
|
||||||
|
@ -69,20 +68,12 @@ static HWAVEOUT hWaveOut;
|
||||||
|
|
||||||
static DWORD gSndBufSize;
|
static DWORD gSndBufSize;
|
||||||
|
|
||||||
static qboolean SNDDMA_InitWav (void);
|
static qboolean SNDDMA_InitWav (snd_t *snd);
|
||||||
|
|
||||||
static cvar_t *snd_stereo;
|
static cvar_t *snd_stereo;
|
||||||
static cvar_t *snd_rate;
|
static cvar_t *snd_rate;
|
||||||
static cvar_t *snd_bits;
|
static cvar_t *snd_bits;
|
||||||
|
|
||||||
static plugin_t plugin_info;
|
|
||||||
static plugin_data_t plugin_info_data;
|
|
||||||
static plugin_funcs_t plugin_info_funcs;
|
|
||||||
static general_data_t plugin_info_general_data;
|
|
||||||
static general_funcs_t plugin_info_general_funcs;
|
|
||||||
static snd_output_data_t plugin_info_snd_output_data;
|
|
||||||
static snd_output_funcs_t plugin_info_snd_output_funcs;
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
SNDDMA_Init_Cvars (void)
|
SNDDMA_Init_Cvars (void)
|
||||||
|
@ -96,14 +87,14 @@ SNDDMA_Init_Cvars (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
SNDDMA_BlockSound (void)
|
SNDDMA_BlockSound (snd_t *snd)
|
||||||
{
|
{
|
||||||
if (++snd_blocked == 1)
|
if (++snd_blocked == 1)
|
||||||
waveOutReset (hWaveOut);
|
waveOutReset (hWaveOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
SNDDMA_UnblockSound (void)
|
SNDDMA_UnblockSound (snd_t *snd)
|
||||||
{
|
{
|
||||||
if (snd_blocked)
|
if (snd_blocked)
|
||||||
--snd_blocked;
|
--snd_blocked;
|
||||||
|
@ -150,7 +141,7 @@ FreeSound (void)
|
||||||
Crappy windows multimedia base
|
Crappy windows multimedia base
|
||||||
*/
|
*/
|
||||||
static qboolean
|
static qboolean
|
||||||
SNDDMA_InitWav (void)
|
SNDDMA_InitWav (snd_t *snd)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
@ -160,19 +151,19 @@ SNDDMA_InitWav (void)
|
||||||
snd_completed = 0;
|
snd_completed = 0;
|
||||||
|
|
||||||
if (!snd_stereo->int_val) {
|
if (!snd_stereo->int_val) {
|
||||||
sn.channels = 1;
|
snd->channels = 1;
|
||||||
} else {
|
} else {
|
||||||
sn.channels = 2;
|
snd->channels = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
sn.samplebits = snd_bits->int_val;
|
snd->samplebits = snd_bits->int_val;
|
||||||
sn.speed = snd_rate->int_val;
|
snd->speed = snd_rate->int_val;
|
||||||
|
|
||||||
memset (&format, 0, sizeof (format));
|
memset (&format, 0, sizeof (format));
|
||||||
format.wFormatTag = WAVE_FORMAT_PCM;
|
format.wFormatTag = WAVE_FORMAT_PCM;
|
||||||
format.nChannels = sn.channels;
|
format.nChannels = snd->channels;
|
||||||
format.wBitsPerSample = sn.samplebits;
|
format.wBitsPerSample = snd->samplebits;
|
||||||
format.nSamplesPerSec = sn.speed;
|
format.nSamplesPerSec = snd->speed;
|
||||||
format.nBlockAlign = format.nChannels * format.wBitsPerSample / 8;
|
format.nBlockAlign = format.nChannels * format.wBitsPerSample / 8;
|
||||||
format.cbSize = 0;
|
format.cbSize = 0;
|
||||||
format.nAvgBytesPerSec = format.nSamplesPerSec * format.nBlockAlign;
|
format.nAvgBytesPerSec = format.nSamplesPerSec * format.nBlockAlign;
|
||||||
|
@ -246,11 +237,11 @@ SNDDMA_InitWav (void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sn.frames = gSndBufSize / (sn.samplebits / 8) / sn.channels;
|
snd->frames = gSndBufSize / (snd->samplebits / 8) / snd->channels;
|
||||||
sn.framepos = 0;
|
snd->framepos = 0;
|
||||||
sn.submission_chunk = 1;
|
snd->submission_chunk = 1;
|
||||||
sn.buffer = (unsigned char *) lpData;
|
snd->buffer = (unsigned char *) lpData;
|
||||||
sample16 = (sn.samplebits / 8) - 1;
|
sample16 = (snd->samplebits / 8) - 1;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -261,11 +252,12 @@ SNDDMA_InitWav (void)
|
||||||
Try to find a sound device to mix for.
|
Try to find a sound device to mix for.
|
||||||
Returns false if nothing is found.
|
Returns false if nothing is found.
|
||||||
*/
|
*/
|
||||||
static volatile dma_t *
|
static int
|
||||||
SNDDMA_Init (void)
|
SNDDMA_Init (snd_t *snd)
|
||||||
{
|
{
|
||||||
|
int ret = 0;
|
||||||
if (snd_firsttime) {
|
if (snd_firsttime) {
|
||||||
if (SNDDMA_InitWav ()) {
|
if ((ret = SNDDMA_InitWav (snd))) {
|
||||||
Sys_Printf ("Wave sound initialized\n");
|
Sys_Printf ("Wave sound initialized\n");
|
||||||
} else {
|
} else {
|
||||||
Sys_Printf ("Wave sound failed to init\n");
|
Sys_Printf ("Wave sound failed to init\n");
|
||||||
|
@ -273,7 +265,7 @@ SNDDMA_Init (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
snd_firsttime = false;
|
snd_firsttime = false;
|
||||||
return &sn;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -284,19 +276,19 @@ SNDDMA_Init (void)
|
||||||
how many sample are required to fill it up.
|
how many sample are required to fill it up.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
SNDDMA_GetDMAPos (void)
|
SNDDMA_GetDMAPos (snd_t *snd)
|
||||||
{
|
{
|
||||||
int s = 0;
|
int s = 0;
|
||||||
|
|
||||||
s = snd_sent * WAV_BUFFER_SIZE;
|
s = snd_sent * WAV_BUFFER_SIZE;
|
||||||
|
|
||||||
s >>= sample16;
|
s >>= sample16;
|
||||||
s /= sn.channels;
|
s /= snd->channels;
|
||||||
|
|
||||||
s %= sn.frames;
|
s %= snd->frames;
|
||||||
sn.framepos = s;
|
snd->framepos = s;
|
||||||
|
|
||||||
return sn.framepos;
|
return snd->framepos;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -305,7 +297,7 @@ SNDDMA_GetDMAPos (void)
|
||||||
Send sound to device if buffer isn't really the dma buffer
|
Send sound to device if buffer isn't really the dma buffer
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
SNDDMA_Submit (void)
|
SNDDMA_Submit (snd_t *snd)
|
||||||
{
|
{
|
||||||
int wResult;
|
int wResult;
|
||||||
LPWAVEHDR h;
|
LPWAVEHDR h;
|
||||||
|
@ -345,40 +337,54 @@ SNDDMA_Submit (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
SNDDMA_shutdown (void)
|
SNDDMA_shutdown (snd_t *snd)
|
||||||
{
|
{
|
||||||
FreeSound ();
|
FreeSound ();
|
||||||
}
|
}
|
||||||
|
|
||||||
PLUGIN_INFO(snd_output, win)
|
static snd_output_data_t plugin_info_snd_output_data = {
|
||||||
{
|
};
|
||||||
plugin_info.type = qfp_snd_output;
|
|
||||||
plugin_info.api_version = QFPLUGIN_VERSION;
|
static snd_output_funcs_t plugin_info_snd_output_funcs = {
|
||||||
plugin_info.plugin_version = "0.1";
|
.init = SNDDMA_Init,
|
||||||
plugin_info.description = "Windows digital output";
|
.shutdown = SNDDMA_shutdown,
|
||||||
plugin_info.copyright = "Copyright (C) 1996-1997 id Software, Inc.\n"
|
.get_dma_pos = SNDDMA_GetDMAPos,
|
||||||
|
.submit = SNDDMA_Submit,
|
||||||
|
.block_sound = SNDDMA_BlockSound,
|
||||||
|
.unblock_sound = SNDDMA_UnblockSound,
|
||||||
|
};
|
||||||
|
|
||||||
|
static general_data_t plugin_info_general_data = {
|
||||||
|
};
|
||||||
|
|
||||||
|
static general_funcs_t plugin_info_general_funcs = {
|
||||||
|
.init = SNDDMA_Init_Cvars,
|
||||||
|
};
|
||||||
|
|
||||||
|
static plugin_data_t plugin_info_data = {
|
||||||
|
.general = &plugin_info_general_data,
|
||||||
|
.snd_output = &plugin_info_snd_output_data,
|
||||||
|
};
|
||||||
|
|
||||||
|
static plugin_funcs_t plugin_info_funcs = {
|
||||||
|
.general = &plugin_info_general_funcs,
|
||||||
|
.snd_output = &plugin_info_snd_output_funcs,
|
||||||
|
};
|
||||||
|
|
||||||
|
static plugin_t plugin_info = {
|
||||||
|
.type = qfp_snd_output,
|
||||||
|
.api_version = QFPLUGIN_VERSION,
|
||||||
|
.plugin_version = "0.1",
|
||||||
|
.description = "Windows digital output",
|
||||||
|
.copyright = "Copyright (C) 1996-1997 id Software, Inc.\n"
|
||||||
"Copyright (C) 1999,2000,2001 contributors of the QuakeForge "
|
"Copyright (C) 1999,2000,2001 contributors of the QuakeForge "
|
||||||
"project\n"
|
"project\n"
|
||||||
"Please see the file \"AUTHORS\" for a list of contributors";
|
"Please see the file \"AUTHORS\" for a list of contributors",
|
||||||
plugin_info.functions = &plugin_info_funcs;
|
.functions = &plugin_info_funcs,
|
||||||
plugin_info.data = &plugin_info_data;
|
.data = &plugin_info_data,
|
||||||
|
};
|
||||||
plugin_info_data.general = &plugin_info_general_data;
|
|
||||||
plugin_info_data.input = NULL;
|
|
||||||
plugin_info_data.snd_output = &plugin_info_snd_output_data;
|
|
||||||
|
|
||||||
plugin_info_funcs.general = &plugin_info_general_funcs;
|
|
||||||
plugin_info_funcs.input = NULL;
|
|
||||||
plugin_info_funcs.snd_output = &plugin_info_snd_output_funcs;
|
|
||||||
|
|
||||||
plugin_info_general_funcs.p_Init = SNDDMA_Init_Cvars;
|
|
||||||
plugin_info_general_funcs.p_Shutdown = NULL;
|
|
||||||
plugin_info_snd_output_funcs.pS_O_Init = SNDDMA_Init;
|
|
||||||
plugin_info_snd_output_funcs.pS_O_Shutdown = SNDDMA_shutdown;
|
|
||||||
plugin_info_snd_output_funcs.pS_O_GetDMAPos = SNDDMA_GetDMAPos;
|
|
||||||
plugin_info_snd_output_funcs.pS_O_Submit = SNDDMA_Submit;
|
|
||||||
plugin_info_snd_output_funcs.pS_O_BlockSound = SNDDMA_BlockSound;
|
|
||||||
plugin_info_snd_output_funcs.pS_O_UnblockSound = SNDDMA_UnblockSound;
|
|
||||||
|
|
||||||
|
PLUGIN_INFO(snd_output, win)
|
||||||
|
{
|
||||||
return &plugin_info;
|
return &plugin_info;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
# include "winquake.h"
|
# include "winquake.h"
|
||||||
HWND mainwindow;
|
HWND win_mainwindow;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MEMSIZE (32 * 1024 * 1024)
|
#define MEMSIZE (32 * 1024 * 1024)
|
||||||
|
|
|
@ -71,7 +71,7 @@ D_BeginDirectRect (int x, int y, byte *pbitmap, int width, int height)
|
||||||
rect.height = height << repshift;
|
rect.height = height << repshift;
|
||||||
rect.next = NULL;
|
rect.next = NULL;
|
||||||
|
|
||||||
win_sw_context->update (&rect);
|
win_sw_context->update (win_sw_context, &rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ D_EndDirectRect (int x, int y, int width, int height)
|
||||||
rect.height = height << repshift;
|
rect.height = height << repshift;
|
||||||
rect.next = NULL;
|
rect.next = NULL;
|
||||||
|
|
||||||
win_sw_context->update (&rect);
|
win_sw_context->update (win_sw_context, &rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -130,13 +130,13 @@ VID_Init (byte *palette, byte *colormap)
|
||||||
|
|
||||||
VID_GetWindowSize (640, 480);
|
VID_GetWindowSize (640, 480);
|
||||||
Win_OpenDisplay ();
|
Win_OpenDisplay ();
|
||||||
vid_internal.choose_visual ();
|
vid_internal.choose_visual (win_sw_context);
|
||||||
Win_SetVidMode (viddef.width, viddef.height);
|
Win_SetVidMode (viddef.width, viddef.height);
|
||||||
Win_CreateWindow (viddef.width, viddef.height);
|
Win_CreateWindow (viddef.width, viddef.height);
|
||||||
vid_internal.create_context ();
|
vid_internal.create_context (win_sw_context);
|
||||||
|
|
||||||
VID_InitGamma (palette);
|
VID_InitGamma (palette);
|
||||||
viddef.vid_internal->set_palette (palette);
|
viddef.vid_internal->set_palette (win_sw_context, palette);
|
||||||
|
|
||||||
Sys_MaskPrintf (SYS_vid, "Video mode %dx%d initialized.\n",
|
Sys_MaskPrintf (SYS_vid, "Video mode %dx%d initialized.\n",
|
||||||
viddef.width, viddef.height);
|
viddef.width, viddef.height);
|
||||||
|
|
|
@ -228,7 +228,7 @@ VID_CreateGDIDriver (int width, int height, const byte *palette, void **buffer,
|
||||||
|
|
||||||
// create a palette
|
// create a palette
|
||||||
VID_InitGamma (palette);
|
VID_InitGamma (palette);
|
||||||
viddef.vid_internal->set_palette (palette);
|
viddef.vid_internal->set_palette (viddef.vid_internal->data, palette);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -308,7 +308,7 @@ Win_CreateDriver (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
win_init_bufers (void)
|
win_init_bufers (void *data)
|
||||||
{
|
{
|
||||||
Win_UnloadAllDrivers ();
|
Win_UnloadAllDrivers ();
|
||||||
Win_CreateDriver ();
|
Win_CreateDriver ();
|
||||||
|
@ -323,7 +323,7 @@ win_init_bufers (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
win_set_palette (const byte *palette)
|
win_set_palette (sw_ctx_t *ctx, const byte *palette)
|
||||||
{
|
{
|
||||||
palette_changed = 1;
|
palette_changed = 1;
|
||||||
if (palette != current_palette) {
|
if (palette != current_palette) {
|
||||||
|
@ -410,7 +410,7 @@ dd_blit_rect (vrect_t *rect)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
win_sw_update (vrect_t *rects)
|
win_sw_update (sw_ctx_t *ctx, vrect_t *rects)
|
||||||
{
|
{
|
||||||
vrect_t full_rect;
|
vrect_t full_rect;
|
||||||
if (!win_palettized && palette_changed) {
|
if (!win_palettized && palette_changed) {
|
||||||
|
|
|
@ -6,7 +6,7 @@ if test -d native; then
|
||||||
cd ../i686-w64-mingw32.static
|
cd ../i686-w64-mingw32.static
|
||||||
ln -fs ../native/qfcc .
|
ln -fs ../native/qfcc .
|
||||||
ln -fs ../native/pak .
|
ln -fs ../native/pak .
|
||||||
ln -fs ../native/ruamoko/qwaq/qwaq-curses .
|
ln -fs ../native/ruamoko/qwaq/qwaq-cmd .
|
||||||
fi
|
fi
|
||||||
export MINGW=/opt/mxe
|
export MINGW=/opt/mxe
|
||||||
export MINGW_USR=$MINGW/usr/i686-w64-mingw32.static
|
export MINGW_USR=$MINGW/usr/i686-w64-mingw32.static
|
||||||
|
@ -14,4 +14,4 @@ export PKG_CONFIG_LIBDIR=$MINGW_USR/lib/pkgconfig
|
||||||
export PKG_CONFIG_PATH=$MINGW_USR/local/lib/pkgconfig
|
export PKG_CONFIG_PATH=$MINGW_USR/local/lib/pkgconfig
|
||||||
export PATH=$MINGW/usr/bin:$PATH
|
export PATH=$MINGW/usr/bin:$PATH
|
||||||
|
|
||||||
make PAK='$(top_builddir)/pak' QFCC='$(top_builddir)/qfcc' QWAQ_CURSES='$(top_builddir)/qwaq-curses' $*
|
make PAK='$(top_builddir)/pak' QFCC='$(top_builddir)/qfcc' QWAQ='$(top_builddir)/qwaq-cmd' $*
|
||||||
|
|
|
@ -6,7 +6,7 @@ if test -d native; then
|
||||||
cd ../x86_64-w64-mingw32.static
|
cd ../x86_64-w64-mingw32.static
|
||||||
ln -fs ../native/qfcc .
|
ln -fs ../native/qfcc .
|
||||||
ln -fs ../native/pak .
|
ln -fs ../native/pak .
|
||||||
ln -fs ../native/ruamoko/qwaq/qwaq-curses .
|
ln -fs ../native/ruamoko/qwaq/qwaq-cmd .
|
||||||
fi
|
fi
|
||||||
export MINGW=/opt/mxe
|
export MINGW=/opt/mxe
|
||||||
export MINGW_USR=$MINGW/usr/x86_64-w64-mingw32.static
|
export MINGW_USR=$MINGW/usr/x86_64-w64-mingw32.static
|
||||||
|
@ -14,4 +14,4 @@ export PKG_CONFIG_LIBDIR=$MINGW_USR/lib/pkgconfig
|
||||||
export PKG_CONFIG_PATH=$MINGW_USR/local/lib/pkgconfig
|
export PKG_CONFIG_PATH=$MINGW_USR/local/lib/pkgconfig
|
||||||
export PATH=$MINGW/usr/bin:$PATH
|
export PATH=$MINGW/usr/bin:$PATH
|
||||||
|
|
||||||
make PAK='$(top_builddir)/pak' QFCC='$(top_builddir)/qfcc' QWAQ_CURSES='$(top_builddir)/qwaq-curses' $*
|
make PAK='$(top_builddir)/pak' QFCC='$(top_builddir)/qfcc' QWAQ='$(top_builddir)/qwaq-cmd' $*
|
||||||
|
|
Loading…
Reference in a new issue