summaryrefslogtreecommitdiff
path: root/library/sound.cpp
Side-by-side diff
Diffstat (limited to 'library/sound.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/sound.cpp63
1 files changed, 34 insertions, 29 deletions
diff --git a/library/sound.cpp b/library/sound.cpp
index 602fcf0..1ff3b3f 100644
--- a/library/sound.cpp
+++ b/library/sound.cpp
@@ -104,19 +104,19 @@ class SoundData : public QSound {
public:
- SoundData(const QString& name) :
- QSound(Resource::findSound(name)),
- filename(Resource::findSound(name))
- {
- loopsleft=0;
- }
+ SoundData ( const QString& name ) :
+ QSound ( Resource::findSound ( name )),
+ filename ( Resource::findSound ( name ))
+ {
+ loopsleft=0;
+ ms = WAVsoundDuration(filename);
+ }
- void playLoop(int loopcnt = -1)
- {
- // needs server support
- loopsleft = loopcnt;
+ void playLoop ( int loopcnt = -1 )
+ {
+ // needs server support
+ loopsleft = loopcnt;
- int ms = WAVsoundDuration(filename);
- if ( ms )
- startTimer(ms > 50 ? ms-50 : 0); // 50 for latency
- play();
- }
+ if ( ms )
+ startTimer ( ms > 50 ? ms-50 : 0 ); // 50 for latency
+ play ( );
+ }
@@ -124,19 +124,23 @@ public:
{
- if (loopsleft >= 0) {
- if (--loopsleft <= 0)
- killTimer (e->timerId());
- return;
- }
- play();
- }
+ if ( loopsleft >= 0 ) {
+ if ( --loopsleft <= 0 ) {
+ killTimer ( e-> timerId ( ));
+ loopsleft = 0;
+ return;
+ }
+ }
+ play();
+ }
- bool isFinished ( ) const
- {
- return ( loopsleft == 0 );
- }
+ bool isFinished ( ) const
+ {
+ return ( loopsleft == 0 );
+ }
private:
- QString filename;
- int loopsleft;
+ QString filename;
+ int loopsleft;
+ int ms;
};
+
#endif
@@ -160,3 +164,2 @@ void Sound::play()
#ifndef QT_NO_SOUND
- d->killTimers();
d->playLoop(1);
@@ -184,2 +187,4 @@ bool Sound::isFinished() const
return d->isFinished();
+#else
+ return true;
#endif