X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;ds=sidebyside;f=snd_win.c;h=ef6703658f01c0590b20b27cf4af701691dd6af1;hb=5ac4f145047673a64b1658f0ceba1cdb836d7eb8;hp=2a6c088acae023030d679cd90c1f04cf9a936c58;hpb=45a612bd1e80c5fe53c1d8cbc3b6e9781797b4f6;p=xonotic%2Fdarkplaces.git diff --git a/snd_win.c b/snd_win.c index 2a6c088a..ef670365 100644 --- a/snd_win.c +++ b/snd_win.c @@ -389,7 +389,6 @@ sndinitstat SNDDMA_InitDirect (void) } memset(lpData, 0, dwSize); -// lpData[4] = lpData[5] = 0x7f; // force a pop for debugging pDSBuf->lpVtbl->Unlock(pDSBuf, lpData, dwSize, NULL, 0); @@ -619,12 +618,7 @@ qboolean SNDDMA_Init(void) snd_firsttime = false; if (!dsound_init && !wav_init) - { -// if (snd_firsttime) -// Con_SafePrintf ("No sound device initialized\n"); - return 0; - } return 1; } @@ -707,19 +701,19 @@ void SNDDMA_Submit(void) 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; + } } } @@ -735,3 +729,53 @@ void SNDDMA_Shutdown(void) 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) +{ +}