|
From: Lasse Kärkkäi. <tr...@us...> - 2010-08-12 22:44:50
|
Module: performous
Branch: master
Commit: 2a086a48576811bea2b495a908a7348d63050568
Author: Vincent Le Ligeour <yo...@us...>
Date: Sun May 30 13:43:59 2010 +0200
Added few methods to enable simple track play
---
game/audio.cc | 21 ++++++++++++++++++---
1 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/game/audio.cc b/game/audio.cc
index 66fe695..bc45462 100644
--- a/game/audio.cc
+++ b/game/audio.cc
@@ -145,24 +145,39 @@ void Audio::fadeout(double fadeTime) {
}
double Audio::getPosition() const {
- return 0.0;
+ boost::mutex::scoped_lock l(self->mutex);
+ return self->playing.empty() ? getNaN() : self->playing[0].pos();
}
double Audio::getLength() const {
- return 0.0;
+ boost::mutex::scoped_lock l(self->mutex);
+ return self->playing.empty() ? getNaN() : self->playing[0].duration();
}
bool Audio::isPlaying() const {
- return false;
+ boost::mutex::scoped_lock l(self->mutex);
+ return !self->playing.empty();
}
void Audio::seek(double offset) {
+ boost::mutex::scoped_lock l(self->mutex);
+ for(boost::ptr_vector<Music>::iterator it = self->playing.begin() ; it != self->playing.end() ; ++it) {
+ it->seek(clamp(it->pos() + offset, 0.0, it->duration()));
+ }
+ pause(false);
}
void Audio::seekPos(double pos) {
+ boost::mutex::scoped_lock l(self->mutex);
+ for(boost::ptr_vector<Music>::iterator it = self->playing.begin() ; it != self->playing.end() ; ++it) {
+ it->seek(pos);
+ }
+ pause(false);
}
void Audio::pause(bool state) {
+ boost::mutex::scoped_lock l(self->mutex);
+ pause(state);
}
void Audio::streamFade(std::string stream_id, double level) {
|