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)
-#define WAV_BUFFERS 64
+// Wave output: how much buffer time, and how many partitions in that time
+#define WAV_BUFFERTIME 0.125
+#define WAV_BUFFERS 16
#define WAV_MASK (WAV_BUFFERS - 1)
static unsigned int wav_buffer_size;
}
}
- wav_buffer_size = (requested->speed / 2 / WAV_BUFFERS) * requested->channels * requested->width;
+ wav_buffer_size = ((int)(requested->speed * WAV_BUFFERTIME) / WAV_BUFFERS) * requested->channels * requested->width;
/*
* Allocate and lock memory for the waveform data. The memory
{
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));
-
- if (wResult != MMSYSERR_NOERROR)
+ if (wResult == MMSYSERR_NOERROR)
+ snd_sent++;
+ else if (wResult == WAVERR_STILLPLAYING)
{
- if (wResult == WAVERR_STILLPLAYING)
- {
- if(developer.integer >= 1000)
- Con_Print("waveOutWrite failed (too much sound data)\n");
- }
- else
- {
- Con_Printf("waveOutWrite failed, error code %d\n", (int) wResult);
- SndSys_Shutdown ();
- return;
- }
+ if(developer.integer >= 1000)
+ Con_Print("waveOutWrite failed (too much sound data)\n");
+ //h->dwFlags |= WHDR_DONE;
+ //snd_sent++;
+ }
+ else
+ {
+ Con_Printf("waveOutWrite failed, error code %d\n", (int) wResult);
+ SndSys_Shutdown ();
+ return;
}
paintpot -= wav_buffer_size;
}
return (snd_completed * wav_buffer_size) / factor;
+
+ /*
+ * S_PaintAndSubmit: WARNING: newsoundtime (soundtime (275 < 134217707)
+ * apparently this sound time wraps quite early?
+ {
+ MMRESULT res;
+ MMTIME mmtime;
+
+ mmtime.wType = TIME_SAMPLES;
+ res = waveOutGetPosition(hWaveOut, &mmtime, sizeof(mmtime));
+ if(res == MMSYSERR_NOERROR)
+ return mmtime.u.sample;
+ }
+ */
}
return 0;