added support for two audio interfaces, one for output, the other for

cue-ing
This commit is contained in:
maroy 2005-05-03 14:34:42 +00:00
parent 65b62b0deb
commit edbd0d31d7
6 changed files with 261 additions and 71 deletions

View file

@ -7,7 +7,8 @@
authenticationClientFactory, authenticationClientFactory,
storageClientFactory, storageClientFactory,
schedulerClientFactory, schedulerClientFactory,
audioPlayer) > outputPlayer,
cuePlayer) >
<!ELEMENT resourceBundle EMPTY > <!ELEMENT resourceBundle EMPTY >
<!ATTLIST resourceBundle path CDATA #REQUIRED > <!ATTLIST resourceBundle path CDATA #REQUIRED >
@ -72,10 +73,16 @@
<!ATTLIST schedulerDaemonXmlRpcClient xmlRpcPort NMTOKEN #REQUIRED > <!ATTLIST schedulerDaemonXmlRpcClient xmlRpcPort NMTOKEN #REQUIRED >
<!ATTLIST schedulerDaemonXmlRpcClient xmlRpcUri CDATA #REQUIRED > <!ATTLIST schedulerDaemonXmlRpcClient xmlRpcUri CDATA #REQUIRED >
<!ELEMENT outputPlayer (audioPlayer) >
<!ELEMENT cuePlayer (audioPlayer) >
<!ELEMENT audioPlayer (helixPlayer) > <!ELEMENT audioPlayer (helixPlayer) >
<!ELEMENT helixPlayer EMPTY > <!ELEMENT helixPlayer EMPTY >
<!ATTLIST helixPlayer dllPath CDATA #REQUIRED > <!ATTLIST helixPlayer dllPath CDATA #REQUIRED >
<!ATTLIST helixPlayer audioDevice CDATA #IMPLIED >
<!ATTLIST helixPlayer audioStreamTimeout NMTOKEN #IMPLIED >
<!ATTLIST helixPlayer fadeLookAheatTime NMTOKEN #IMPLIED >
]> ]>
<gLiveSupport> <gLiveSupport>
@ -111,9 +118,21 @@
/> />
</schedulerClientFactory> </schedulerClientFactory>
<audioPlayer> <outputPlayer>
<helixPlayer dllPath = "../../usr/lib/helix"/> <audioPlayer>
</audioPlayer> <helixPlayer dllPath = "../../usr/lib/helix"
audioDevice = "/dev/dsp"
/>
</audioPlayer>
</outputPlayer>
<cuePlayer>
<audioPlayer>
<helixPlayer dllPath = "../../usr/lib/helix"
audioDevice = "/dev/dsp"
/>
</audioPlayer>
</cuePlayer>
</gLiveSupport> </gLiveSupport>

