void SNDDXDeInit() { DWORD status=0; if (lpDSB2) { IDirectSoundBuffer8_GetStatus(lpDSB2, &status); if(status == DSBSTATUS_PLAYING) IDirectSoundBuffer8_Stop(lpDSB2); IDirectSoundBuffer8_Release(lpDSB2); lpDSB2 = NULL; } if (lpDSB) { IDirectSoundBuffer8_Release(lpDSB); lpDSB = NULL; } if (lpDS8) { IDirectSound8_Release(lpDS8); lpDS8 = NULL; } }
static gboolean gst_directsound_ring_buffer_stop (GstRingBuffer * buf) { HRESULT hr; DWORD ret; HANDLE hThread; GstDirectSoundRingBuffer * dsoundbuffer; dsoundbuffer = GST_DIRECTSOUND_RING_BUFFER (buf); GST_DEBUG ("Stopping RingBuffer"); GST_DSOUND_LOCK (dsoundbuffer); dsoundbuffer->should_run = FALSE; if (dsoundbuffer->pDSB8) { hr = IDirectSoundBuffer8_Stop (dsoundbuffer->pDSB8); if (G_UNLIKELY (FAILED(hr))) { GST_DSOUND_UNLOCK (dsoundbuffer); GST_WARNING ("gst_directsound_ring_buffer_stop: IDirectSoundBuffer8_Stop, hr = %X", (unsigned int) hr); return FALSE; } } hThread = dsoundbuffer->hThread; if (dsoundbuffer->suspended && ResumeThread (hThread) != -1) { dsoundbuffer->suspended = FALSE; } else { GST_DSOUND_UNLOCK (dsoundbuffer); GST_WARNING ("gst_directsound_ring_buffer_stop: ResumeThread failed."); return FALSE; } GST_DSOUND_UNLOCK (dsoundbuffer); /* wait without lock held */ ret = WaitForSingleObject (hThread, 5000); if (G_UNLIKELY (ret == WAIT_TIMEOUT)) { GST_WARNING ("gst_directsound_ring_buffer_stop: Failed to wait for thread shutdown. (%u)", (unsigned int) ret); return FALSE; } GST_DSOUND_LOCK (dsoundbuffer); CloseHandle (dsoundbuffer->hThread); dsoundbuffer->hThread = NULL; GST_DSOUND_UNLOCK (dsoundbuffer); return TRUE; }
EXPORT void CALL CloseDLL (void) { #ifdef THREADED TerminateThread (handleAudioThread, 0); #endif if (lpdsbuf) { IDirectSoundBuffer8_Stop(lpdsbuf); IDirectSoundBuffer8_Release(lpdsbuf); lpdsbuf = NULL; } if ( lpds ) { IDirectSound8_Release(lpds); lpds = NULL; } }
EXPORT void CALL RomClosed (void) { // ucodeDetected = FALSE; // gUcode = UNDEFINED_UCODE; if (!audioIsPlaying) return; audioIsPlaying = FALSE; #ifdef THREADED TerminateThread (handleAudioThread, 0); #endif IDirectSoundBuffer8_Stop(lpdsbuf); Dacrate = 0; Playing = FALSE; SndBuffer[0] = Buffer_Empty; SndBuffer[1] = Buffer_Empty; SndBuffer[2] = Buffer_Empty; *AudioInfo.AI_STATUS_REG &= ~AI_STATUS_FIFO_FULL; *AudioInfo.MI_INTR_REG |= MI_INTR_AI; }
static gboolean gst_directsound_ring_buffer_pause (GstRingBuffer * buf) { HRESULT hr = S_OK; GstDirectSoundRingBuffer * dsoundbuffer; dsoundbuffer = GST_DIRECTSOUND_RING_BUFFER (buf); GST_DEBUG ("Pausing RingBuffer"); GST_DSOUND_LOCK (dsoundbuffer); if (dsoundbuffer->pDSB8) { hr = IDirectSoundBuffer8_Stop (dsoundbuffer->pDSB8); } if (G_LIKELY (!dsoundbuffer->suspended)) { if (G_UNLIKELY(SuspendThread (dsoundbuffer->hThread) == -1)) GST_WARNING ("gst_directsound_ring_buffer_pause: SuspendThread failed."); else dsoundbuffer->suspended = TRUE; } GST_DSOUND_UNLOCK (dsoundbuffer); /* in the unlikely event that a device was reconfigured, we can consider * ourselves stopped even though the stop call failed */ if (G_UNLIKELY (FAILED(hr)) && G_UNLIKELY(hr != DIRECTSOUND_ERROR_DEVICE_RECONFIGURED) && G_UNLIKELY(hr != DIRECTSOUND_ERROR_DEVICE_NO_DRIVER)) { GST_WARNING ("gst_directsound_ring_buffer_pause: IDirectSoundBuffer8_Stop, hr = %X", (unsigned int) hr); return FALSE; } return TRUE; }