X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=snd_win.c;h=a7a2adff12571818a8f74629f8e821498585c7bf;hb=0002fd924cc7129181a5757a3a2702a9af4def4e;hp=1228bd7f1c069b6450682931a7ccf139d8324c1a;hpb=87e474443b39bf3c118ad442b40ff448bf38420c;p=xonotic%2Fdarkplaces.git diff --git a/snd_win.c b/snd_win.c index 1228bd7f..a7a2adff 100644 --- a/snd_win.c +++ b/snd_win.c @@ -82,13 +82,14 @@ static const GUID MY_KSDATAFORMAT_SUBTYPE_PCM = // ============================================================================== extern HWND mainwindow; +static cvar_t snd_wav_partitionsize = {CVAR_SAVE, "snd_wav_partitionsize", "1024", "controls sound delay in samples, values too low will cause crackling, too high will cause delayed sounds"}; +static qboolean sndsys_registeredcvars = false; #ifdef SUPPORTDIRECTX HRESULT (WINAPI *pDirectSoundCreate)(GUID FAR *lpGUID, LPDIRECTSOUND FAR *lplpDS, IUnknown FAR *pUnkOuter); #endif -// Wave output: how much buffer time, and how many partitions in that time -#define WAV_BUFFERTIME 0.125 +// Wave output: queue of this many sound buffers to play, reused cyclically #define WAV_BUFFERS 16 #define WAV_MASK (WAV_BUFFERS - 1) static unsigned int wav_buffer_size; @@ -458,7 +459,7 @@ static qboolean SndSys_InitMmsystem (const snd_format_t* requested) } } - wav_buffer_size = ((int)(requested->speed * WAV_BUFFERTIME) / WAV_BUFFERS) * requested->channels * requested->width; + wav_buffer_size = bound(128, snd_wav_partitionsize.integer, 8192) * requested->channels * requested->width; /* * Allocate and lock memory for the waveform data. The memory @@ -550,6 +551,12 @@ qboolean SndSys_Init (const snd_format_t* requested, snd_format_t* suggested) #endif sndinitstat stat; + if (!sndsys_registeredcvars) + { + sndsys_registeredcvars = true; + Cvar_RegisterVariable(&snd_wav_partitionsize); + } + Con_Print ("SndSys_Init: using the Win32 module\n"); #ifdef SUPPORTDIRECTX @@ -709,8 +716,8 @@ void SndSys_Submit (void) snd_sent++; else if (wResult == WAVERR_STILLPLAYING) { - if(developer.integer >= 1000) - Con_Print("waveOutWrite failed (too much sound data)\n"); + if(developer_insane.integer) + Con_DPrint("waveOutWrite failed (too much sound data)\n"); //h->dwFlags |= WHDR_DONE; //snd_sent++; } @@ -762,7 +769,7 @@ unsigned int SndSys_GetSoundTime (void) { if (snd_completed == snd_sent) { - Con_DPrint("Sound overrun\n"); + // Con_DPrint("Sound overrun\n"); break; } @@ -874,3 +881,15 @@ void SndSys_UnlockRenderBuffer (void) IDirectSoundBuffer_Unlock(pDSBuf, dsound_pbuf, dsound_dwSize, dsound_pbuf2, dsound_dwSize2); #endif } + +/* +==================== +SndSys_SendKeyEvents + +Send keyboard events originating from the sound system (e.g. MIDI) +==================== +*/ +void SndSys_SendKeyEvents(void) +{ + // not supported +}