From 2a685e572e2ab8d9f50129de3f0869628edb3d8e Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 21 Jan 2012 02:02:34 +0200 Subject: [PATCH] Style update: add spaces around assignments --- source/context.cpp | 2 +- source/device.cpp | 4 +-- source/jukebox.cpp | 22 ++++++++-------- source/sound.cpp | 60 +++++++++++++++++++++---------------------- source/soundscape.cpp | 4 +-- source/source.cpp | 8 +++--- source/streamer.cpp | 22 ++++++++-------- 7 files changed, 61 insertions(+), 61 deletions(-) diff --git a/source/context.cpp b/source/context.cpp index 847680a..bc2964f 100644 --- a/source/context.cpp +++ b/source/context.cpp @@ -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"); diff --git a/source/device.cpp b/source/device.cpp index dcc78f1..aea0897 100644 --- a/source/device.cpp +++ b/source/device.cpp @@ -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"); } diff --git a/source/jukebox.cpp b/source/jukebox.cpp index b8224b2..95ca6a0 100644 --- a/source/jukebox.cpp +++ b/source/jukebox.cpp @@ -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::iterator i=find(tracks.begin(), tracks.end(), trk); + list::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::iterator i=tracks.begin(); + list::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() diff --git a/source/sound.cpp b/source/sound.cpp index 1559605..9ac1143 100644 --- a/source/sound.cpp +++ b/source/sound.cpp @@ -24,24 +24,24 @@ struct MemorySource size_t memory_read(void *ptr, size_t size, size_t nmemb, void *src) { - MemorySource &memsrc=*reinterpret_cast(src); - unsigned len=min(size*nmemb, memsrc.length-memsrc.pos); + MemorySource &memsrc = *reinterpret_cast(src); + unsigned len = min(size*nmemb, memsrc.length-memsrc.pos); memcpy(ptr, reinterpret_cast(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(src); + MemorySource &memsrc = *reinterpret_cast(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(src); + MemorySource &memsrc = *reinterpret_cast(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, §ion); + int section = 0; + int res = ov_read(&ovfile, buf, len, 0, 2, 1, §ion); 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"); } } diff --git a/source/soundscape.cpp b/source/soundscape.cpp index d36b3bf..0b126ac 100644 --- a/source/soundscape.cpp +++ b/source/soundscape.cpp @@ -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; diff --git a/source/source.cpp b/source/source.cpp index 348b41e..23770b0 100644 --- a/source/source.cpp +++ b/source/source.cpp @@ -96,7 +96,7 @@ void Source::queue_buffers(const vector &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 &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; } diff --git a/source/streamer.cpp b/source/streamer.cpp index 8fe7483..6808b18 100644 --- a/source/streamer.cpp +++ b/source/streamer.cpp @@ -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; iget_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(posread(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 -- 2.43.0