rewrote play-stop-onStop methods in trying to fix #914 -- logic is a bit clearer now, but #914 is still not fixed

This commit is contained in:
fgerlits 2005-05-19 13:31:44 +00:00
parent 7081d4461a
commit 974ecc10a0
3 changed files with 92 additions and 70 deletions

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ Author : $Author: fgerlits $
Version : $Revision: 1.2 $ Version : $Revision: 1.3 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/CuePlayer.cxx,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/CuePlayer.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -121,10 +121,7 @@ CuePlayer :: onPlayItem(void) throw ()
try { try {
gLiveSupport->playCueAudio(playable); gLiveSupport->playCueAudio(playable);
} catch (XmlRpcException &e) { } catch (std::logic_error &e) {
std::cerr << "GLiveSupport::playCueAudio() error:"
<< std::endl << e.what() << std::endl;
} catch (std::exception &e) {
std::cerr << "GLiveSupport::playCueAudio() error:" std::cerr << "GLiveSupport::playCueAudio() error:"
<< std::endl << e.what() << std::endl; << std::endl << e.what() << std::endl;
} }
@ -197,9 +194,6 @@ CuePlayer :: onStopButtonClicked(void) throw ()
if (audioState != waitingState) { if (audioState != waitingState) {
try { try {
gLiveSupport->stopCueAudio(); gLiveSupport->stopCueAudio();
} catch (XmlRpcException &e) {
std::cerr << "GLiveSupport::stopCueAudio() error:" << std::endl
<< e.what() << std::endl;
} catch (std::logic_error &e) { } catch (std::logic_error &e) {
std::cerr << "GLiveSupport::stopCueAudio() error:" << std::endl std::cerr << "GLiveSupport::stopCueAudio() error:" << std::endl
<< e.what() << std::endl; << e.what() << std::endl;

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ Author : $Author: fgerlits $
Version : $Revision: 1.42 $ Version : $Revision: 1.43 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/GLiveSupport.cxx,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/GLiveSupport.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -598,27 +598,6 @@ GLiveSupport :: addToLiveMode(Ptr<Playable>::Ref playable)
} }
/*------------------------------------------------------------------------------
* Event handler for the "output audio player has stopped" event.
*----------------------------------------------------------------------------*/
void
LiveSupport :: GLiveSupport ::
GLiveSupport :: onStop(void) throw ()
{
Ptr<Playable>::Ref playable;
setNowPlaying(playable); // reset to empty
playable = masterPanel->getNextItemToPlay();
if (playable) {
playOutputAudio(playable);
setNowPlaying(playable);
} else {
stopOutputAudio();
}
}
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Display the playable item on the master panel as "now playing". * Display the playable item on the master panel as "now playing".
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
@ -774,10 +753,6 @@ GLiveSupport :: playOutputAudio(Ptr<Playable>::Ref playable)
throw (std::logic_error) throw (std::logic_error)
{ {
try { try {
if (outputItemPlayingNow) {
stopOutputAudio(); // stop the audio player and
} // release old resources
switch (playable->getType()) { switch (playable->getType()) {
case Playable::AudioClipType: case Playable::AudioClipType:
outputItemPlayingNow = storage->acquireAudioClip(sessionId, outputItemPlayingNow = storage->acquireAudioClip(sessionId,
@ -843,10 +818,40 @@ LiveSupport :: GLiveSupport ::
GLiveSupport :: stopOutputAudio(void) GLiveSupport :: stopOutputAudio(void)
throw (std::logic_error) throw (std::logic_error)
{ {
try {
outputPlayer->close();
if (outputItemPlayingNow) { if (outputItemPlayingNow) {
outputPlayer->close(); // triggers a call to onStop()
outputPlayerIsPaused = false;
}
}
/*------------------------------------------------------------------------------
* Event handler for the "output audio player has stopped" event.
*----------------------------------------------------------------------------*/
void
LiveSupport :: GLiveSupport ::
GLiveSupport :: onStop(void) throw ()
{
releaseOutputAudio();
Ptr<Playable>::Ref playable = masterPanel->getNextItemToPlay();
if (playable) {
playOutputAudio(playable);
}
setNowPlaying(playable);
}
/*------------------------------------------------------------------------------
* Release the resources used by the output audio player.
*----------------------------------------------------------------------------*/
void
LiveSupport :: GLiveSupport ::
GLiveSupport :: releaseOutputAudio(void)
throw (std::logic_error)
{
if (outputItemPlayingNow) {
try {
switch (outputItemPlayingNow->getType()) { switch (outputItemPlayingNow->getType()) {
case Playable::AudioClipType: case Playable::AudioClipType:
storage->releaseAudioClip(sessionId, storage->releaseAudioClip(sessionId,
@ -861,15 +866,13 @@ GLiveSupport :: stopOutputAudio(void)
default: // this never happens default: // this never happens
break; break;
} }
}
} catch (XmlRpcException &e) { } catch (XmlRpcException &e) {
Ptr<Glib::ustring>::Ref eMsg Ptr<Glib::ustring>::Ref eMsg
= getResourceUstring("audioErrorMsg"); = getResourceUstring("audioErrorMsg");
eMsg->append(e.what()); eMsg->append(e.what());
displayMessageWindow(eMsg); displayMessageWindow(eMsg);
} }
}
outputPlayerIsPaused = false;
} }
@ -881,11 +884,11 @@ LiveSupport :: GLiveSupport ::
GLiveSupport :: playCueAudio(Ptr<Playable>::Ref playable) GLiveSupport :: playCueAudio(Ptr<Playable>::Ref playable)
throw (std::logic_error) throw (std::logic_error)
{ {
try {
if (cueItemPlayingNow) { if (cueItemPlayingNow) {
stopCueAudio(); // stop the audio player and stopCueAudio(); // stop the audio player and
} // release old resources } // release old resources
try {
switch (playable->getType()) { switch (playable->getType()) {
case Playable::AudioClipType: case Playable::AudioClipType:
cueItemPlayingNow = storage->acquireAudioClip(sessionId, cueItemPlayingNow = storage->acquireAudioClip(sessionId,
@ -951,10 +954,23 @@ LiveSupport :: GLiveSupport ::
GLiveSupport :: stopCueAudio(void) GLiveSupport :: stopCueAudio(void)
throw (std::logic_error) throw (std::logic_error)
{ {
try {
cuePlayer->close();
if (cueItemPlayingNow) { if (cueItemPlayingNow) {
cuePlayer->close();
releaseCueAudio();
cuePlayerIsPaused = false;
}
}
/*------------------------------------------------------------------------------
* Release the resources used by the cue audio player.
*----------------------------------------------------------------------------*/
void
LiveSupport :: GLiveSupport ::
GLiveSupport :: releaseCueAudio(void)
throw (std::logic_error)
{
if (cueItemPlayingNow) {
try {
switch (cueItemPlayingNow->getType()) { switch (cueItemPlayingNow->getType()) {
case Playable::AudioClipType: case Playable::AudioClipType:
storage->releaseAudioClip(sessionId, storage->releaseAudioClip(sessionId,
@ -969,15 +985,13 @@ GLiveSupport :: stopCueAudio(void)
default: // this never happens default: // this never happens
break; break;
} }
}
} catch (XmlRpcException &e) { } catch (XmlRpcException &e) {
Ptr<Glib::ustring>::Ref eMsg Ptr<Glib::ustring>::Ref eMsg
= getResourceUstring("audioErrorMsg"); = getResourceUstring("audioErrorMsg");
eMsg->append(e.what()); eMsg->append(e.what());
displayMessageWindow(eMsg); displayMessageWindow(eMsg);
} }
}
cuePlayerIsPaused = false;
} }

View file

@ -22,7 +22,7 @@
Author : $Author: fgerlits $ Author : $Author: fgerlits $
Version : $Revision: 1.34 $ Version : $Revision: 1.35 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/GLiveSupport.h,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/GLiveSupport.h,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -101,7 +101,7 @@ class MasterPanelWindow;
* respective documentation. * respective documentation.
* *
* @author $Author: fgerlits $ * @author $Author: fgerlits $
* @version $Revision: 1.34 $ * @version $Revision: 1.35 $
* @see LocalizedObject#getBundle(const xmlpp::Element &) * @see LocalizedObject#getBundle(const xmlpp::Element &)
* @see AuthenticationClientFactory * @see AuthenticationClientFactory
* @see StorageClientFactory * @see StorageClientFactory
@ -235,12 +235,30 @@ class GLiveSupport : public LocalizedConfigurable,
void void
loadScratchpadContents(void) throw (); loadScratchpadContents(void) throw ();
/**
* Release the resources used by the output audio player.
*
* @exception std::logic_error in case of audio player errors.
*/
virtual void
releaseOutputAudio(void) throw (std::logic_error);
/**
* Release the resources used by the cue audio player.
*
* @exception std::logic_error in case of audio player errors.
*/
virtual void
releaseCueAudio(void) throw (std::logic_error);
public: public:
/** /**
* Constructor. * Constructor.
*/ */
GLiveSupport(void) throw () GLiveSupport(void) throw ()
: outputPlayerIsPaused(false),
cuePlayerIsPaused(false)
{ {
scratchpadContents.reset(new PlayableList()); scratchpadContents.reset(new PlayableList());
} }
@ -581,10 +599,7 @@ class GLiveSupport : public LocalizedConfigurable,
* Play a Playable object using the output audio player. * Play a Playable object using the output audio player.
* *
* @param playable the Playable object to play. * @param playable the Playable object to play.
* @exception XmlRpcException in case of storage server errors.
* @exception std::invalid_argument in case of audio player errors.
* @exception std::logic_error in case of audio player errors. * @exception std::logic_error in case of audio player errors.
* @exception std::runtime_error in case of audio player errors.
*/ */
virtual void virtual void
playOutputAudio(Ptr<Playable>::Ref playable) playOutputAudio(Ptr<Playable>::Ref playable)
@ -593,7 +608,6 @@ class GLiveSupport : public LocalizedConfigurable,
/** /**
* Stop the output audio player. * Stop the output audio player.
* *
* @exception XmlRpcException in case of storage server errors.
* @exception std::logic_error in case of audio player errors. * @exception std::logic_error in case of audio player errors.
*/ */
virtual void virtual void