added setAudioDevice() method to HelixPlayer and (AudioPlayerInterface);

added HelixPlayer::openAndStartPlaylist() to AudioPlayerInterface.
This commit is contained in:
fgerlits 2005-02-26 12:33:48 +00:00
parent ed9cc68fc3
commit 2f6ef90968
6 changed files with 115 additions and 15 deletions

View File

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: maroy $
Version : $Revision: 1.4 $
Author : $Author: fgerlits $
Version : $Revision: 1.5 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/playlistExecutor/include/LiveSupport/PlaylistExecutor/AudioPlayerInterface.h,v $
------------------------------------------------------------------------------*/
@ -46,6 +46,7 @@
#include <boost/date_time/posix_time/posix_time.hpp>
#include "LiveSupport/Core/Ptr.h"
#include "LiveSupport/Core/Playlist.h"
namespace LiveSupport {
@ -66,8 +67,8 @@ using namespace LiveSupport::Core;
/**
* A generic interface for playing audio files.
*
* @author $Author: maroy $
* @version $Revision: 1.4 $
* @author $Author: fgerlits $
* @version $Revision: 1.5 $
*/
class AudioPlayerInterface
{
@ -164,6 +165,36 @@ class AudioPlayerInterface
virtual void
stop(void) throw (std::logic_error)
= 0;
/**
* Play a playlist, with simulated fading.
*
* This is a stopgap method, and should be replaced as soon as
* the SMIL animation issues are fixed in the Helix client.
*
* @param playlist the Playlist object to be played.
* @exception std::invalid_argument playlist is invalid (e.g.,
* does not have a URI field, or there is no valid
* SMIL file at the given URI).
* @exception std::logic_error thrown by start() if open() was
* unsuccessful, but returned normally (never happens)
* @exception std::runtime_error on errors thrown by the helix player
*/
virtual void
openAndStartPlaylist(Ptr<Playlist>::Ref playlist)
throw (std::invalid_argument,
std::logic_error,
std::runtime_error)
= 0;
/**
* Set the audio device used for playback.
*
* @param deviceName the new device name, e.g., /dev/dsp
* @return true if successful, false if not
*/
virtual bool
setAudioDevice(const std::string &deviceName)
throw () = 0;
};

View File

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: maroy $
Version : $Revision: 1.5 $
Author : $Author: fgerlits $
Version : $Revision: 1.6 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/playlistExecutor/src/Attic/AudioPlayerFactoryTest.cxx,v $
------------------------------------------------------------------------------*/
@ -167,3 +167,34 @@ AudioPlayerFactoryTest :: simplePlayTest(void)
audioPlayer->close();
}
/*------------------------------------------------------------------------------
* Send stuff to /dev/null
*----------------------------------------------------------------------------*/
void
AudioPlayerFactoryTest :: nullDeviceTest(void)
throw (CPPUNIT_NS::Exception)
{
Ptr<AudioPlayerFactory>::Ref audioPlayerFactory;
Ptr<AudioPlayerInterface>::Ref audioPlayer;
Ptr<time_duration>::Ref sleepT(new time_duration(microseconds(10)));
audioPlayerFactory = AudioPlayerFactory::getInstance();
audioPlayer = audioPlayerFactory->getAudioPlayer();
CPPUNIT_ASSERT_NO_THROW(audioPlayer->open("file:var/simpleSmil.smil"));
CPPUNIT_ASSERT(!audioPlayer->isPlaying());
CPPUNIT_ASSERT(audioPlayer->setAudioDevice("/dev/null"));
CPPUNIT_ASSERT_NO_THROW(audioPlayer->start());
CPPUNIT_ASSERT(audioPlayer->isPlaying());
while (audioPlayer->isPlaying()) {
TimeConversion::sleep(sleepT);
}
CPPUNIT_ASSERT(!audioPlayer->isPlaying());
CPPUNIT_ASSERT(audioPlayer->setAudioDevice(""));
audioPlayer->close();
}

