/* Getting here means the device is being stopped. */
/* The playback device should be drained before stopping. */
/* 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 (isPlaybackDeviceStarted) {
/* TODO: Drain the playback device. */
for (;;) {
DWORD availableBytesPlayback = 0;
DWORD physicalPlayCursorInBytes;
DWORD physicalWriteCursorInBytes;
if (FAILED(mal_IDirectSoundBuffer_GetCurrentPosition((mal_IDirectSoundBuffer*)pDevice->dsound.pPlaybackBuffer, &physicalPlayCursorInBytes, &physicalWriteCursorInBytes))) {
break;
}
if (physicalPlayCursorInBytes < prevPlayCursorInBytesPlayback) {