unsafe void UpdateSample() { uint status; int hr = IDirectSoundBuffer.GetStatus(currentSoundBuffer, out status); if (Wrapper.FAILED(hr)) { DirectSoundWorld.Warning("IDirectSoundBuffer.GetStatus", hr); return; } if ((status & DSound.DSBSTATUS_PLAYING) == 0) { CurrentVirtualChannel.Stop(); } }
public unsafe bool RestoreSoundBuffers(out bool restored) { IDirectSoundBuffer *soundBuffer = (IDirectSoundBuffer *)soundBuffers[0].ToPointer(); int hr; restored = false; uint status; hr = IDirectSoundBuffer.GetStatus(soundBuffer, out status); if (Wrapper.FAILED(hr)) { DirectSoundWorld.Warning("IDirectSoundBuffer.GetStatus", hr); return(false); } if ((status & DSound.DSBSTATUS_BUFFERLOST) != 0) { int DSERR_BUFFERLOST = DSound.Get_DSERR_BUFFERLOST(); // Since the app could have just been activated, then // DirectSound may not be giving us control yet, so // the restoring the buffer may fail. // If it does, sleep until DirectSound gives us control. do { hr = IDirectSoundBuffer.Restore(soundBuffer); if (hr == DSERR_BUFFERLOST) { Thread.Sleep(10); } }while((hr = IDirectSoundBuffer.Restore(soundBuffer)) == DSERR_BUFFERLOST); restored = true; } return(true); }