-/* $Id$
-
-This file is part of libmspal
-Copyright © 2009 Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
#include <algorithm>
#include <cstdlib>
-#include <msp/core/except.h>
+#include <stdexcept>
#include "jukebox.h"
-#include "sound.h"
+#include "sounddecoder.h"
using namespace std;
Jukebox::Jukebox():
streamer(source),
- sound(0),
+ decoder(0),
current_track(tracks.end()),
shuffle(false)
{ }
Jukebox::~Jukebox()
{
streamer.stop();
- delete sound;
+ delete decoder;
}
void Jukebox::add_track(const string &trk)
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::play()
{
- if(tracks.empty() || sound)
+ if(tracks.empty() || decoder)
return;
- sound = new AL::Sound;
- sound->open_file(*current_track);
- streamer.play(*sound);
+ decoder = new AL::SoundDecoder;
+ decoder->open_file(*current_track);
+ streamer.play(*decoder);
}
void Jukebox::next()
void Jukebox::stop()
{
streamer.stop();
- delete sound;
- sound = 0;
+ delete decoder;
+ decoder = 0;
}
void Jukebox::tick()
{
streamer.tick();
- if(sound && sound->eof())
+ if(decoder && decoder->eof())
next();
}