]> git.tdb.fi Git - libs/al.git/commitdiff
Style update: add spaces around assignments
authorMikko Rasa <tdb@tdb.fi>
Sat, 21 Jan 2012 00:02:34 +0000 (02:02 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sat, 21 Jan 2012 00:02:34 +0000 (02:02 +0200)
source/context.cpp
source/device.cpp
source/jukebox.cpp
source/sound.cpp
source/soundscape.cpp
source/source.cpp
source/streamer.cpp

index 847680a20a338c7439be2beb3fed0a3f54a081b7..bc2964f3e0fc4396169460273d1b141b016f8e25 100644 (file)
@@ -14,7 +14,7 @@ namespace AL {
 
 Context::Context(Device &dev)
 {
-       context=alcCreateContext(dev.get_device(), 0);
+       context = alcCreateContext(dev.get_device(), 0);
        if(!context)
                throw Exception("Couldn't create OpenAL context");
 
index dcc78f1aa949b37dbe173adf96a3cb140e1f41ff..aea089790ca51251dc4acd3407a0e78880ece1d7 100644 (file)
@@ -15,14 +15,14 @@ namespace AL {
 
 Device::Device()
 {
-       dev=alcOpenDevice(0);
+       dev = alcOpenDevice(0);
        if(!dev)
                throw Exception("Couldn't get OpenAL device");
 }
 
 Device::Device(const string &spec)
 {
-       dev=alcOpenDevice(spec.c_str());
+       dev = alcOpenDevice(spec.c_str());
        if(!dev)
                throw Exception("Couldn't get OpenAL device");
 }
index b8224b29596acd234f67c5cb22c7104cbb6eb83d..95ca6a05e9e2656dab7d85708c98d07e0606cafd 100644 (file)
@@ -31,25 +31,25 @@ Jukebox::~Jukebox()
 
 void Jukebox::add_track(const string &trk)
 {
-       bool was_empty=tracks.empty();
+       bool was_empty = tracks.empty();
        tracks.push_back(trk);
        if(was_empty)
        {
-               current_track=tracks.begin();
+               current_track = tracks.begin();
                signal_track_changed.emit(*current_track);
        }
 }
 
 void Jukebox::remove_track(const string &trk)
 {
-       list<string>::iterator i=find(tracks.begin(), tracks.end(), trk);
+       list<string>::iterator i = find(tracks.begin(), tracks.end(), trk);
        if(i!=tracks.end())
        {
                if(i==current_track)
                        next();
                tracks.erase(i);
                if(tracks.empty())
-                       current_track=tracks.end();
+                       current_track = tracks.end();
        }
 }
 
@@ -57,7 +57,7 @@ void Jukebox::clear_tracks()
 {
        stop();
        tracks.clear();
-       current_track=tracks.end();
+       current_track = tracks.end();
 }
 
 const string &Jukebox::get_current_track() const
@@ -69,7 +69,7 @@ const string &Jukebox::get_current_track() const
 
 void Jukebox::set_shuffle(bool s)
 {
-       shuffle=s;
+       shuffle = s;
 }
 
 void Jukebox::play()
@@ -77,7 +77,7 @@ void Jukebox::play()
        if(tracks.empty() || sound)
                return;
 
-       sound=new AL::Sound;
+       sound = new AL::Sound;
        sound->open_file(*current_track);
        streamer.play(*sound);
 }
@@ -91,7 +91,7 @@ void Jukebox::next()
                {
                        while(1)
                        {
-                               list<string>::iterator i=tracks.begin();
+                               list<string>::iterator i = tracks.begin();
                                advance(i, rand()%tracks.size());
                                if(i!=current_track)
                                {
@@ -104,7 +104,7 @@ void Jukebox::next()
                {
                        ++current_track;
                        if(current_track==tracks.end())
-                               current_track=tracks.begin();
+                               current_track = tracks.begin();
                }
                signal_track_changed.emit(*current_track);
        }
@@ -120,7 +120,7 @@ void Jukebox::previous()
        if(tracks.size()>1)
        {
                if(current_track==tracks.begin())
-                       current_track=tracks.end();
+                       current_track = tracks.end();
                --current_track;
                signal_track_changed.emit(*current_track);
        }
@@ -131,7 +131,7 @@ void Jukebox::stop()
 {
        streamer.stop();
        delete sound;
-       sound=0;
+       sound = 0;
 }
 
 void Jukebox::tick()
index 15596053309f2ba436da99e3bd6bba69b4f892b4..9ac1143e32f2b8206d50db4c51e234bdcd4e7331 100644 (file)
@@ -24,24 +24,24 @@ struct MemorySource
 
 size_t memory_read(void *ptr, size_t size, size_t nmemb, void *src)
 {
-       MemorySource &memsrc=*reinterpret_cast<MemorySource *>(src);
-       unsigned len=min(size*nmemb, memsrc.length-memsrc.pos);
+       MemorySource &memsrc = *reinterpret_cast<MemorySource *>(src);
+       unsigned len = min(size*nmemb, memsrc.length-memsrc.pos);
        memcpy(ptr, reinterpret_cast<const char *>(memsrc.data)+memsrc.pos, len);
-       memsrc.pos+=len;
+       memsrc.pos += len;
 
        return len/size;
 }
 
 int memory_seek(void *src, ogg_int64_t offset, int whence)
 {
-       MemorySource &memsrc=*reinterpret_cast<MemorySource *>(src);
+       MemorySource &memsrc = *reinterpret_cast<MemorySource *>(src);
        if(whence==SEEK_SET)
-               memsrc.pos=offset;
+               memsrc.pos = offset;
        else if(whence==SEEK_CUR)
-               memsrc.pos+=offset;
+               memsrc.pos += offset;
        else if(whence==SEEK_END)
-               memsrc.pos=memsrc.length-offset;
-       memsrc.pos=min(memsrc.pos, memsrc.length);
+               memsrc.pos = memsrc.length-offset;
+       memsrc.pos = min(memsrc.pos, memsrc.length);
 
        return memsrc.pos;
 }
@@ -54,7 +54,7 @@ int memory_close(void *src)
 
 long memory_tell(void *src)
 {
-       MemorySource &memsrc=*reinterpret_cast<MemorySource *>(src);
+       MemorySource &memsrc = *reinterpret_cast<MemorySource *>(src);
        return memsrc.pos;
 }
 
@@ -75,7 +75,7 @@ Sound::Sound():
        data(0),
        eof_flag(false)
 {
-       ovfile.datasource=0;
+       ovfile.datasource = 0;
 }
 
 Sound::~Sound()
@@ -100,7 +100,7 @@ void Sound::open_memory(const void *d, unsigned len)
        if(ovfile.datasource)
                throw InvalidState("Sound has already been opened");
 
-       MemorySource *src=new MemorySource(d, len);
+       MemorySource *src = new MemorySource(d, len);
        if(ov_open_callbacks(src, &ovfile, 0, 0, memory_callbacks)<0)
        {
                delete src;
@@ -115,14 +115,14 @@ void Sound::load_data()
        if(data)
                throw InvalidState("Data has already been loaded");
 
-       size=ov_pcm_total(&ovfile, 0)*4;
-       char *dptr=new char[size];
-       unsigned pos=0;
-       while(unsigned len=read(dptr+pos, size-pos))
-               pos+=len;
-       data=dptr;
-       size=pos;
-       read_pos=0;
+       size = ov_pcm_total(&ovfile, 0)*4;
+       char *dptr = new char[size];
+       unsigned pos = 0;
+       while(unsigned len = read(dptr+pos, size-pos))
+               pos += len;
+       data = dptr;
+       size = pos;
+       read_pos = 0;
 }
 
 void Sound::load_file(const std::string &fn)
@@ -148,7 +148,7 @@ void Sound::close()
 void Sound::rewind()
 {
        if(data)
-               read_pos=0;
+               read_pos = 0;
        else
                ov_pcm_seek(&ovfile, 0);
 }
@@ -157,19 +157,19 @@ unsigned Sound::read(char *buf, unsigned len)
 {
        if(data)
        {
-               len=min(len, size-read_pos);
+               len = min(len, size-read_pos);
                memcpy(buf, data+read_pos, len);
-               read_pos+=len;
+               read_pos += len;
                return len;
        }
        else if(ovfile.datasource)
        {
-               int section=0;
-               int res=ov_read(&ovfile, buf, len, 0, 2, 1, &section);
+               int section = 0;
+               int res = ov_read(&ovfile, buf, len, 0, 2, 1, &section);
                if(res<0)
                        throw Exception("Error reading ogg vorbis file");
                else if(res==0)
-                       eof_flag=true;
+                       eof_flag = true;
                return res;
        }
        else
@@ -186,14 +186,14 @@ const char *Sound::get_data() const
 void Sound::open_common()
 {
        delete data;
-       data=0;
+       data = 0;
 
-       vorbis_info *info=ov_info(&ovfile, -1);
-       freq=info->rate;
+       vorbis_info *info = ov_info(&ovfile, -1);
+       freq = info->rate;
        switch(info->channels)
        {
-       case 1: format=MONO16; break;
-       case 2: format=STEREO16; break;
+       case 1: format = MONO16; break;
+       case 2: format = STEREO16; break;
        default: throw Exception("Unsupported number of channels");
        }
 }
index d36b3bf7c1648c236fa3fde5c0890a9e707b0268..0b126ac01bde48190480adb6a0f94fce5568652c 100644 (file)
@@ -26,7 +26,7 @@ void SoundScape::add_source(Source &src)
 
 Source &SoundScape::play(const Buffer &buf, float x, float y, float z)
 {
-       Source *src=new Source;
+       Source *src = new Source;
        add_source(*src);
        src->set_buffer(buf);
        src->set_position(x, y, z);
@@ -41,7 +41,7 @@ void SoundScape::tick()
                if((*i)->get_state()==STOPPED)
                {
                        delete *i;
-                       i=sources.erase(i);
+                       i = sources.erase(i);
                }
                else
                        ++i;
index 348b41e37cd6d98d12665a9cc6929b064a9db518..23770b0163cf8418a85f831eecf55af0aa545c07 100644 (file)
@@ -96,7 +96,7 @@ void Source::queue_buffers(const vector<const Buffer *> &buffers)
 
 void Source::queue_buffer(const Buffer &buffer)
 {
-       uint bid=buffer.get_id();
+       uint bid = buffer.get_id();
        alSourceQueueBuffers(id, 1, &bid);
 }
 
@@ -111,7 +111,7 @@ void Source::unqueue_buffers(const vector<const Buffer *> &buffers)
 
 void Source::unqueue_buffer(const Buffer &buffer)
 {
-       uint bid=buffer.get_id();
+       uint bid = buffer.get_id();
        alSourceUnqueueBuffers(id, 1, &bid);
 }
 
@@ -122,14 +122,14 @@ void Source::clear_buffers()
 
 unsigned Source::get_buffers_queued() const
 {
-       int n=0;
+       int n = 0;
        get_attribute(AL_BUFFERS_QUEUED, &n);
        return n;
 }
 
 unsigned Source::get_buffers_processed() const
 {
-       int n=0;
+       int n = 0;
        get_attribute(AL_BUFFERS_PROCESSED, &n);
        return n;
 }
index 8fe7483cc735ffbc5fab4dfa3c8185b35fc5044d..6808b181678f4535dca699e5f25f107fa553d592 100644 (file)
@@ -29,20 +29,20 @@ Streamer::~Streamer()
 
 void Streamer::play(Sound &s)
 {
-       snd=&s;
+       snd = &s;
        tick();
        src.play();
 }
 
 void Streamer::stop()
 {
-       snd=0;
+       snd = 0;
        src.stop();
 }
 
 void Streamer::tick()
 {
-       if(unsigned n=src.get_buffers_processed())
+       if(unsigned n = src.get_buffers_processed())
        {
                for(unsigned i=0; i<n; ++i)
                {
@@ -58,24 +58,24 @@ void Streamer::tick()
        if(src.get_state()!=PLAYING && src.get_state()!=PAUSED)
                src.play();
 
-       unsigned freq=snd->get_frequency();
-       unsigned chunk_size=freq&~0xF;
-       unsigned queued=src.get_buffers_queued();
+       unsigned freq = snd->get_frequency();
+       unsigned chunk_size = freq&~0xF;
+       unsigned queued = src.get_buffers_queued();
        for(unsigned i=queued; i<4; ++i)
        {
                char data[chunk_size];
-               unsigned pos=0;
+               unsigned pos = 0;
                while(pos<chunk_size)
                {
-                       unsigned len=snd->read(data+pos, chunk_size-pos);
+                       unsigned len = snd->read(data+pos, chunk_size-pos);
                        if(len==0)
                                break;
-                       pos+=len;
+                       pos += len;
                }
 
                if(pos)
                {
-                       Buffer *buf=new Buffer;
+                       Buffer *buf = new Buffer;
                        buf->data(snd->get_format(), data, pos, freq);
                        src.queue_buffer(*buf);
                        buffers.push_back(buf);
@@ -83,7 +83,7 @@ void Streamer::tick()
        }
 
        if(snd->eof())
-               snd=0;
+               snd = 0;
 }
 
 } // namespace AL