mirror of https://github.com/minetest/minetest.git
Fixed more style and naming convention issues
This commit is contained in:
parent
6a33ffebd1
commit
d954cfd68b
|
@ -89,7 +89,7 @@ static const char *alErrorString(ALenum err)
|
||||||
|
|
||||||
static ALenum warn_if_error(ALenum err, const char *desc)
|
static ALenum warn_if_error(ALenum err, const char *desc)
|
||||||
{
|
{
|
||||||
if(err == AL_NO_ERROR)
|
if (err == AL_NO_ERROR)
|
||||||
return err;
|
return err;
|
||||||
warningstream<<desc<<": "<<alErrorString(err)<<std::endl;
|
warningstream<<desc<<": "<<alErrorString(err)<<std::endl;
|
||||||
return err;
|
return err;
|
||||||
|
@ -125,7 +125,7 @@ SoundBuffer *load_opened_ogg_file(OggVorbis_File *oggFile,
|
||||||
pInfo = ov_info(oggFile, -1);
|
pInfo = ov_info(oggFile, -1);
|
||||||
|
|
||||||
// Check the number of channels... always use 16-bit samples
|
// Check the number of channels... always use 16-bit samples
|
||||||
if(pInfo->channels == 1)
|
if (pInfo->channels == 1)
|
||||||
snd->format = AL_FORMAT_MONO16;
|
snd->format = AL_FORMAT_MONO16;
|
||||||
else
|
else
|
||||||
snd->format = AL_FORMAT_STEREO16;
|
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
|
// Read up to a buffer's worth of decoded sound data
|
||||||
bytes = ov_read(oggFile, array, BUFFER_SIZE, endian, 2, 1, &bitStream);
|
bytes = ov_read(oggFile, array, BUFFER_SIZE, endian, 2, 1, &bitStream);
|
||||||
|
|
||||||
if(bytes < 0)
|
if (bytes < 0)
|
||||||
{
|
{
|
||||||
ov_clear(oggFile);
|
ov_clear(oggFile);
|
||||||
infostream << "Audio: Error decoding "
|
infostream << "Audio: Error decoding "
|
||||||
|
@ -159,7 +159,7 @@ SoundBuffer *load_opened_ogg_file(OggVorbis_File *oggFile,
|
||||||
|
|
||||||
ALenum error = alGetError();
|
ALenum error = alGetError();
|
||||||
|
|
||||||
if(error != AL_NO_ERROR){
|
if (error != AL_NO_ERROR){
|
||||||
infostream<<"Audio: OpenAL error: "<<alErrorString(error)
|
infostream<<"Audio: OpenAL error: "<<alErrorString(error)
|
||||||
<<"preparing sound buffer"<<std::endl;
|
<<"preparing sound buffer"<<std::endl;
|
||||||
}
|
}
|
||||||
|
@ -288,14 +288,14 @@ public:
|
||||||
infostream<<"Audio: Initializing..."<<std::endl;
|
infostream<<"Audio: Initializing..."<<std::endl;
|
||||||
|
|
||||||
m_device = alcOpenDevice(NULL);
|
m_device = alcOpenDevice(NULL);
|
||||||
if(!m_device){
|
if (!m_device){
|
||||||
infostream<<"Audio: No audio device available, audio system "
|
infostream<<"Audio: No audio device available, audio system "
|
||||||
<<"not initialized"<<std::endl;
|
<<"not initialized"<<std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_context = alcCreateContext(m_device, NULL);
|
m_context = alcCreateContext(m_device, NULL);
|
||||||
if(!m_context){
|
if (!m_context){
|
||||||
error = alcGetError(m_device);
|
error = alcGetError(m_device);
|
||||||
infostream<<"Audio: Unable to initialize audio context, "
|
infostream<<"Audio: Unable to initialize audio context, "
|
||||||
<<"aborting audio initialization ("<<alcErrorString(error)
|
<<"aborting audio initialization ("<<alcErrorString(error)
|
||||||
|
@ -305,7 +305,7 @@ public:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!alcMakeContextCurrent(m_context) ||
|
if (!alcMakeContextCurrent(m_context) ||
|
||||||
(error = alcGetError(m_device) != ALC_NO_ERROR))
|
(error = alcGetError(m_device) != ALC_NO_ERROR))
|
||||||
{
|
{
|
||||||
infostream<<"Audio: Error setting audio context, aborting audio "
|
infostream<<"Audio: Error setting audio context, aborting audio "
|
||||||
|
@ -337,13 +337,13 @@ public:
|
||||||
alcCloseDevice(m_device);
|
alcCloseDevice(m_device);
|
||||||
m_device = NULL;
|
m_device = NULL;
|
||||||
|
|
||||||
for (UNORDERED_MAP<std::string, std::vector<SoundBuffer*> >::iterator i = m_buffers.begin();
|
for (UNORDERED_MAP<std::string, std::vector<SoundBuffer*> >::iterator it = m_buffers.begin();
|
||||||
i != m_buffers.end(); ++i) {
|
it != m_buffers.end(); ++it) {
|
||||||
for (std::vector<SoundBuffer*>::iterator iter = (*i).second.begin();
|
for (std::vector<SoundBuffer*>::iterator iter = (*it).second.begin();
|
||||||
iter != (*i).second.end(); ++iter) {
|
iter != (*it).second.end(); ++iter) {
|
||||||
delete *iter;
|
delete *iter;
|
||||||
}
|
}
|
||||||
(*i).second.clear();
|
(*it).second.clear();
|
||||||
}
|
}
|
||||||
m_buffers.clear();
|
m_buffers.clear();
|
||||||
infostream<<"Audio: Deinitialized."<<std::endl;
|
infostream<<"Audio: Deinitialized."<<std::endl;
|
||||||
|
@ -351,10 +351,10 @@ public:
|
||||||
|
|
||||||
void addBuffer(const std::string &name, SoundBuffer *buf)
|
void addBuffer(const std::string &name, SoundBuffer *buf)
|
||||||
{
|
{
|
||||||
UNORDERED_MAP<std::string, std::vector<SoundBuffer*> >::iterator i =
|
UNORDERED_MAP<std::string, std::vector<SoundBuffer*> >::iterator it =
|
||||||
m_buffers.find(name);
|
m_buffers.find(name);
|
||||||
if(i != m_buffers.end()){
|
if(it != m_buffers.end()){
|
||||||
i->second.push_back(buf);
|
it->second.push_back(buf);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
std::vector<SoundBuffer*> bufs;
|
std::vector<SoundBuffer*> bufs;
|
||||||
|
@ -365,11 +365,11 @@ public:
|
||||||
|
|
||||||
SoundBuffer* getBuffer(const std::string &name)
|
SoundBuffer* getBuffer(const std::string &name)
|
||||||
{
|
{
|
||||||
UNORDERED_MAP<std::string, std::vector<SoundBuffer*> >::iterator i =
|
UNORDERED_MAP<std::string, std::vector<SoundBuffer*> >::iterator it =
|
||||||
m_buffers.find(name);
|
m_buffers.find(name);
|
||||||
if(i == m_buffers.end())
|
if (it == m_buffers.end())
|
||||||
return NULL;
|
return NULL;
|
||||||
std::vector<SoundBuffer*> &bufs = i->second;
|
std::vector<SoundBuffer*> &bufs = it->second;
|
||||||
int j = myrand() % bufs.size();
|
int j = myrand() % bufs.size();
|
||||||
return bufs[j];
|
return bufs[j];
|
||||||
}
|
}
|
||||||
|
@ -423,7 +423,7 @@ public:
|
||||||
{
|
{
|
||||||
assert(buf);
|
assert(buf);
|
||||||
PlayingSound *sound = createPlayingSound(buf, loop, volume);
|
PlayingSound *sound = createPlayingSound(buf, loop, volume);
|
||||||
if(!sound)
|
if (!sound)
|
||||||
return -1;
|
return -1;
|
||||||
int id = m_next_id++;
|
int id = m_next_id++;
|
||||||
m_sounds_playing[id] = sound;
|
m_sounds_playing[id] = sound;
|
||||||
|
@ -434,7 +434,7 @@ public:
|
||||||
{
|
{
|
||||||
assert(buf);
|
assert(buf);
|
||||||
PlayingSound *sound = createPlayingSoundAt(buf, loop, volume, pos);
|
PlayingSound *sound = createPlayingSoundAt(buf, loop, volume, pos);
|
||||||
if(!sound)
|
if (!sound)
|
||||||
return -1;
|
return -1;
|
||||||
int id = m_next_id++;
|
int id = m_next_id++;
|
||||||
m_sounds_playing[id] = sound;
|
m_sounds_playing[id] = sound;
|
||||||
|
@ -443,10 +443,10 @@ public:
|
||||||
|
|
||||||
void deleteSound(int id)
|
void deleteSound(int id)
|
||||||
{
|
{
|
||||||
UNORDERED_MAP<int, PlayingSound*>::iterator i = m_sounds_playing.find(id);
|
UNORDERED_MAP<int, PlayingSound*>::iterator it = m_sounds_playing.find(id);
|
||||||
if(i == m_sounds_playing.end())
|
if (it == m_sounds_playing.end())
|
||||||
return;
|
return;
|
||||||
PlayingSound *sound = i->second;
|
PlayingSound *sound = it->second;
|
||||||
|
|
||||||
alDeleteSources(1, &sound->source_id);
|
alDeleteSources(1, &sound->source_id);
|
||||||
|
|
||||||
|
@ -456,20 +456,20 @@ public:
|
||||||
|
|
||||||
void pauseSnd(int id)
|
void pauseSnd(int id)
|
||||||
{
|
{
|
||||||
UNORDERED_MAP<int, PlayingSound*>::iterator i = m_sounds_playing.find(id);
|
UNORDERED_MAP<int, PlayingSound*>::iterator it = m_sounds_playing.find(id);
|
||||||
if(i == m_sounds_playing.end())
|
if (it == m_sounds_playing.end())
|
||||||
return;
|
return;
|
||||||
PlayingSound *sound = i->second;
|
PlayingSound *sound = it->second;
|
||||||
|
|
||||||
alSourcePause(sound->source_id);
|
alSourcePause(sound->source_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void resumeSnd(int id)
|
void resumeSnd(int id)
|
||||||
{
|
{
|
||||||
UNORDERED_MAP<int, PlayingSound*>::iterator i = m_sounds_playing.find(id);
|
UNORDERED_MAP<int, PlayingSound*>::iterator it = m_sounds_playing.find(id);
|
||||||
if(i == m_sounds_playing.end())
|
if (it == m_sounds_playing.end())
|
||||||
return;
|
return;
|
||||||
PlayingSound *sound = i->second;
|
PlayingSound *sound = it->second;
|
||||||
|
|
||||||
alSourcePlay(sound->source_id);
|
alSourcePlay(sound->source_id);
|
||||||
}
|
}
|
||||||
|
@ -478,20 +478,20 @@ public:
|
||||||
SoundBuffer* getFetchBuffer(const std::string &name)
|
SoundBuffer* getFetchBuffer(const std::string &name)
|
||||||
{
|
{
|
||||||
SoundBuffer *buf = getBuffer(name);
|
SoundBuffer *buf = getBuffer(name);
|
||||||
if(buf)
|
if (buf)
|
||||||
return buf;
|
return buf;
|
||||||
if(!m_fetcher)
|
if (!m_fetcher)
|
||||||
return NULL;
|
return NULL;
|
||||||
std::set<std::string> paths;
|
std::set<std::string> paths;
|
||||||
std::set<std::string> datas;
|
std::set<std::string> datas;
|
||||||
m_fetcher->fetchSounds(name, paths, datas);
|
m_fetcher->fetchSounds(name, paths, datas);
|
||||||
for(std::set<std::string>::iterator i = paths.begin();
|
for (std::set<std::string>::iterator it = paths.begin();
|
||||||
i != paths.end(); ++i){
|
it != paths.end(); ++it){
|
||||||
loadSoundFile(name, *i);
|
loadSoundFile(name, *it);
|
||||||
}
|
}
|
||||||
for(std::set<std::string>::iterator i = datas.begin();
|
for (std::set<std::string>::iterator it = datas.begin();
|
||||||
i != datas.end(); ++i){
|
it != datas.end(); ++it){
|
||||||
loadSoundData(name, *i);
|
loadSoundData(name, *it);
|
||||||
}
|
}
|
||||||
return getBuffer(name);
|
return getBuffer(name);
|
||||||
}
|
}
|
||||||
|
@ -503,27 +503,27 @@ public:
|
||||||
<<m_sounds_playing.size()<<" playing sounds, "
|
<<m_sounds_playing.size()<<" playing sounds, "
|
||||||
<<m_buffers.size()<<" sound names loaded"<<std::endl;
|
<<m_buffers.size()<<" sound names loaded"<<std::endl;
|
||||||
std::set<int> del_list;
|
std::set<int> del_list;
|
||||||
for(UNORDERED_MAP<int, PlayingSound*>::iterator i = m_sounds_playing.begin();
|
for (UNORDERED_MAP<int, PlayingSound*>::iterator it = m_sounds_playing.begin();
|
||||||
i != m_sounds_playing.end(); ++i) {
|
it != m_sounds_playing.end(); ++it) {
|
||||||
int id = i->first;
|
int id = it->first;
|
||||||
PlayingSound *sound = i->second;
|
PlayingSound *sound = it->second;
|
||||||
// If not playing, remove it
|
// If not playing, remove it
|
||||||
{
|
{
|
||||||
ALint state;
|
ALint state;
|
||||||
alGetSourcei(sound->source_id, AL_SOURCE_STATE, &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);
|
del_list.insert(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!del_list.empty())
|
if (!del_list.empty())
|
||||||
verbosestream<<"OpenALSoundManager::maintain(): deleting "
|
verbosestream<<"OpenALSoundManager::maintain(): deleting "
|
||||||
<<del_list.size()<<" playing sounds"<<std::endl;
|
<<del_list.size()<<" playing sounds"<<std::endl;
|
||||||
for(std::set<int>::iterator i = del_list.begin();
|
for (std::set<int>::iterator it = del_list.begin();
|
||||||
i != del_list.end(); ++i)
|
it != del_list.end(); ++it)
|
||||||
{
|
{
|
||||||
deleteSound(*i);
|
deleteSound(*it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -567,10 +567,10 @@ public:
|
||||||
int playSound(const std::string &name, bool loop, float volume)
|
int playSound(const std::string &name, bool loop, float volume)
|
||||||
{
|
{
|
||||||
maintain();
|
maintain();
|
||||||
if(name == "")
|
if (name == "")
|
||||||
return 0;
|
return 0;
|
||||||
SoundBuffer *buf = getFetchBuffer(name);
|
SoundBuffer *buf = getFetchBuffer(name);
|
||||||
if(!buf){
|
if (!buf){
|
||||||
infostream<<"OpenALSoundManager: \""<<name<<"\" not found."
|
infostream<<"OpenALSoundManager: \""<<name<<"\" not found."
|
||||||
<<std::endl;
|
<<std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -581,10 +581,10 @@ public:
|
||||||
int playSoundAt(const std::string &name, bool loop, float volume, v3f pos)
|
int playSoundAt(const std::string &name, bool loop, float volume, v3f pos)
|
||||||
{
|
{
|
||||||
maintain();
|
maintain();
|
||||||
if(name == "")
|
if (name == "")
|
||||||
return 0;
|
return 0;
|
||||||
SoundBuffer *buf = getFetchBuffer(name);
|
SoundBuffer *buf = getFetchBuffer(name);
|
||||||
if(!buf){
|
if (!buf){
|
||||||
infostream<<"OpenALSoundManager: \""<<name<<"\" not found."
|
infostream<<"OpenALSoundManager: \""<<name<<"\" not found."
|
||||||
<<std::endl;
|
<<std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -618,10 +618,10 @@ public:
|
||||||
|
|
||||||
void updateSoundPosition(int id, v3f pos)
|
void updateSoundPosition(int id, v3f pos)
|
||||||
{
|
{
|
||||||
UNORDERED_MAP<int, PlayingSound*>::iterator i = m_sounds_playing.find(id);
|
UNORDERED_MAP<int, PlayingSound*>::iterator it = m_sounds_playing.find(id);
|
||||||
if (i == m_sounds_playing.end())
|
if (it == m_sounds_playing.end())
|
||||||
return;
|
return;
|
||||||
PlayingSound *sound = i->second;
|
PlayingSound *sound = it->second;
|
||||||
|
|
||||||
alSourcei(sound->source_id, AL_SOURCE_RELATIVE, false);
|
alSourcei(sound->source_id, AL_SOURCE_RELATIVE, false);
|
||||||
alSource3f(sound->source_id, AL_POSITION, pos.X, pos.Y, pos.Z);
|
alSource3f(sound->source_id, AL_POSITION, pos.X, pos.Y, pos.Z);
|
||||||
|
@ -633,7 +633,7 @@ public:
|
||||||
ISoundManager *createOpenALSoundManager(OnDemandSoundFetcher *fetcher)
|
ISoundManager *createOpenALSoundManager(OnDemandSoundFetcher *fetcher)
|
||||||
{
|
{
|
||||||
OpenALSoundManager *m = new OpenALSoundManager(fetcher);
|
OpenALSoundManager *m = new OpenALSoundManager(fetcher);
|
||||||
if(m->m_is_initialized)
|
if (m->m_is_initialized)
|
||||||
return m;
|
return m;
|
||||||
delete m;
|
delete m;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in New Issue