From d954cfd68b02b2dd305a2a0c4ebd2783538f5279 Mon Sep 17 00:00:00 2001 From: Ian Giestas Pauli Date: Sat, 18 Feb 2017 00:07:30 -0200 Subject: [PATCH] Fixed more style and naming convention issues --- src/sound_openal.cpp | 108 +++++++++++++++++++++---------------------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/src/sound_openal.cpp b/src/sound_openal.cpp index 62ff956fc..46779a795 100644 --- a/src/sound_openal.cpp +++ b/src/sound_openal.cpp @@ -89,7 +89,7 @@ static const char *alErrorString(ALenum err) static ALenum warn_if_error(ALenum err, const char *desc) { - if(err == AL_NO_ERROR) + if (err == AL_NO_ERROR) return err; warningstream<channels == 1) + if (pInfo->channels == 1) snd->format = AL_FORMAT_MONO16; else snd->format = AL_FORMAT_STEREO16; @@ -139,7 +139,7 @@ SoundBuffer *load_opened_ogg_file(OggVorbis_File *oggFile, // Read up to a buffer's worth of decoded sound data bytes = ov_read(oggFile, array, BUFFER_SIZE, endian, 2, 1, &bitStream); - if(bytes < 0) + if (bytes < 0) { ov_clear(oggFile); infostream << "Audio: Error decoding " @@ -159,7 +159,7 @@ SoundBuffer *load_opened_ogg_file(OggVorbis_File *oggFile, ALenum error = alGetError(); - if(error != AL_NO_ERROR){ + if (error != AL_NO_ERROR){ infostream<<"Audio: OpenAL error: "< >::iterator i = m_buffers.begin(); - i != m_buffers.end(); ++i) { - for (std::vector::iterator iter = (*i).second.begin(); - iter != (*i).second.end(); ++iter) { + for (UNORDERED_MAP >::iterator it = m_buffers.begin(); + it != m_buffers.end(); ++it) { + for (std::vector::iterator iter = (*it).second.begin(); + iter != (*it).second.end(); ++iter) { delete *iter; } - (*i).second.clear(); + (*it).second.clear(); } m_buffers.clear(); infostream<<"Audio: Deinitialized."< >::iterator i = + UNORDERED_MAP >::iterator it = m_buffers.find(name); - if(i != m_buffers.end()){ - i->second.push_back(buf); + if(it != m_buffers.end()){ + it->second.push_back(buf); return; } std::vector bufs; @@ -365,11 +365,11 @@ public: SoundBuffer* getBuffer(const std::string &name) { - UNORDERED_MAP >::iterator i = + UNORDERED_MAP >::iterator it = m_buffers.find(name); - if(i == m_buffers.end()) + if (it == m_buffers.end()) return NULL; - std::vector &bufs = i->second; + std::vector &bufs = it->second; int j = myrand() % bufs.size(); return bufs[j]; } @@ -423,7 +423,7 @@ public: { assert(buf); PlayingSound *sound = createPlayingSound(buf, loop, volume); - if(!sound) + if (!sound) return -1; int id = m_next_id++; m_sounds_playing[id] = sound; @@ -434,7 +434,7 @@ public: { assert(buf); PlayingSound *sound = createPlayingSoundAt(buf, loop, volume, pos); - if(!sound) + if (!sound) return -1; int id = m_next_id++; m_sounds_playing[id] = sound; @@ -443,10 +443,10 @@ public: void deleteSound(int id) { - UNORDERED_MAP::iterator i = m_sounds_playing.find(id); - if(i == m_sounds_playing.end()) + UNORDERED_MAP::iterator it = m_sounds_playing.find(id); + if (it == m_sounds_playing.end()) return; - PlayingSound *sound = i->second; + PlayingSound *sound = it->second; alDeleteSources(1, &sound->source_id); @@ -456,20 +456,20 @@ public: void pauseSnd(int id) { - UNORDERED_MAP::iterator i = m_sounds_playing.find(id); - if(i == m_sounds_playing.end()) + UNORDERED_MAP::iterator it = m_sounds_playing.find(id); + if (it == m_sounds_playing.end()) return; - PlayingSound *sound = i->second; + PlayingSound *sound = it->second; alSourcePause(sound->source_id); } void resumeSnd(int id) { - UNORDERED_MAP::iterator i = m_sounds_playing.find(id); - if(i == m_sounds_playing.end()) + UNORDERED_MAP::iterator it = m_sounds_playing.find(id); + if (it == m_sounds_playing.end()) return; - PlayingSound *sound = i->second; + PlayingSound *sound = it->second; alSourcePlay(sound->source_id); } @@ -478,20 +478,20 @@ public: SoundBuffer* getFetchBuffer(const std::string &name) { SoundBuffer *buf = getBuffer(name); - if(buf) + if (buf) return buf; - if(!m_fetcher) + if (!m_fetcher) return NULL; std::set paths; std::set datas; m_fetcher->fetchSounds(name, paths, datas); - for(std::set::iterator i = paths.begin(); - i != paths.end(); ++i){ - loadSoundFile(name, *i); + for (std::set::iterator it = paths.begin(); + it != paths.end(); ++it){ + loadSoundFile(name, *it); } - for(std::set::iterator i = datas.begin(); - i != datas.end(); ++i){ - loadSoundData(name, *i); + for (std::set::iterator it = datas.begin(); + it != datas.end(); ++it){ + loadSoundData(name, *it); } return getBuffer(name); } @@ -503,27 +503,27 @@ public: < del_list; - for(UNORDERED_MAP::iterator i = m_sounds_playing.begin(); - i != m_sounds_playing.end(); ++i) { - int id = i->first; - PlayingSound *sound = i->second; + for (UNORDERED_MAP::iterator it = m_sounds_playing.begin(); + it != m_sounds_playing.end(); ++it) { + int id = it->first; + PlayingSound *sound = it->second; // If not playing, remove it { ALint state; alGetSourcei(sound->source_id, AL_SOURCE_STATE, &state); - if(state != AL_PLAYING && state != AL_PAUSED) { + if (state != AL_PLAYING && state != AL_PAUSED) { del_list.insert(id); } } } - if(!del_list.empty()) + if (!del_list.empty()) verbosestream<<"OpenALSoundManager::maintain(): deleting " <::iterator i = del_list.begin(); - i != del_list.end(); ++i) + for (std::set::iterator it = del_list.begin(); + it != del_list.end(); ++it) { - deleteSound(*i); + deleteSound(*it); } } @@ -567,10 +567,10 @@ public: int playSound(const std::string &name, bool loop, float volume) { maintain(); - if(name == "") + if (name == "") return 0; SoundBuffer *buf = getFetchBuffer(name); - if(!buf){ + if (!buf){ infostream<<"OpenALSoundManager: \""<::iterator i = m_sounds_playing.find(id); - if (i == m_sounds_playing.end()) + UNORDERED_MAP::iterator it = m_sounds_playing.find(id); + if (it == m_sounds_playing.end()) return; - PlayingSound *sound = i->second; + PlayingSound *sound = it->second; alSourcei(sound->source_id, AL_SOURCE_RELATIVE, false); alSource3f(sound->source_id, AL_POSITION, pos.X, pos.Y, pos.Z); @@ -633,7 +633,7 @@ public: ISoundManager *createOpenALSoundManager(OnDemandSoundFetcher *fetcher) { OpenALSoundManager *m = new OpenALSoundManager(fetcher); - if(m->m_is_initialized) + if (m->m_is_initialized) return m; delete m; return NULL;