mirror of
https://github.com/clangen/musikcube.git
synced 2025-01-08 12:40:28 +00:00
Jeeze one of these times I'll get this right.
This commit is contained in:
parent
d85251a02f
commit
ca455e108b
@ -211,7 +211,8 @@ bool DirectSoundOut::Play(IBuffer *buffer, IBufferProvider *provider) {
|
|||||||
|
|
||||||
/* note we ALWAYS allow this loop to run once, even if we're paused,
|
/* note we ALWAYS allow this loop to run once, even if we're paused,
|
||||||
just to keep the buffer as full as possible. note that waits are
|
just to keep the buffer as full as possible. note that waits are
|
||||||
disabled if not playing! */
|
disabled if not playing! also note we do this outside of the critical
|
||||||
|
section to minimize lock contention */
|
||||||
bool bail = false;
|
bool bail = false;
|
||||||
do {
|
do {
|
||||||
availableBytes = getAvailableBytes(
|
availableBytes = getAvailableBytes(
|
||||||
@ -229,47 +230,46 @@ bool DirectSoundOut::Play(IBuffer *buffer, IBufferProvider *provider) {
|
|||||||
}
|
}
|
||||||
} while (!bail);
|
} while (!bail);
|
||||||
|
|
||||||
if (availableBytes >= bufferBytes) {
|
{
|
||||||
if (this->state != StatePlaying) {
|
Lock lock(this->stateMutex);
|
||||||
int n = 10;
|
|
||||||
++n;
|
|
||||||
}
|
|
||||||
|
|
||||||
HRESULT result =
|
if (this->state != StateStopped && availableBytes >= bufferBytes) {
|
||||||
outputBuffer->Lock(
|
HRESULT result =
|
||||||
writeOffset,
|
outputBuffer->Lock(
|
||||||
bufferBytes,
|
writeOffset,
|
||||||
(void **)&dst1, &size1,
|
bufferBytes,
|
||||||
(void **)&dst2, &size2,
|
(void **)&dst1, &size1,
|
||||||
0);
|
(void **)&dst2, &size2,
|
||||||
|
0);
|
||||||
|
|
||||||
if (result == DSERR_BUFFERLOST) {
|
if (result == DSERR_BUFFERLOST) {
|
||||||
outputBuffer->Restore();
|
outputBuffer->Restore();
|
||||||
|
|
||||||
result = this->secondaryBuffer->Lock(
|
result = outputBuffer->Lock(
|
||||||
writeOffset,
|
writeOffset,
|
||||||
bufferBytes,
|
bufferBytes,
|
||||||
(void **)&dst1, &size1,
|
(void **)&dst1, &size1,
|
||||||
(void **)&dst2, &size2,
|
(void **)&dst2, &size2,
|
||||||
0);
|
0);
|
||||||
}
|
|
||||||
|
|
||||||
if (result == DS_OK) {
|
|
||||||
char* bufferPointer = (char *)buffer->BufferPointer();
|
|
||||||
|
|
||||||
memcpy(dst1, bufferPointer, size1);
|
|
||||||
if (size2 > 0) {
|
|
||||||
memcpy(dst2, bufferPointer + size1, size2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
writeOffset += bufferBytes;
|
if (result == DS_OK) {
|
||||||
writeOffset %= this->bufferSize;
|
char* bufferPointer = (char *)buffer->BufferPointer();
|
||||||
|
|
||||||
outputBuffer->Unlock((void *)dst1, size1, (void *)dst2, size2);
|
memcpy(dst1, bufferPointer, size1);
|
||||||
outputBuffer->Release();
|
if (size2 > 0) {
|
||||||
|
memcpy(dst2, bufferPointer + size1, size2);
|
||||||
|
}
|
||||||
|
|
||||||
provider->OnBufferProcessed(buffer);
|
writeOffset += bufferBytes;
|
||||||
return true;
|
writeOffset %= this->bufferSize;
|
||||||
|
|
||||||
|
outputBuffer->Unlock((void *)dst1, size1, (void *)dst2, size2);
|
||||||
|
outputBuffer->Release();
|
||||||
|
|
||||||
|
provider->OnBufferProcessed(buffer);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user