author | sandman <sandman> | 2002-06-18 12:46:11 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-06-18 12:46:11 (UTC) |
commit | 61e2f9e5eb634b17ef480d79bdbcbc3a715990cb (patch) (side-by-side diff) | |
tree | 013600ee0ababcc25f37ff98cede8f67cbdc9d2a /library/sound.cpp | |
parent | e21322ab34a8df36344eece685e604abe4f83fc6 (diff) | |
download | opie-61e2f9e5eb634b17ef480d79bdbcbc3a715990cb.zip opie-61e2f9e5eb634b17ef480d79bdbcbc3a715990cb.tar.gz opie-61e2f9e5eb634b17ef480d79bdbcbc3a715990cb.tar.bz2 |
Moved platform specific things from custom-*.h #defines to virtual methods
in libopie/odevice.{h,cpp}
Minor fix in Sound + reformating
-rw-r--r-- | library/sound.cpp | 63 |
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 @@ -101,45 +101,49 @@ static int WAVsoundDuration(const QString& filename) } 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 ( ); + } void timerEvent ( QTimerEvent *e ) { - 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 Sound::Sound(const QString& name) { @@ -157,9 +161,8 @@ Sound::~Sound() void Sound::play() { #ifndef QT_NO_SOUND - d->killTimers(); d->playLoop(1); #endif } @@ -181,8 +184,10 @@ void Sound::stop() bool Sound::isFinished() const { #ifndef QT_NO_SOUND return d->isFinished(); +#else + return true; #endif } void Sound::soundAlarm() |