ALSequencer::~ALSequencer() { bDestroying = true; WaitForSingleObject(hThread, INFINITE); Stop(); alutExit(); ShutdownOpenAL(); if (pOutput) free(pOutput); for (unsigned long ulLoop = 0; ulLoop < ulNumEffects; ulLoop++) { if (pEffectOutput[ulLoop]) free(pEffectOutput[ulLoop]); } if (pWaveLoader) { for (int i = 0; i < fileCount; i++) { if (pWaveLoader->IsWaveID(files[i])) pWaveLoader->DeleteWaveFile(files[i]); } delete pWaveLoader; } }
int main(int argc, char *argv[]) { InitOpenAL(); // 初始化openal LoadData(); // 载入WAV数据 Play(); // 播放 UnloadData(); // 卸载WAV数据 ShutdownOpenAL(); // 关闭openal return 0; }
void clAudioThread::Run() { Env->Logger->SetCurrentThreadName( "Audio" ); guard(); #if L_AUDIO_USE_OPENAL LAL::clALExtRetriever* OpenAL = new LAL::clALExtRetriever; FATAL( !OpenAL->Reload(), "Unable to initialize OpenAL" ); // now initialize OpenAL InitOpenAL(); #endif double Seconds = Env->GetSeconds(); while ( !IsPendingExit() ) { float DeltaSeconds = static_cast<float>( Env->GetSeconds() - Seconds ); { LMutex Lock( &FMutex ); // update sources std::for_each( FActiveSources.begin(), FActiveSources.end(), std::bind2nd( std::mem_fun( &iAudioSource::Update ), DeltaSeconds ) ); } Seconds = Env->GetSeconds(); Env->ReleaseTimeslice( 100 ); } Env->Logger->Log( L_NOTICE, "Deallocating sources" ); { LMutex Lock( &FMutex ); while ( !FActiveSources.empty() ) { delete( FActiveSources.back() ); } } #if L_AUDIO_USE_OPENAL ShutdownOpenAL(); delete( OpenAL ); #endif Env->Logger->Log( L_NOTICE, "Audio thread exited" ); unguard(); }
Sound::~Sound() { if (alcGetCurrentContext() != 0) { alDeleteSources(NUM_SOURCES, m_sources); // Automatically stops currently playing sources alDeleteBuffers(2, m_music_buffers); for( std::map<std::string, ALuint>::iterator itr = m_buffers.begin(); itr != m_buffers.end(); ++itr ) alDeleteBuffers(1, &itr->second ); } ShutdownOpenAL(); }
void Sound::Impl::Disable() { if (!m_initialized) return; StopMusic(); ShutdownOpenAL(); //Reset playing audio m_music_loops = 0; m_buffers.clear(); m_temporary_disable_count = 0; m_initialized = false; DebugLogger() << "Audio " << (m_initialized ? "enabled." : "disabled."); }
static void destroy (GtkWidget *window, gpointer data) { ShutdownOpenAL(); gtk_main_quit (); }