HINSTANCE hInstDS;
-qboolean SNDDMA_InitDirect (void);
qboolean SNDDMA_InitWav (void);
-
+sndinitstat SNDDMA_InitDirect (void);
/*
==================
WAVEFORMATEX format, pformat;
HRESULT hresult;
int reps;
+ int i;
memset ((void *)&sn, 0, sizeof (sn));
shm->channels = 2;
shm->samplebits = 16;
- shm->speed = 11025;
+ i = COM_CheckParm ("-sndspeed"); // LordHavoc: -sndspeed option
+ if (i && i != (com_argc - 1))
+ shm->speed = atoi(com_argv[i+1]);
+ else
+ shm->speed = 11025;
memset (&format, 0, sizeof(format));
format.wFormatTag = WAVE_FORMAT_PCM;
format.nChannels = shm->channels;
format.wBitsPerSample = shm->samplebits;
format.nSamplesPerSec = shm->speed;
- format.nBlockAlign = format.nChannels
- *format.wBitsPerSample / 8;
+ format.nBlockAlign = format.nChannels * format.wBitsPerSample / 8;
format.cbSize = 0;
- format.nAvgBytesPerSec = format.nSamplesPerSec
- *format.nBlockAlign;
+ format.nAvgBytesPerSec = format.nSamplesPerSec * format.nBlockAlign;
if (!hInstDS)
{
if (snd_firsttime)
Con_SafePrintf(" %d channel(s)\n"
" %d bits/sample\n"
- " %d bytes/sec\n",
+ " %d samples/sec\n",
shm->channels, shm->samplebits, shm->speed);
gSndBufSize = dsbcaps.dwBufferBytes;
}
memset(lpData, 0, dwSize);
-// lpData[4] = lpData[5] = 0x7f; // force a pop for debugging
pDSBuf->lpVtbl->Unlock(pDSBuf, lpData, dwSize, NULL, 0);
shm->channels = 2;
shm->samplebits = 16;
- shm->speed = 11025;
+ i = COM_CheckParm ("-sndspeed"); // LordHavoc: -sndspeed option
+ if (i && i != (com_argc - 1))
+ shm->speed = atoi(com_argv[i+1]);
+ else
+ shm->speed = 11025;
memset (&format, 0, sizeof(format));
format.wFormatTag = WAVE_FORMAT_PCM;
==================
*/
-int SNDDMA_Init(void)
+qboolean SNDDMA_Init(void)
{
sndinitstat stat;
snd_firsttime = false;
if (!dsound_init && !wav_init)
- {
-// if (snd_firsttime)
-// Con_SafePrintf ("No sound device initialized\n");
-
return 0;
- }
return 1;
}
{
s = snd_sent * WAV_BUFFER_SIZE;
}
+ else
+ s = 0;
s >>= sample16;
h = lpWaveHdr + ( snd_sent&WAV_MASK );
snd_sent++;
- /*
- * Now the data block can be sent to the output device. The
- * waveOutWrite function returns immediately and waveform
- * data is sent to the output device in the background.
- */
- wResult = waveOutWrite(hWaveOut, h, sizeof(WAVEHDR));
+ /*
+ * Now the data block can be sent to the output device. The
+ * waveOutWrite function returns immediately and waveform
+ * data is sent to the output device in the background.
+ */
+ wResult = waveOutWrite(hWaveOut, h, sizeof(WAVEHDR));
if (wResult != MMSYSERR_NOERROR)
- {
+ {
Con_SafePrintf ("Failed to write block to device\n");
FreeSound ();
- return;
- }
+ return;
+ }
}
}
FreeSound ();
}
+DWORD dsound_dwSize;
+DWORD dsound_dwSize2;
+DWORD *dsound_pbuf;
+DWORD *dsound_pbuf2;
+void *S_LockBuffer(void)
+{
+ int reps;
+ HRESULT hresult;
+
+ if (pDSBuf)
+ {
+ reps = 0;
+
+ while ((hresult = pDSBuf->lpVtbl->Lock(pDSBuf, 0, gSndBufSize, &dsound_pbuf, &dsound_dwSize, &dsound_pbuf2, &dsound_dwSize2, 0)) != DS_OK)
+ {
+ if (hresult != DSERR_BUFFERLOST)
+ {
+ Con_Printf ("S_LockBuffer: DS::Lock Sound Buffer Failed\n");
+ S_Shutdown ();
+ S_Startup ();
+ return NULL;
+ }
+
+ if (++reps > 10000)
+ {
+ Con_Printf ("S_LockBuffer: DS: couldn't restore buffer\n");
+ S_Shutdown ();
+ S_Startup ();
+ return NULL;
+ }
+ }
+ return dsound_pbuf;
+ }
+ else
+ return shm->buffer;
+}
+
+void S_UnlockBuffer(void)
+{
+ if (pDSBuf)
+ pDSBuf->lpVtbl->Unlock(pDSBuf, dsound_pbuf, dsound_dwSize, dsound_pbuf2, dsound_dwSize2);
+}
+
+void S_Open(void)
+{
+}
+
+void S_Close(void)
+{
+}