From ad9b8acf2bfe25091370dd8d7fc8b3d5c3457c84 Mon Sep 17 00:00:00 2001 From: fgerlits Date: Fri, 1 Jul 2005 22:19:30 +0000 Subject: [PATCH] added flags to prevent pause from firing onStop() --- .../products/gLiveSupport/src/CuePlayer.cxx | 8 ++- .../gLiveSupport/src/GLiveSupport.cxx | 6 +- .../products/gLiveSupport/src/GLiveSupport.h | 62 ++++++++++++++++++- .../products/gLiveSupport/src/NowPlaying.cxx | 5 +- 4 files changed, 76 insertions(+), 5 deletions(-) diff --git a/livesupport/products/gLiveSupport/src/CuePlayer.cxx b/livesupport/products/gLiveSupport/src/CuePlayer.cxx index 9b9b46d82..98b358e90 100644 --- a/livesupport/products/gLiveSupport/src/CuePlayer.cxx +++ b/livesupport/products/gLiveSupport/src/CuePlayer.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.4 $ + Version : $Revision: 1.5 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/CuePlayer.cxx,v $ ------------------------------------------------------------------------------*/ @@ -174,11 +174,13 @@ void CuePlayer :: onPauseButtonClicked(void) throw () { try { + gLiveSupport->setCueAudioPauseFlag(true); gLiveSupport->pauseCueAudio(); audioState = pausedState; remove(*pauseButton); pack_end(*playButton, Gtk::PACK_SHRINK, 3); playButton->show(); + gLiveSupport->setCueAudioPauseFlag(false); } catch (std::logic_error &e) { std::cerr << "GLiveSupport::pauseCueAudio() error:" << std::endl << e.what() << std::endl; @@ -209,6 +211,10 @@ CuePlayer :: onStopButtonClicked(void) throw () void CuePlayer :: onStop(void) throw () { + if (gLiveSupport->getCueAudioPauseFlag()) { + return; // onStop() is fired on pause, unfortunately + } + switch (audioState) { case pausedState: remove(*playButton); diff --git a/livesupport/products/gLiveSupport/src/GLiveSupport.cxx b/livesupport/products/gLiveSupport/src/GLiveSupport.cxx index 6adfca537..058f92eb4 100644 --- a/livesupport/products/gLiveSupport/src/GLiveSupport.cxx +++ b/livesupport/products/gLiveSupport/src/GLiveSupport.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.55 $ + Version : $Revision: 1.56 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/GLiveSupport.cxx,v $ ------------------------------------------------------------------------------*/ @@ -836,6 +836,10 @@ void LiveSupport :: GLiveSupport :: GLiveSupport :: onStop(void) throw () { + if (getOutputAudioPauseFlag()) { + return; // onStop() is fired on pause, unfortunately + } + releaseOutputAudio(); Ptr::Ref playable = masterPanel->getNextItemToPlay(); diff --git a/livesupport/products/gLiveSupport/src/GLiveSupport.h b/livesupport/products/gLiveSupport/src/GLiveSupport.h index 5413ab394..227e9d029 100644 --- a/livesupport/products/gLiveSupport/src/GLiveSupport.h +++ b/livesupport/products/gLiveSupport/src/GLiveSupport.h @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.41 $ + Version : $Revision: 1.42 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/GLiveSupport.h,v $ ------------------------------------------------------------------------------*/ @@ -102,7 +102,7 @@ class MasterPanelWindow; * respective documentation. * * @author $Author: fgerlits $ - * @version $Revision: 1.41 $ + * @version $Revision: 1.42 $ * @see LocalizedObject#getBundle(const xmlpp::Element &) * @see AuthenticationClientFactory * @see StorageClientFactory @@ -212,11 +212,21 @@ class GLiveSupport : public LocalizedConfigurable, */ bool outputPlayerIsPaused; + /** + * Set to prevent onStop() from being fired by pausing. + */ + bool outputAudioPauseFlag; + /** * True if the cue audio player has been paused. */ bool cuePlayerIsPaused; + /** + * Set to prevent onStop() from being fired by pausing. + */ + bool cueAudioPauseFlag; + /** * The raw image containing the station logo. */ @@ -624,6 +634,30 @@ class GLiveSupport : public LocalizedConfigurable, pauseOutputAudio(void) throw (std::logic_error); + /** + * Set the output audio pause flag. This is set to true before + * a call to pauseOutputAudio() and to false afterwards, in + * order to prevent the onStop() method from executing on pause. + * + * @param value the new value of the flag. + */ + virtual void + setOutputAudioPauseFlag(bool value) throw () + { + outputAudioPauseFlag = value; + } + + /** + * Get the output audio pause flag. + * + * @see setOutputAudioPauseFlag() + */ + virtual bool + getOutputAudioPauseFlag(void) throw () + { + return outputAudioPauseFlag; + } + /** * Play a Playable object using the cue audio player. * @@ -656,6 +690,30 @@ class GLiveSupport : public LocalizedConfigurable, pauseCueAudio(void) throw (std::logic_error); + /** + * Set the cue audio pause flag. This is set to true before + * a call to pauseCueAudio() and to false afterwards, in + * order to prevent the onStop() method from executing on pause. + * + * @param value the new value of the flag. + */ + virtual void + setCueAudioPauseFlag(bool value) throw () + { + cueAudioPauseFlag = value; + } + + /** + * Get the cue audio pause flag. + * + * @see setOutputAudioPauseFlag() + */ + virtual bool + getCueAudioPauseFlag(void) throw () + { + return cueAudioPauseFlag; + } + /** * Attach a listener for the cue audio player (the listener * will be notified when the cue audio player has stopped playing). diff --git a/livesupport/products/gLiveSupport/src/NowPlaying.cxx b/livesupport/products/gLiveSupport/src/NowPlaying.cxx index db8a49bd6..319f59635 100644 --- a/livesupport/products/gLiveSupport/src/NowPlaying.cxx +++ b/livesupport/products/gLiveSupport/src/NowPlaying.cxx @@ -22,7 +22,7 @@ Author : $Author: fgerlits $ - Version : $Revision: 1.5 $ + Version : $Revision: 1.6 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/NowPlaying.cxx,v $ ------------------------------------------------------------------------------*/ @@ -162,6 +162,8 @@ NowPlaying :: onPlayButtonClicked(void) throw () void NowPlaying :: onPauseButtonClicked(void) throw () { + gLiveSupport->setOutputAudioPauseFlag(true); + gLiveSupport->pauseOutputAudio(); remove(*pauseButton); @@ -169,6 +171,7 @@ NowPlaying :: onPauseButtonClicked(void) throw () playButton->show(); isPaused = true; + gLiveSupport->setOutputAudioPauseFlag(false); }