added setAudioDevice() method to HelixPlayer and (AudioPlayerInterface);
added HelixPlayer::openAndStartPlaylist() to AudioPlayerInterface.
This commit is contained in:
parent
ed9cc68fc3
commit
2f6ef90968
6 changed files with 115 additions and 15 deletions
|
@ -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: maroy $
|
Author : $Author: fgerlits $
|
||||||
Version : $Revision: 1.4 $
|
Version : $Revision: 1.5 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/playlistExecutor/include/LiveSupport/PlaylistExecutor/AudioPlayerInterface.h,v $
|
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 <boost/date_time/posix_time/posix_time.hpp>
|
||||||
|
|
||||||
#include "LiveSupport/Core/Ptr.h"
|
#include "LiveSupport/Core/Ptr.h"
|
||||||
|
#include "LiveSupport/Core/Playlist.h"
|
||||||
|
|
||||||
|
|
||||||
namespace LiveSupport {
|
namespace LiveSupport {
|
||||||
|
@ -66,8 +67,8 @@ using namespace LiveSupport::Core;
|
||||||
/**
|
/**
|
||||||
* A generic interface for playing audio files.
|
* A generic interface for playing audio files.
|
||||||
*
|
*
|
||||||
* @author $Author: maroy $
|
* @author $Author: fgerlits $
|
||||||
* @version $Revision: 1.4 $
|
* @version $Revision: 1.5 $
|
||||||
*/
|
*/
|
||||||
class AudioPlayerInterface
|
class AudioPlayerInterface
|
||||||
{
|
{
|
||||||
|
@ -164,6 +165,36 @@ class AudioPlayerInterface
|
||||||
virtual void
|
virtual void
|
||||||
stop(void) throw (std::logic_error)
|
stop(void) throw (std::logic_error)
|
||||||
= 0;
|
= 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;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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: maroy $
|
Author : $Author: fgerlits $
|
||||||
Version : $Revision: 1.5 $
|
Version : $Revision: 1.6 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/playlistExecutor/src/Attic/AudioPlayerFactoryTest.cxx,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/playlistExecutor/src/Attic/AudioPlayerFactoryTest.cxx,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -167,3 +167,34 @@ AudioPlayerFactoryTest :: simplePlayTest(void)
|
||||||
audioPlayer->close();
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -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: maroy $
|
Author : $Author: fgerlits $
|
||||||
Version : $Revision: 1.1 $
|
Version : $Revision: 1.2 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/playlistExecutor/src/Attic/AudioPlayerFactoryTest.h,v $
|
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.
|
* Unit test for the AudioPlayerFactory class.
|
||||||
*
|
*
|
||||||
* @author $Author: maroy $
|
* @author $Author: fgerlits $
|
||||||
* @version $Revision: 1.1 $
|
* @version $Revision: 1.2 $
|
||||||
* @see AudioPlayerFactory
|
* @see AudioPlayerFactory
|
||||||
*/
|
*/
|
||||||
class AudioPlayerFactoryTest : public CPPUNIT_NS::TestFixture
|
class AudioPlayerFactoryTest : public CPPUNIT_NS::TestFixture
|
||||||
{
|
{
|
||||||
CPPUNIT_TEST_SUITE(AudioPlayerFactoryTest);
|
CPPUNIT_TEST_SUITE(AudioPlayerFactoryTest);
|
||||||
CPPUNIT_TEST(firstTest);
|
CPPUNIT_TEST(firstTest);
|
||||||
|
CPPUNIT_TEST(nullDeviceTest);
|
||||||
CPPUNIT_TEST(simplePlayTest);
|
CPPUNIT_TEST(simplePlayTest);
|
||||||
CPPUNIT_TEST_SUITE_END();
|
CPPUNIT_TEST_SUITE_END();
|
||||||
|
|
||||||
|
@ -88,6 +89,14 @@ class AudioPlayerFactoryTest : public CPPUNIT_NS::TestFixture
|
||||||
void
|
void
|
||||||
simplePlayTest(void) throw (CPPUNIT_NS::Exception);
|
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:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: fgerlits $
|
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 $
|
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);
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
|
|
||||||
Author : $Author: fgerlits $
|
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 $
|
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>
|
* </pre></code>
|
||||||
*
|
*
|
||||||
* @author $Author: fgerlits $
|
* @author $Author: fgerlits $
|
||||||
* @version $Revision: 1.10 $
|
* @version $Revision: 1.11 $
|
||||||
*/
|
*/
|
||||||
class HelixPlayer : virtual public Configurable,
|
class HelixPlayer : virtual public Configurable,
|
||||||
virtual public AudioPlayerInterface,
|
virtual public AudioPlayerInterface,
|
||||||
|
@ -349,11 +349,28 @@ class HelixPlayer : virtual public Configurable,
|
||||||
* unsuccessful, but returned normally (never happens)
|
* unsuccessful, but returned normally (never happens)
|
||||||
* @exception std::runtime_error on errors thrown by the helix player
|
* @exception std::runtime_error on errors thrown by the helix player
|
||||||
*/
|
*/
|
||||||
void
|
virtual void
|
||||||
openAndStartPlaylist(Ptr<Playlist>::Ref playlist)
|
openAndStartPlaylist(Ptr<Playlist>::Ref playlist)
|
||||||
throw (std::invalid_argument,
|
throw (std::invalid_argument,
|
||||||
std::logic_error,
|
std::logic_error,
|
||||||
std::runtime_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 ();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<smil xmlns = "http://www.w3.org/2001/SMIL20/Language"
|
<smil xmlns = "http://www.w3.org/2001/SMIL20/Language"
|
||||||
xmlns:rn = "http://features.real.com/2001/SMIL20/Extensions">
|
xmlns:rn = "http://features.real.com/2001/SMIL20/Extensions">
|
||||||
<body>
|
<body>
|
||||||
<audio src="file:var/test.mp3"/>
|
<audio src="file:var/test-short.mp3"/>
|
||||||
</body>
|
</body>
|
||||||
</smil>
|
</smil>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue