void free_ship (RACE_DESC *raceDescPtr, BOOLEAN FreeIconData, BOOLEAN FreeBattleData) { if (raceDescPtr->uninit_func != NULL) (*raceDescPtr->uninit_func) (raceDescPtr); if (FreeBattleData) { DATA_STUFF *shipData = &raceDescPtr->ship_data; free_image (shipData->special); free_image (shipData->weapon); free_image (shipData->ship); DestroyDrawable ( ReleaseDrawable (shipData->captain_control.background)); DestroyMusic (shipData->victory_ditty); DestroySound (ReleaseSound (shipData->ship_sounds)); } if (FreeIconData) { SHIP_INFO *shipInfo = &raceDescPtr->ship_info; DestroyDrawable (ReleaseDrawable (shipInfo->melee_icon)); DestroyDrawable (ReleaseDrawable (shipInfo->icons)); DestroyStringTable (ReleaseStringTable (shipInfo->race_strings)); } DestroyCodeRes (ReleaseCodeRes (raceDescPtr->CodeRef)); }
void Audio::Update(float dt, Camera* Listener) { // Calculate velocity Vec3 velocity = dt > M_EPSILON ? Listener->GetPosition().GetRelativeToPoint(mLastCameraPosition) / dt : Vec3(0.0f, 0.0f, 0.0f); mLastCameraPosition = Listener->GetPosition(); // Update Listener orientation irrklang::vec3df lookDir = Listener->GetOrientation() * Vec3(0.0f, 0.0f, -1.0f); irrklang::vec3df upDir = Listener->GetOrientation() * Vec3(0.0f, 1.0f, 0.0f); mSoundEngine->setListenerPosition(irrklang::vec3df(0.0f, 0.0f, 0.0f), lookDir, velocity, upDir); // Clear immediate sounds auto i = mImmediateSounds.begin(); while (i != mImmediateSounds.end()) { if ((*i)->IsFinished()) { DestroySound(*i); i = mImmediateSounds.erase(i); } else { i++; } } // Update sounds for (auto snd : mSounds) snd->Update(Listener, dt); }
VOID AudioShutdown() { UINT i; for (i = 0; i < ARRAYSIZE(g_sounds); ++i) { DestroySound(&g_sounds[i]); } }
VOID AudioDestroy(HSOUND sound) { if (sound != INVALID_HSOUND_VALUE && sound < MAX_SOUNDS) { assert(g_sounds[sound].Data); DestroySound(&g_sounds[sound]); if (sound < g_nextFree) { g_nextFree = sound; } } }
static void UninitKernel (BOOLEAN ships) { UninitSpace (); DestroySound (ReleaseSound (MenuSounds)); DestroyFont (MicroFont); DestroyStringTable (ReleaseStringTable (GameStrings)); DestroyDrawable (ReleaseDrawable (StatusFrame)); DestroyDrawable (ReleaseDrawable (ActivityFrame)); DestroyFont (TinyFont); DestroyFont (StarConFont); UninitQueue (&race_q[0]); UninitQueue (&race_q[1]); if (ships) FreeMasterShipList (); ActivityFrame = 0; }
void SoundMgr::Update() { vObject_t::iterator iter = m_vSounds.begin(); vObject_t::iterator iter_end = m_vSounds.end(); while( iter != iter_end ) { object_t* objContainer = (*iter); SoundContainer* soundContainer = objContainer->GetData(); sf::Sound* sound = soundContainer->GetSound(); if( objContainer->IsMarkedForDeletion() ) { IObjectManager::FreeObjectData( objContainer ); //fast erase from temporal sounds if( m_vSounds.size() > 1 ) { std::swap( *iter, m_vSounds.back()); iter = m_vSounds.erase( m_vSounds.end() - 1 ); } else { iter = m_vSounds.erase( iter ); } iter_end = m_vSounds.end(); } else { if( soundContainer->m_isDestroyWhenFinished && (sound->GetStatus() != sf::Sound::Playing) ) { DestroySound( objContainer->GetId() ); } ++iter; } } }
BOOL CreateSoundFromWave(PSOUND sound, PSTR waveFile, BOOL music) { MMRESULT mr = MMSYSERR_ERROR; HMMIO hmmio = NULL; ZeroMemory(sound, sizeof(SOUND)); hmmio = mmioOpen(waveFile, NULL, MMIO_ALLOCBUF | MMIO_READ); if (hmmio != NULL) { MMCKINFO riff = {0}; MMCKINFO chunk = {0}; PCMWAVEFORMAT pcmFormat = {0}; mr = mmioDescend(hmmio, &riff, NULL, 0); if (mr == 0) { /* ensure it's a proper wave file */ if (riff.ckid != FOURCC_RIFF || riff.fccType != mmioFOURCC('W', 'A', 'V', 'E')) { mr = MMSYSERR_ERROR; } } if (mr == 0) { /* find the format info */ chunk.ckid = mmioFOURCC( 'f', 'm', 't', ' ' ); if (mmioDescend(hmmio, &chunk, &riff, MMIO_FINDCHUNK) == 0) { if (mmioRead(hmmio, (HPSTR)&pcmFormat, sizeof(PCMWAVEFORMAT)) == sizeof(PCMWAVEFORMAT) && pcmFormat.wf.wFormatTag == WAVE_FORMAT_PCM) { memcpy(&sound->Format, &pcmFormat, sizeof(pcmFormat)); sound->Format.cbSize = 0; } else { mr = MMSYSERR_ERROR; } } else { mr = MMSYSERR_ERROR; } } if (mr == 0) { /* find the data chunk */ if (mmioSeek(hmmio, riff.dwDataOffset + sizeof(FOURCC), SEEK_SET) != -1) { chunk.ckid = mmioFOURCC('d', 'a', 't', 'a'); mr = mmioDescend(hmmio, &chunk, &riff, MMIO_FINDCHUNK); } else { mr = MMSYSERR_ERROR; } } if (mr == 0) { if (music) { /* if this is music, store off the streaming info and stop */ sound->IsMusic = TRUE; sound->Stream = (PSTREAMINFO)malloc(sizeof(STREAMINFO)); sound->Stream->Playing = FALSE; sound->Stream->Stream = hmmio; sound->Stream->TotalSize = chunk.cksize; sound->Stream->Riff = riff; sound->Stream->UsedSize = 0; mr = mmioGetInfo(hmmio, &sound->Stream->StreamInfo, 0); } else { /* if this is sound fx, then copy the buffer to the sound object so we can tear off instances */ MMIOINFO info = {0}; DWORD current; DWORD size = chunk.cksize; sound->IsMusic = FALSE; sound->Data = (LPWAVEHDR)malloc(sizeof(WAVEHDR)); ZeroMemory(sound->Data, sizeof(WAVEHDR)); mr = mmioGetInfo(hmmio, &info, 0); sound->Data->lpData = (LPSTR)malloc(size); sound->Data->dwBufferLength = size; for (current = 0; current < size && mr == MMSYSERR_NOERROR; ++current) { if (info.pchNext == info.pchEndRead) { mr = mmioAdvance(hmmio, &info, MMIO_READ); if (mr == MMSYSERR_NOERROR) { mr = (info.pchNext != info.pchEndRead ? MMSYSERR_NOERROR : MMSYSERR_ERROR); } } if (mr == MMSYSERR_NOERROR) { sound->Data->lpData[current] = *info.pchNext; ++info.pchNext; } } } } } if (mr == 0) { if (!music) { mmioClose(hmmio, 0); } return TRUE; } else { /* clean up any stank */ DestroySound(sound); if (hmmio) { mmioClose(hmmio, 0); } return FALSE; } }