View file

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: fgerlits $ Author : $Author: maroy $
Version : $Revision: 1.34 $ Version : $Revision: 1.35 $
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 $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -89,6 +89,16 @@ static const std::string localeAttrName = "locale";
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
static const std::string nameAttrName = "name"; 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 * The name of the user preference for storing Scratchpad contents
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
@ -195,16 +205,39 @@ GLiveSupport :: configure(const xmlpp::Element & element)
scheduler = schcf->getSchedulerClient(); scheduler = schcf->getSchedulerClient();
// configure the AudioPlayerFactory Ptr<AudioPlayerFactory>::Ref apf;
nodes = element.get_children(AudioPlayerFactory::getConfigElementName()); 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) { if (nodes.size() < 1) {
throw std::invalid_argument("no audioPlayer element"); throw std::invalid_argument("no audioPlayer element");
} }
Ptr<AudioPlayerFactory>::Ref apf = AudioPlayerFactory::getInstance(); apf = AudioPlayerFactory::getInstance();
apf->configure( *((const xmlpp::Element*) *(nodes.begin())) ); apf->configure( *((const xmlpp::Element*) *(nodes.begin())) );
audioPlayer = apf->getAudioPlayer(); outputPlayer = apf->getAudioPlayer();
audioPlayer->initialize(); 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<const std::string>::Ref uri)
throw (std::invalid_argument) throw (std::invalid_argument)
{ {
Ptr<time_duration>::Ref playlength; Ptr<time_duration>::Ref playlength;
audioPlayer->open(*uri); cuePlayer->open(*uri);
playlength = audioPlayer->getPlaylength(); playlength = cuePlayer->getPlaylength();
audioPlayer->close(); cuePlayer->close();
return playlength; return playlength;
} }
@ -695,69 +728,70 @@ GLiveSupport :: deletePlayable(Ptr<Playable>::Ref playable)
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Play a Playable object using the audio player. * Play a Playable object using the output audio player.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
LiveSupport :: GLiveSupport :: LiveSupport :: GLiveSupport ::
GLiveSupport :: playAudio(Ptr<Playable>::Ref playable) GLiveSupport :: playOutputAudio(Ptr<Playable>::Ref playable)
throw (XmlRpcException, throw (XmlRpcException,
std::invalid_argument, std::invalid_argument,
std::logic_error, std::logic_error,
std::runtime_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()) { switch (playable->getType()) {
case Playable::AudioClipType: case Playable::AudioClipType:
itemPlayingNow = storage->acquireAudioClip(sessionId, itemPlayingNow = storage->acquireAudioClip(sessionId,
playable->getId()); playable->getId());
audioPlayer->open(*itemPlayingNow->getUri()); outputPlayer->open(*itemPlayingNow->getUri());
audioPlayer->start(); outputPlayer->start();
break; break;
case Playable::PlaylistType: case Playable::PlaylistType:
itemPlayingNow = storage->acquirePlaylist(sessionId, itemPlayingNow = storage->acquirePlaylist(sessionId,
playable->getId()); playable->getId());
audioPlayer->openAndStart(itemPlayingNow->getPlaylist()); outputPlayer->openAndStart(itemPlayingNow->getPlaylist());
break; break;
default: // this never happens default: // this never happens
break; break;
} }
audioPlayerIsPaused = false; outputPlayerIsPaused = false;
cuePlayerIsPaused = false;
} }
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Pause the audio player. * Pause the output audio player.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
LiveSupport :: GLiveSupport :: LiveSupport :: GLiveSupport ::
GLiveSupport :: pauseAudio(void) GLiveSupport :: pauseOutputAudio(void)
throw (std::logic_error) throw (std::logic_error)
{ {
if (!audioPlayerIsPaused && audioPlayer->isPlaying()) { if (!outputPlayerIsPaused && outputPlayer->isPlaying()) {
audioPlayer->pause(); outputPlayer->pause();
audioPlayerIsPaused = true; outputPlayerIsPaused = true;
} else if (audioPlayerIsPaused) { } else if (outputPlayerIsPaused) {
audioPlayer->start(); outputPlayer->start();
audioPlayerIsPaused = false; outputPlayerIsPaused = false;
} }
} }
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* Stop the audio player. * Stop the output audio player.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
void void
LiveSupport :: GLiveSupport :: LiveSupport :: GLiveSupport ::
GLiveSupport :: stopAudio(void) GLiveSupport :: stopOutputAudio(void)
throw (XmlRpcException, throw (XmlRpcException,
std::logic_error) std::logic_error)
{ {
audioPlayer->close(); outputPlayer->close();
if (itemPlayingNow) { if (itemPlayingNow) {
switch (itemPlayingNow->getType()) { 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<Playable>::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;
} }

View file

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: fgerlits $ Author : $Author: maroy $
Version : $Revision: 1.28 $ Version : $Revision: 1.29 $
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 $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -90,7 +90,8 @@ class MasterPanelWindow;
* authenticationClientFactory, * authenticationClientFactory,
* storageClientFactory, * storageClientFactory,
* schedulerClientFactory, * schedulerClientFactory,
* audioPlayer) > * outputPlayer,
* cuePlayer) >
* </code></pre> * </code></pre>
* *
* For a description of the <code>resourceBundle</code>, * For a description of the <code>resourceBundle</code>,
@ -99,8 +100,8 @@ class MasterPanelWindow;
* <code>schedulerClientFactory</code> elements see their * <code>schedulerClientFactory</code> elements see their
* respective documentation. * respective documentation.
* *
* @author $Author: fgerlits $ * @author $Author: maroy $
* @version $Revision: 1.28 $ * @version $Revision: 1.29 $
* @see LocalizedObject#getBundle(const xmlpp::Element &) * @see LocalizedObject#getBundle(const xmlpp::Element &)
* @see AuthenticationClientFactory * @see AuthenticationClientFactory
* @see StorageClientFactory * @see StorageClientFactory
@ -153,9 +154,14 @@ class GLiveSupport : public LocalizedConfigurable,
Ptr<SchedulerClientInterface>::Ref scheduler; Ptr<SchedulerClientInterface>::Ref scheduler;
/** /**
* The audio player. * The output audio player.
*/ */
Ptr<AudioPlayerInterface>::Ref audioPlayer; Ptr<AudioPlayerInterface>::Ref outputPlayer;
/**
* The cue audio player.
*/
Ptr<AudioPlayerInterface>::Ref cuePlayer;
/** /**
* The session id for the user. * The session id for the user.
@ -193,9 +199,14 @@ class GLiveSupport : public LocalizedConfigurable,
Ptr<Playable>::Ref itemPlayingNow; Ptr<Playable>::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, * Read a supportedLanguages configuration element,
@ -238,8 +249,11 @@ class GLiveSupport : public LocalizedConfigurable,
virtual virtual
~GLiveSupport(void) throw () ~GLiveSupport(void) throw ()
{ {
if (audioPlayer.get()) { if (outputPlayer.get()) {
audioPlayer->deInitialize(); outputPlayer->deInitialize();
}
if (cuePlayer.get()) {
cuePlayer->deInitialize();
} }
} }
@ -573,7 +587,7 @@ class GLiveSupport : public LocalizedConfigurable,
throw (XmlRpcException); 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. * @param playable the Playable object to play.
* @exception XmlRpcException in case of storage server errors. * @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. * @exception std::runtime_error in case of audio player errors.
*/ */
virtual void virtual void
playAudio(Ptr<Playable>::Ref playable) playOutputAudio(Ptr<Playable>::Ref playable)
throw (XmlRpcException, throw (XmlRpcException,
std::invalid_argument, std::invalid_argument,
std::logic_error, std::logic_error,
std::runtime_error); std::runtime_error);
/** /**
* Stop the audio player. * Stop the output audio player.
* *
* @exception XmlRpcException in case of storage server errors. * @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
stopAudio(void) stopOutputAudio(void)
throw (XmlRpcException, throw (XmlRpcException,
std::logic_error); std::logic_error);
/** /**
* Pause the audio player. * Pause the output audio player.
* *
* @exception std::logic_error in case of audio player errors. * @exception std::logic_error in case of audio player errors.
*/ */
virtual void 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<Playable>::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); throw (std::logic_error);
/** /**

View file

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: fgerlits $ Author : $Author: maroy $
Version : $Revision: 1.3 $ Version : $Revision: 1.4 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/LiveModeWindow.cxx,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/LiveModeWindow.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -238,12 +238,12 @@ LiveModeWindow :: onCueMenuOption(void) throw ()
Ptr<Playable>::Ref playable = (*iter)[modelColumns.playableColumn]; Ptr<Playable>::Ref playable = (*iter)[modelColumns.playableColumn];
try { try {
gLiveSupport->playAudio(playable); gLiveSupport->playOutputAudio(playable);
} catch (XmlRpcException &e) { } catch (XmlRpcException &e) {
std::cerr << "GLiveSupport::playAudio() error:" << std::endl std::cerr << "GLiveSupport::playOutputAudio() error:" << std::endl
<< e.what() << std::endl; << e.what() << std::endl;
} catch (std::exception &e) { } catch (std::exception &e) {
std::cerr << "GLiveSupport::playAudio() error:" << std::endl std::cerr << "GLiveSupport::playOutputAudio() error:" << std::endl
<< e.what() << std::endl; << e.what() << std::endl;
} }
} }

View file

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: fgerlits $ Author : $Author: maroy $
Version : $Revision: 1.26 $ Version : $Revision: 1.27 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/MasterPanelWindow.cxx,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/MasterPanelWindow.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -178,7 +178,8 @@ MasterPanelWindow :: MasterPanelWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
MasterPanelWindow :: ~MasterPanelWindow (void) throw () MasterPanelWindow :: ~MasterPanelWindow (void) throw ()
{ {
resetTimer(); resetTimer();
gLiveSupport->stopAudio(); gLiveSupport->stopOutputAudio();
gLiveSupport->stopCueAudio();
} }

View file

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: fgerlits $ Author : $Author: maroy $
Version : $Revision: 1.12 $ Version : $Revision: 1.13 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/ScratchpadWindow.cxx,v $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/products/gLiveSupport/src/ScratchpadWindow.cxx,v $
------------------------------------------------------------------------------*/ ------------------------------------------------------------------------------*/
@ -620,13 +620,13 @@ ScratchpadWindow :: onPlayItem(void) throw ()
Ptr<Playable>::Ref playable = (*iter)[modelColumns.playableColumn]; Ptr<Playable>::Ref playable = (*iter)[modelColumns.playableColumn];
try { try {
gLiveSupport->playAudio(playable); gLiveSupport->playOutputAudio(playable);
} catch (XmlRpcException &e) { } catch (XmlRpcException &e) {
std::cerr << "GLiveSupport::playAudio() error:" << std::endl std::cerr << "GLiveSupport::playOutputAudio() error:"
<< e.what() << std::endl; << std::endl << e.what() << std::endl;
} catch (std::exception &e) { } catch (std::exception &e) {
std::cerr << "GLiveSupport::playAudio() error:" << std::endl std::cerr << "GLiveSupport::playOutputAudio() error:"
<< e.what() << std::endl; << std::endl << e.what() << std::endl;
} }
} }
} }
@ -671,9 +671,9 @@ void
ScratchpadWindow :: onPauseButtonClicked(void) throw () ScratchpadWindow :: onPauseButtonClicked(void) throw ()
{ {
try { try {
gLiveSupport->pauseAudio(); gLiveSupport->pauseOutputAudio();
} catch (std::logic_error &e) { } catch (std::logic_error &e) {
std::cerr << "GLiveSupport::pauseAudio() error:" << std::endl std::cerr << "GLiveSupport::pauseOutputAudio() error:" << std::endl
<< e.what() << std::endl; << e.what() << std::endl;
} }
} }
@ -686,12 +686,12 @@ void
ScratchpadWindow :: onStopButtonClicked(void) throw () ScratchpadWindow :: onStopButtonClicked(void) throw ()
{ {
try { try {
gLiveSupport->stopAudio(); gLiveSupport->stopOutputAudio();
} catch (XmlRpcException &e) { } catch (XmlRpcException &e) {
std::cerr << "GLiveSupport::stopAudio() error:" << std::endl std::cerr << "GLiveSupport::stopOutputAudio() error:" << std::endl
<< e.what() << std::endl; << e.what() << std::endl;
} catch (std::logic_error &e) { } catch (std::logic_error &e) {
std::cerr << "GLiveSupport::stopAudio() error:" << std::endl std::cerr << "GLiveSupport::stopOutputAudio() error:" << std::endl
<< e.what() << std::endl; << e.what() << std::endl;
} }
} }