diff --git a/livesupport/products/gLiveSupport/etc/gLiveSupport.xml b/livesupport/products/gLiveSupport/etc/gLiveSupport.xml index d908ced04..6b225559d 100644 --- a/livesupport/products/gLiveSupport/etc/gLiveSupport.xml +++ b/livesupport/products/gLiveSupport/etc/gLiveSupport.xml @@ -7,7 +7,8 @@ authenticationClientFactory, storageClientFactory, schedulerClientFactory, - audioPlayer) > + outputPlayer, + cuePlayer) > @@ -72,10 +73,16 @@ + + + - + + + + ]> @@ -111,9 +118,21 @@ /> - - - + + + + + + + + + + + diff --git a/livesupport/products/gLiveSupport/src/GLiveSupport.cxx b/livesupport/products/gLiveSupport/src/GLiveSupport.cxx index 4cb6d6eda..bae545074 100644 --- a/livesupport/products/gLiveSupport/src/GLiveSupport.cxx +++ b/livesupport/products/gLiveSupport/src/GLiveSupport.cxx @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: fgerlits $ - Version : $Revision: 1.34 $ + Author : $Author: maroy $ + Version : $Revision: 1.35 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/GLiveSupport.cxx,v $ ------------------------------------------------------------------------------*/ @@ -89,6 +89,16 @@ static const std::string localeAttrName = "locale"; *----------------------------------------------------------------------------*/ static const std::string nameAttrName = "name"; +/*------------------------------------------------------------------------------ + * The name of the config element for the sound output player + *----------------------------------------------------------------------------*/ +static const std::string outputPlayerElementName = "outputPlayer"; + +/*------------------------------------------------------------------------------ + * The name of the config element for the sound cue player + *----------------------------------------------------------------------------*/ +static const std::string cuePlayerElementName = "cuePlayer"; + /*------------------------------------------------------------------------------ * The name of the user preference for storing Scratchpad contents *----------------------------------------------------------------------------*/ @@ -195,16 +205,39 @@ GLiveSupport :: configure(const xmlpp::Element & element) scheduler = schcf->getSchedulerClient(); - // configure the AudioPlayerFactory - nodes = element.get_children(AudioPlayerFactory::getConfigElementName()); + Ptr::Ref apf; + xmlpp::Element * elem; + // configure the outputPlayer AudioPlayerFactory + nodes = element.get_children(outputPlayerElementName); + if (nodes.size() < 1) { + throw std::invalid_argument("no outputPlayer element"); + } + elem = (xmlpp::Element*) *(nodes.begin()); + nodes = elem->get_children(AudioPlayerFactory::getConfigElementName()); if (nodes.size() < 1) { throw std::invalid_argument("no audioPlayer element"); } - Ptr::Ref apf = AudioPlayerFactory::getInstance(); + apf = AudioPlayerFactory::getInstance(); apf->configure( *((const xmlpp::Element*) *(nodes.begin())) ); - audioPlayer = apf->getAudioPlayer(); - audioPlayer->initialize(); + outputPlayer = apf->getAudioPlayer(); + outputPlayer->initialize(); + + // configure the cuePlayer AudioPlayerFactory + nodes = element.get_children(cuePlayerElementName); + if (nodes.size() < 1) { + throw std::invalid_argument("no outputPlayer element"); + } + elem = (xmlpp::Element*) *(nodes.begin()); + nodes = elem->get_children(AudioPlayerFactory::getConfigElementName()); + if (nodes.size() < 1) { + throw std::invalid_argument("no audioPlayer element"); + } + apf = AudioPlayerFactory::getInstance(); + apf->configure( *((const xmlpp::Element*) *(nodes.begin())) ); + + cuePlayer = apf->getAudioPlayer(); + cuePlayer->initialize(); } @@ -497,9 +530,9 @@ GLiveSupport :: getPlaylength(Ptr::Ref uri) throw (std::invalid_argument) { Ptr::Ref playlength; - audioPlayer->open(*uri); - playlength = audioPlayer->getPlaylength(); - audioPlayer->close(); + cuePlayer->open(*uri); + playlength = cuePlayer->getPlaylength(); + cuePlayer->close(); return playlength; } @@ -695,69 +728,70 @@ GLiveSupport :: deletePlayable(Ptr::Ref playable) /*------------------------------------------------------------------------------ - * Play a Playable object using the audio player. + * Play a Playable object using the output audio player. *----------------------------------------------------------------------------*/ void LiveSupport :: GLiveSupport :: -GLiveSupport :: playAudio(Ptr::Ref playable) +GLiveSupport :: playOutputAudio(Ptr::Ref playable) throw (XmlRpcException, std::invalid_argument, std::logic_error, std::runtime_error) { - stopAudio(); // stop the audio player and release old resources + stopOutputAudio(); // stop the audio player and release old resources switch (playable->getType()) { case Playable::AudioClipType: itemPlayingNow = storage->acquireAudioClip(sessionId, playable->getId()); - audioPlayer->open(*itemPlayingNow->getUri()); - audioPlayer->start(); + outputPlayer->open(*itemPlayingNow->getUri()); + outputPlayer->start(); break; case Playable::PlaylistType: itemPlayingNow = storage->acquirePlaylist(sessionId, playable->getId()); - audioPlayer->openAndStart(itemPlayingNow->getPlaylist()); + outputPlayer->openAndStart(itemPlayingNow->getPlaylist()); break; default: // this never happens break; } - audioPlayerIsPaused = false; + outputPlayerIsPaused = false; + cuePlayerIsPaused = false; } /*------------------------------------------------------------------------------ - * Pause the audio player. + * Pause the output audio player. *----------------------------------------------------------------------------*/ void LiveSupport :: GLiveSupport :: -GLiveSupport :: pauseAudio(void) +GLiveSupport :: pauseOutputAudio(void) throw (std::logic_error) { - if (!audioPlayerIsPaused && audioPlayer->isPlaying()) { - audioPlayer->pause(); - audioPlayerIsPaused = true; + if (!outputPlayerIsPaused && outputPlayer->isPlaying()) { + outputPlayer->pause(); + outputPlayerIsPaused = true; - } else if (audioPlayerIsPaused) { - audioPlayer->start(); - audioPlayerIsPaused = false; + } else if (outputPlayerIsPaused) { + outputPlayer->start(); + outputPlayerIsPaused = false; } } /*------------------------------------------------------------------------------ - * Stop the audio player. + * Stop the output audio player. *----------------------------------------------------------------------------*/ void LiveSupport :: GLiveSupport :: -GLiveSupport :: stopAudio(void) +GLiveSupport :: stopOutputAudio(void) throw (XmlRpcException, std::logic_error) { - audioPlayer->close(); + outputPlayer->close(); if (itemPlayingNow) { switch (itemPlayingNow->getType()) { @@ -776,7 +810,93 @@ GLiveSupport :: stopAudio(void) } } - audioPlayerIsPaused = false; + outputPlayerIsPaused = false; +} + + +/*------------------------------------------------------------------------------ + * Play a Playable object using the cue audio player. + *----------------------------------------------------------------------------*/ +void +LiveSupport :: GLiveSupport :: +GLiveSupport :: playCueAudio(Ptr::Ref playable) + throw (XmlRpcException, + std::invalid_argument, + std::logic_error, + std::runtime_error) +{ + stopCueAudio(); // stop the audio player and release old resources + + switch (playable->getType()) { + case Playable::AudioClipType: + itemPlayingNow = storage->acquireAudioClip(sessionId, + playable->getId()); + cuePlayer->open(*itemPlayingNow->getUri()); + cuePlayer->start(); + break; + + case Playable::PlaylistType: + itemPlayingNow = storage->acquirePlaylist(sessionId, + playable->getId()); + cuePlayer->openAndStart(itemPlayingNow->getPlaylist()); + break; + + default: // this never happens + break; + } + + cuePlayerIsPaused = false; +} + + +/*------------------------------------------------------------------------------ + * Pause the cue audio player. + *----------------------------------------------------------------------------*/ +void +LiveSupport :: GLiveSupport :: +GLiveSupport :: pauseCueAudio(void) + throw (std::logic_error) +{ + if (!cuePlayerIsPaused && cuePlayer->isPlaying()) { + cuePlayer->pause(); + cuePlayerIsPaused = true; + + } else if (cuePlayerIsPaused) { + cuePlayer->start(); + cuePlayerIsPaused = false; + } +} + + +/*------------------------------------------------------------------------------ + * Stop the cue audio player. + *----------------------------------------------------------------------------*/ +void +LiveSupport :: GLiveSupport :: +GLiveSupport :: stopCueAudio(void) + throw (XmlRpcException, + std::logic_error) +{ + cuePlayer->close(); + + if (itemPlayingNow) { + switch (itemPlayingNow->getType()) { + case Playable::AudioClipType: + storage->releaseAudioClip(sessionId, + itemPlayingNow->getAudioClip()); + itemPlayingNow.reset(); + break; + case Playable::PlaylistType: + storage->releasePlaylist(sessionId, + itemPlayingNow->getPlaylist()); + itemPlayingNow.reset(); + break; + default: // this never happens + break; + } + } + + cuePlayerIsPaused = false; } diff --git a/livesupport/products/gLiveSupport/src/GLiveSupport.h b/livesupport/products/gLiveSupport/src/GLiveSupport.h index 0c223705c..99add87c6 100644 --- a/livesupport/products/gLiveSupport/src/GLiveSupport.h +++ b/livesupport/products/gLiveSupport/src/GLiveSupport.h @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: fgerlits $ - Version : $Revision: 1.28 $ + Author : $Author: maroy $ + Version : $Revision: 1.29 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/GLiveSupport.h,v $ ------------------------------------------------------------------------------*/ @@ -90,7 +90,8 @@ class MasterPanelWindow; * authenticationClientFactory, * storageClientFactory, * schedulerClientFactory, - * audioPlayer) > + * outputPlayer, + * cuePlayer) > * * * For a description of the resourceBundle, @@ -99,8 +100,8 @@ class MasterPanelWindow; * schedulerClientFactory elements see their * respective documentation. * - * @author $Author: fgerlits $ - * @version $Revision: 1.28 $ + * @author $Author: maroy $ + * @version $Revision: 1.29 $ * @see LocalizedObject#getBundle(const xmlpp::Element &) * @see AuthenticationClientFactory * @see StorageClientFactory @@ -153,9 +154,14 @@ class GLiveSupport : public LocalizedConfigurable, Ptr::Ref scheduler; /** - * The audio player. + * The output audio player. */ - Ptr::Ref audioPlayer; + Ptr::Ref outputPlayer; + + /** + * The cue audio player. + */ + Ptr::Ref cuePlayer; /** * The session id for the user. @@ -193,9 +199,14 @@ class GLiveSupport : public LocalizedConfigurable, Ptr::Ref itemPlayingNow; /** - * True if the audio player has been paused. + * True if the output audio player has been paused. */ - bool audioPlayerIsPaused; + bool outputPlayerIsPaused; + + /** + * True if the cue audio player has been paused. + */ + bool cuePlayerIsPaused; /** * Read a supportedLanguages configuration element, @@ -238,8 +249,11 @@ class GLiveSupport : public LocalizedConfigurable, virtual ~GLiveSupport(void) throw () { - if (audioPlayer.get()) { - audioPlayer->deInitialize(); + if (outputPlayer.get()) { + outputPlayer->deInitialize(); + } + if (cuePlayer.get()) { + cuePlayer->deInitialize(); } } @@ -573,7 +587,7 @@ class GLiveSupport : public LocalizedConfigurable, throw (XmlRpcException); /** - * Play a Playable object using the audio player. + * Play a Playable object using the output audio player. * * @param playable the Playable object to play. * @exception XmlRpcException in case of storage server errors. @@ -582,30 +596,66 @@ class GLiveSupport : public LocalizedConfigurable, * @exception std::runtime_error in case of audio player errors. */ virtual void - playAudio(Ptr::Ref playable) + playOutputAudio(Ptr::Ref playable) throw (XmlRpcException, std::invalid_argument, std::logic_error, std::runtime_error); /** - * Stop the 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. */ virtual void - stopAudio(void) + stopOutputAudio(void) throw (XmlRpcException, std::logic_error); /** - * Pause the audio player. + * Pause the output audio player. * * @exception std::logic_error in case of audio player errors. */ virtual void - pauseAudio(void) + pauseOutputAudio(void) + throw (std::logic_error); + + /** + * Play a Playable object using the cue audio player. + * + * @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::runtime_error in case of audio player errors. + */ + virtual void + playCueAudio(Ptr::Ref playable) + throw (XmlRpcException, + std::invalid_argument, + std::logic_error, + std::runtime_error); + + /** + * Stop the cue audio player. + * + * @exception XmlRpcException in case of storage server errors. + * @exception std::logic_error in case of audio player errors. + */ + virtual void + stopCueAudio(void) + throw (XmlRpcException, + std::logic_error); + + /** + * Pause the cue audio player. + * + * @exception std::logic_error in case of audio player errors. + */ + virtual void + pauseCueAudio(void) throw (std::logic_error); /** diff --git a/livesupport/products/gLiveSupport/src/LiveModeWindow.cxx b/livesupport/products/gLiveSupport/src/LiveModeWindow.cxx index d8471ee74..20d61d677 100644 --- a/livesupport/products/gLiveSupport/src/LiveModeWindow.cxx +++ b/livesupport/products/gLiveSupport/src/LiveModeWindow.cxx @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: fgerlits $ - Version : $Revision: 1.3 $ + Author : $Author: maroy $ + Version : $Revision: 1.4 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/LiveModeWindow.cxx,v $ ------------------------------------------------------------------------------*/ @@ -238,12 +238,12 @@ LiveModeWindow :: onCueMenuOption(void) throw () Ptr::Ref playable = (*iter)[modelColumns.playableColumn]; try { - gLiveSupport->playAudio(playable); + gLiveSupport->playOutputAudio(playable); } catch (XmlRpcException &e) { - std::cerr << "GLiveSupport::playAudio() error:" << std::endl + std::cerr << "GLiveSupport::playOutputAudio() error:" << std::endl << e.what() << std::endl; } catch (std::exception &e) { - std::cerr << "GLiveSupport::playAudio() error:" << std::endl + std::cerr << "GLiveSupport::playOutputAudio() error:" << std::endl << e.what() << std::endl; } } diff --git a/livesupport/products/gLiveSupport/src/MasterPanelWindow.cxx b/livesupport/products/gLiveSupport/src/MasterPanelWindow.cxx index 1b8e4c9d3..3c57987cc 100644 --- a/livesupport/products/gLiveSupport/src/MasterPanelWindow.cxx +++ b/livesupport/products/gLiveSupport/src/MasterPanelWindow.cxx @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: fgerlits $ - Version : $Revision: 1.26 $ + Author : $Author: maroy $ + Version : $Revision: 1.27 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/MasterPanelWindow.cxx,v $ ------------------------------------------------------------------------------*/ @@ -178,7 +178,8 @@ MasterPanelWindow :: MasterPanelWindow (Ptr::Ref gLiveSupport, MasterPanelWindow :: ~MasterPanelWindow (void) throw () { resetTimer(); - gLiveSupport->stopAudio(); + gLiveSupport->stopOutputAudio(); + gLiveSupport->stopCueAudio(); } diff --git a/livesupport/products/gLiveSupport/src/ScratchpadWindow.cxx b/livesupport/products/gLiveSupport/src/ScratchpadWindow.cxx index a868b736e..61e0abc82 100644 --- a/livesupport/products/gLiveSupport/src/ScratchpadWindow.cxx +++ b/livesupport/products/gLiveSupport/src/ScratchpadWindow.cxx @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: fgerlits $ - Version : $Revision: 1.12 $ + Author : $Author: maroy $ + Version : $Revision: 1.13 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/ScratchpadWindow.cxx,v $ ------------------------------------------------------------------------------*/ @@ -620,13 +620,13 @@ ScratchpadWindow :: onPlayItem(void) throw () Ptr::Ref playable = (*iter)[modelColumns.playableColumn]; try { - gLiveSupport->playAudio(playable); + gLiveSupport->playOutputAudio(playable); } catch (XmlRpcException &e) { - std::cerr << "GLiveSupport::playAudio() error:" << std::endl - << e.what() << std::endl; + std::cerr << "GLiveSupport::playOutputAudio() error:" + << std::endl << e.what() << std::endl; } catch (std::exception &e) { - std::cerr << "GLiveSupport::playAudio() error:" << std::endl - << e.what() << std::endl; + std::cerr << "GLiveSupport::playOutputAudio() error:" + << std::endl << e.what() << std::endl; } } } @@ -671,9 +671,9 @@ void ScratchpadWindow :: onPauseButtonClicked(void) throw () { try { - gLiveSupport->pauseAudio(); + gLiveSupport->pauseOutputAudio(); } catch (std::logic_error &e) { - std::cerr << "GLiveSupport::pauseAudio() error:" << std::endl + std::cerr << "GLiveSupport::pauseOutputAudio() error:" << std::endl << e.what() << std::endl; } } @@ -686,12 +686,12 @@ void ScratchpadWindow :: onStopButtonClicked(void) throw () { try { - gLiveSupport->stopAudio(); + gLiveSupport->stopOutputAudio(); } catch (XmlRpcException &e) { - std::cerr << "GLiveSupport::stopAudio() error:" << std::endl + std::cerr << "GLiveSupport::stopOutputAudio() error:" << std::endl << e.what() << std::endl; } catch (std::logic_error &e) { - std::cerr << "GLiveSupport::stopAudio() error:" << std::endl + std::cerr << "GLiveSupport::stopOutputAudio() error:" << std::endl << e.what() << std::endl; } }