Hack: Use a single-play (non-looping) buffer for very short samples that fit entirely in the buffer for DSound playback. This avoids unwanted repeating of very short samples, but also makes it impossible to extend these selections to continue playback.

Fixing the real problem could prove to be very hard or even impossible, as it seems to be a problem of timing and possibly even related to the time slices allocated by the OS. As a buffer size in the DSound player is fixed at 150 ms the side-effect of this hack hopefully won't be a real problem.

Originally committed to SVN as r1460.
This commit is contained in:
Niels Martin Hansen 2007-07-29 21:00:57 +00:00
parent c62c674975
commit 0718cf5a2c
1 changed files with 9 additions and 5 deletions

View File

@ -337,14 +337,18 @@ void DirectSoundPlayer::Play(__int64 start,__int64 count) {
// Fill whole buffer
FillBuffer(true);
// Start thread
thread = new DirectSoundPlayerThread(this);
thread->Create();
thread->Run();
DWORD play_flag = 0;
if (count > bufSize) {
// Start thread
thread = new DirectSoundPlayerThread(this);
thread->Create();
thread->Run();
play_flag = DSBPLAY_LOOPING;
}
// Play
buffer->SetCurrentPosition(0);
res = buffer->Play(0,0,DSBPLAY_LOOPING);
res = buffer->Play(0,0,play_flag);
if (SUCCEEDED(res)) playing = true;
startTime = GetTickCount();