View File

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: maroy $
Version : $Revision: 1.1 $
Author : $Author: fgerlits $
Version : $Revision: 1.2 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/playlistExecutor/src/Attic/AudioPlayerFactoryTest.h,v $
------------------------------------------------------------------------------*/
@ -59,14 +59,15 @@ namespace PlaylistExecutor {
/**
* Unit test for the AudioPlayerFactory class.
*
* @author $Author: maroy $
* @version $Revision: 1.1 $
* @author $Author: fgerlits $
* @version $Revision: 1.2 $
* @see AudioPlayerFactory
*/
class AudioPlayerFactoryTest : public CPPUNIT_NS::TestFixture
{
CPPUNIT_TEST_SUITE(AudioPlayerFactoryTest);
CPPUNIT_TEST(firstTest);
CPPUNIT_TEST(nullDeviceTest);
CPPUNIT_TEST(simplePlayTest);
CPPUNIT_TEST_SUITE_END();
@ -88,6 +89,14 @@ class AudioPlayerFactoryTest : public CPPUNIT_NS::TestFixture
void
simplePlayTest(void) throw (CPPUNIT_NS::Exception);
/**
* Check the setAudioDevice() method.
*
* @exception CPPUNIT_NS::Exception on test failures.
*/
void
nullDeviceTest(void) throw (CPPUNIT_NS::Exception);
public:
/**

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.12 $
Version : $Revision: 1.13 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/playlistExecutor/src/Attic/HelixPlayer.cxx,v $
------------------------------------------------------------------------------*/
@ -492,3 +492,15 @@ HelixPlayer :: openAndStartPlaylist(Ptr<Playlist>::Ref playlist)
HX_RELEASE(audioPlayer);
}
/*------------------------------------------------------------------------------
* Set the audio device.
*----------------------------------------------------------------------------*/
bool
HelixPlayer :: setAudioDevice(const std::string &deviceName)
throw ()
{
return (setenv("AUDIO", deviceName.c_str(), 1) == 0);
// 1 = overwrite if exists
}

View File

@ -22,7 +22,7 @@
Author : $Author: fgerlits $
Version : $Revision: 1.10 $
Version : $Revision: 1.11 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/playlistExecutor/src/Attic/HelixPlayer.h,v $
------------------------------------------------------------------------------*/
@ -91,7 +91,7 @@ using namespace LiveSupport::Core;
* </pre></code>
*
* @author $Author: fgerlits $
* @version $Revision: 1.10 $
* @version $Revision: 1.11 $
*/
class HelixPlayer : virtual public Configurable,
virtual public AudioPlayerInterface,
@ -349,11 +349,28 @@ class HelixPlayer : virtual public Configurable,
* unsuccessful, but returned normally (never happens)
* @exception std::runtime_error on errors thrown by the helix player
*/
void
virtual void
openAndStartPlaylist(Ptr<Playlist>::Ref playlist)
throw (std::invalid_argument,
std::logic_error,
std::runtime_error);
/**
* Set the audio device used for playback.
*
* Sets the environment variable AUDIO. This should be replaced with
* a Helix function call as soon as this functionality is provided.
*
* There are some strange issues with this: e.g., if you set the
* device to "/dev/null", this works fine for SMIL files, but gives
* Helix error 80040100 (HXR_AUDIO_DRIVER) when an mp3 file is played.
*
* @param deviceName the new device name, e.g., /dev/dsp
* @return true if successful, false if not
*/
virtual bool
setAudioDevice(const std::string &deviceName)
throw ();
};

View File

@ -1,6 +1,6 @@
<smil xmlns = "http://www.w3.org/2001/SMIL20/Language"
xmlns:rn = "http://features.real.com/2001/SMIL20/Extensions">
<body>
<audio src="file:var/test.mp3"/>
<audio src="file:var/test-short.mp3"/>
</body>
</smil>