X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fjukebox.cpp;h=d2a997d4cfffcf35f61f7e020183665b837f1492;hb=dfec8f9568d11c432038d55f3ceb35d59614777d;hp=b8224b29596acd234f67c5cb22c7104cbb6eb83d;hpb=32f20df0174d2872199f6b14d65e0f0d7556adaa;p=libs%2Fal.git diff --git a/source/jukebox.cpp b/source/jukebox.cpp index b8224b2..d2a997d 100644 --- a/source/jukebox.cpp +++ b/source/jukebox.cpp @@ -1,13 +1,6 @@ -/* $Id$ - -This file is part of libmspal -Copyright © 2009 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - #include #include -#include +#include #include "jukebox.h" #include "sound.h" @@ -31,25 +24,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,19 +50,19 @@ void Jukebox::clear_tracks() { stop(); tracks.clear(); - current_track=tracks.end(); + current_track = tracks.end(); } const string &Jukebox::get_current_track() const { if(tracks.empty()) - throw InvalidState("No current track"); + throw logic_error("No current track"); return *current_track; } void Jukebox::set_shuffle(bool s) { - shuffle=s; + shuffle = s; } void Jukebox::play() @@ -77,7 +70,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 +84,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 +97,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 +113,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 +124,7 @@ void Jukebox::stop() { streamer.stop(); delete sound; - sound=0; + sound = 0; } void Jukebox::tick()