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

View file

@ -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<AudioPlayerFactory>::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<AudioPlayerFactory>::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<const std::string>::Ref uri)
throw (std::invalid_argument)
{
Ptr<time_duration>::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<Playable>::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<Playable>::Ref playable)
GLiveSupport :: playOutputAudio(Ptr<Playable>::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<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
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) >
* </code></pre>
*
* For a description of the <code>resourceBundle</code>,
@ -99,8 +100,8 @@ class MasterPanelWindow;
* <code>schedulerClientFactory</code> 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<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.
@ -193,9 +199,14 @@ class GLiveSupport : public LocalizedConfigurable,
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,
@ -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<Playable>::Ref playable)
playOutputAudio(Ptr<Playable>::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<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);
/**

View file

@ -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<Playable>::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;
}
}

View file

@ -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<GLiveSupport>::Ref gLiveSupport,
MasterPanelWindow :: ~MasterPanelWindow (void) throw ()
{
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
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<Playable>::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;
}
}