void sound_direct_sound::dsound_kill() { // release the object if (m_dsound) m_dsound->Release(); m_dsound = nullptr; }
//----------------------------------------------------------------------------- // Освобождение Direct Sound объекта // на входе : direct - указатель на Direct Sound объект // на выходе : * //----------------------------------------------------------------------------- void ds_Release(LPDIRECTSOUND direct) { // удаление объекта воспроизведения if (direct) direct->Release(); // Освобождение COM CoUninitialize(); }
ULONG STDMETHODCALLTYPE DirectSound::Release() { ULONG result = m_ds->Release(); if (!result) { delete this; } return result; }
int Game_Shutdown(void *parms) { // this function is where you shutdown your game and // release all resources that you allocated // release the directsoundobject if (lpds!=NULL) lpds->Release(); // return success return(1); } // end Game_Shutdown
bool DeleteDirectSoundResources() { if(lpDS) { lpDS->Release(); lpDS = NULL; return true; } // Just incase something should go wrong. MessageBox(NULL, "Sound buffer freed without having been acquired.", "DirectSound Error", MB_OK | MB_ICONEXCLAMATION); return false; }
// DirectSound-Objekte freigeben int QuitDSound(void) { if(lpDS!= NULL) lpDS->Release(); for (int i=0; i<ANZ_SOUNDS; i++) { if(SoundArray[i]!= NULL) SoundArray[i]->Release(); } return 0; }
//----------------------------------------------------------------------------- // Name: DSUtil_InitDirectSound() // Desc: //----------------------------------------------------------------------------- HRESULT DSUtil_InitDirectSound( HWND hWnd ) { if( FAILED( DirectSoundCreate( NULL, &g_pDS, NULL ) ) ) return E_FAIL; if( FAILED( g_pDS->SetCooperativeLevel( hWnd, DSSCL_NORMAL ) ) ) { g_pDS->Release(); g_pDS = NULL; return E_FAIL; } return S_OK; }
//=========================================================================== // DS_Shutdown //=========================================================================== void DS_Shutdown(void) { if(!initOk) return; if(eaxListener) eaxListener->Release(); if(dsListener) dsListener->Release(); if(primary) primary->Release(); if(dsound) dsound->Release(); eaxListener = NULL; dsListener = NULL; primary = NULL; dsound = NULL; initOk = false; }
/* ================== SNDDMA_Shutdown ================== */ void SNDDMA_Shutdown( void ) { Com_DPrintf( "Shutting down sound system\n" ); if ( pDS ) { Com_DPrintf( "Destroying DS buffers\n" ); if ( pDS ) { Com_DPrintf( "...setting NORMAL coop level\n" ); // FIXME JA was DSSCL_NORMAL and Q3 says DSSCL_PRIORITY but the printf says setting normal pDS->SetCooperativeLevel( g_wv.hWnd, DSSCL_PRIORITY ); } if ( pDSBuf ) { Com_DPrintf( "...stopping and releasing sound buffer\n" ); pDSBuf->Stop( ); pDSBuf->Release( ); } // only release primary buffer if it's not also the mixing buffer we just released if ( pDSPBuf && ( pDSBuf != pDSPBuf ) ) { Com_DPrintf( "...releasing primary buffer\n" ); pDSPBuf->Release( ); } pDSBuf = NULL; pDSPBuf = NULL; dma.buffer = NULL; Com_DPrintf( "...releasing DS object\n" ); pDS->Release( ); } if ( hInstDS ) { Com_DPrintf( "...freeing DSOUND.DLL\n" ); FreeLibrary( hInstDS ); hInstDS = NULL; } pDS = NULL; pDSBuf = NULL; pDSPBuf = NULL; dsound_init = qfalse; memset ((void *)&dma, 0, sizeof (dma)); CoUninitialize( ); }
int DSound_Shutdown(void) { // this function releases all the memory allocated and the directsound object // itself // first turn all sounds off DSound_Stop_All_Sounds(); // now release all sound buffers for (int index=0; index<MAX_SOUNDS; index++) if (sound_fx[index].dsbuffer) sound_fx[index].dsbuffer->Release(); // now release the directsound interface itself if (lpds) lpds->Release(); return(1); }
void SNDDMA_Shutdown() { common->DPrintf( "Shutting down sound system\n" ); if ( pDS ) { if ( pDSBuf ) { common->DPrintf( "...stopping and releasing sound buffer\n" ); pDSBuf->Stop(); pDSBuf->Release(); } common->DPrintf( "...releasing DS object\n" ); pDS->Release(); } pDS = NULL; pDSBuf = NULL; dsound_init = false; Com_Memset( ( void* )&dma, 0, sizeof ( dma ) ); CoUninitialize(); }
int DSShutdown(void) { // first turn all sounds off StopAllSounds(); // now release all sound buffers for (int index = 0; index < MAX_SOUNDS; index++) if (sound_fx[index].dsbuffer) { sound_fx[index].dsbuffer->Release(); } // now release the directsound interface itself if (lpDS) { lpDS->Release(); lpDS = NULL; } // return success return(1); }
//----------------------------------------------------------------------------- // Name: DSUtil_FreeDirectSound() // Desc: //----------------------------------------------------------------------------- VOID DSUtil_FreeDirectSound() { if( g_pDS ) g_pDS->Release(); g_pDS = NULL; }
/* ------------------------------------------------------------------------------------ */ int StreamingAudio::Create(char *szFileName) { int nError = 0; if(CCD->GetLogging()) { char szDebug[512]; sprintf(szDebug, "[INFO] Loaded %s", szFileName); CCD->ReportError(szDebug, false); } // Sanity check parameters if(szFileName == NULL) return RGF_FAILURE; // Wrong. // changed RF064 int len = strlen(szFileName)-4; if(stricmp((szFileName+len),".mp3") == 0) { if(Mpeg3 != NULL) return RGF_FAILURE; Mpeg3 = new CMp3Manager; Mpeg3->OpenMediaFile(szFileName); mp3 = true; m_fActive = true; // start a timer for this stream. MMRESULT nTimer = timeSetEvent(125, 5, &TimerFunction, (DWORD)this, TIME_PERIODIC | TIME_CALLBACK_FUNCTION); if(nTimer == NULL) { CCD->ReportError("[WARNING] StreamingAudio: Timer callback set-up failed", false); return RGF_FAILURE; // Timer startup failed. } m_nTimerID = nTimer; // Save timer ID return RGF_SUCCESS; } mp3 = false; if(stricmp((szFileName+len), ".ogg") == 0) { if(Ogg != NULL) return RGF_FAILURE; Ogg = new OggAudio(m_pDS); Ogg->Load(szFileName); ogg = true; m_fActive = true; return RGF_SUCCESS; } ogg = false; // start a timer for this stream. MMRESULT nTimer = timeSetEvent(125, 5, &TimerFunction, (DWORD)this, TIME_PERIODIC | TIME_CALLBACK_FUNCTION); if(nTimer == NULL) { CCD->ReportError("[WARNING] StreamingAudio: Timer callback set-up failed", false); return RGF_FAILURE; // Timer startup failed. } m_nTimerID = nTimer; // Save timer ID // end change RF064 // Check for stream availability if(m_pStream != NULL) return RGF_FAILURE; // Already loaded! // Open up the WAVE file. nError = WaveOpen(szFileName, &m_hWaveFile, &m_pWaveFormat, &m_rRiffData); if(nError != RGF_SUCCESS) { char szBug[128]; sprintf(szBug, "[WARNING] File %s - Line %d: Failed to open wave file '%s'\n(Note: streamig audio can't be placed in VFS)", __FILE__, __LINE__, szFileName); CCD->ReportError(szBug, false); return RGF_FAILURE; // Problem here, too! } // Get current position in file, which will be the start of the // ..WAVE data. m_nDataPosition = mmioSeek(m_hWaveFile, 0, SEEK_CUR); m_nDataSize = m_rRiffData.cksize; // Save data size // Fetch DirectSound interface we want LPDIRECTSOUND pDSIF; nError = m_pDS->QueryInterface(IID_IDirectSound, (LPVOID *)&pDSIF); // Create a DSound buffer to stream into DSBUFFERDESC theDesc; memset(&theDesc, 0, sizeof(DSBUFFERDESC)); theDesc.dwSize = sizeof(DSBUFFERDESC); theDesc.dwBufferBytes = kBufferSize; theDesc.lpwfxFormat = m_pWaveFormat; theDesc.dwFlags = DSBCAPS_CTRLVOLUME; nError = pDSIF->CreateSoundBuffer(&theDesc, &m_pStream, NULL); pDSIF->Release(); // Done w/ this. if(nError != 0) // Error! Sick out. { char szBug[128]; sprintf(szBug, "StreamingAudio: Failed to create buffer for '%s'\n", szFileName); OutputDebugString(szBug); mmioClose(m_hWaveFile, 0); m_hWaveFile = NULL; delete m_pWaveFormat; m_pWaveFormat = NULL; return RGF_FAILURE; } m_nOffset = 0; // Start at top of buffer // changed RF064 //m_fActive = true; // Set as active // end change RF064 PumpWave(kBufferSize); // Initial buffer load return RGF_SUCCESS; }