/* The playback device should be drained before stopping. All we do is wait until the available bytes is equal to the size of the buffer. */
if (pDevice->type == mal_device_type_playback || pDevice->type == mal_device_type_duplex) {
if (isPlaybackDeviceStarted) {
/* The playback device should be drained before stopping. All we do is wait until the available bytes is equal to the size of the buffer. */
for (;;) {
if (isPlaybackDeviceStarted) {
DWORD availableBytesPlayback = 0;
for (;;) {
DWORD physicalPlayCursorInBytes;
DWORD availableBytesPlayback = 0;
DWORD physicalWriteCursorInBytes;
DWORD physicalPlayCursorInBytes;
if (FAILED(mal_IDirectSoundBuffer_GetCurrentPosition((mal_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, &physicalPlayCursorInBytes, &physicalWriteCursorInBytes))) {
DWORD physicalWriteCursorInBytes;
break;
if (FAILED(mal_IDirectSoundBuffer_GetCurrentPosition((mal_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, &physicalPlayCursorInBytes, &physicalWriteCursorInBytes))) {
}
break;
}
if (physicalPlayCursorInBytes < prevPlayCursorInBytesPlayback) {
if (physicalPlayCursorInBytes < prevPlayCursorInBytesPlayback) {