From dc017540477237a2823dd818a8de52ab3d630495 Mon Sep 17 00:00:00 2001 From: maroy Date: Sun, 2 Jan 2005 12:30:10 +0000 Subject: [PATCH] fixed open/close cycle, hopefully --- .../playlistExecutor/src/HelixPlayer.cxx | 21 +++++++++++++++---- .../playlistExecutor/src/HelixPlayer.h | 14 +++---------- .../playlistExecutor/src/HelixPlayerTest.cxx | 13 +++++++++++- 3 files changed, 32 insertions(+), 16 deletions(-) diff --git a/livesupport/modules/playlistExecutor/src/HelixPlayer.cxx b/livesupport/modules/playlistExecutor/src/HelixPlayer.cxx index 4298c20d6..d93c93f38 100644 --- a/livesupport/modules/playlistExecutor/src/HelixPlayer.cxx +++ b/livesupport/modules/playlistExecutor/src/HelixPlayer.cxx @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.7 $ + Version : $Revision: 1.8 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/playlistExecutor/src/Attic/HelixPlayer.cxx,v $ ------------------------------------------------------------------------------*/ @@ -237,9 +237,7 @@ HelixPlayer :: open(const std::string fileUrl) if (HXR_OK != player->OpenURL(fileUrl.c_str())) { throw std::invalid_argument("can't open URL"); } - // if the source count was not 0 before OpenURL(), the source is simply - // replaced - if (!sourceCount && sourceCount == player->GetSourceCount()) { + if (sourceCount == player->GetSourceCount()) { throw std::invalid_argument("can't open URL"); } } @@ -316,6 +314,21 @@ HelixPlayer :: stop(void) throw (std::logic_error) } +/*------------------------------------------------------------------------------ + * Close the currently opened audio file. + *----------------------------------------------------------------------------*/ +void +HelixPlayer :: close(void) throw () +{ + if (isPlaying()) { + stop(); + } else { + // else, call IHXPlayer->Stop(), to clean up things... + player->Stop(); + } +} + + /*------------------------------------------------------------------------------ * A global function needed by the Helix library, this will return the * access path to shared objects. diff --git a/livesupport/modules/playlistExecutor/src/HelixPlayer.h b/livesupport/modules/playlistExecutor/src/HelixPlayer.h index 3fe5900bc..878c25594 100644 --- a/livesupport/modules/playlistExecutor/src/HelixPlayer.h +++ b/livesupport/modules/playlistExecutor/src/HelixPlayer.h @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.5 $ + Version : $Revision: 1.6 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/playlistExecutor/src/Attic/HelixPlayer.h,v $ ------------------------------------------------------------------------------*/ @@ -91,7 +91,7 @@ using namespace LiveSupport::Core; * * * @author $Author: maroy $ - * @version $Revision: 1.5 $ + * @version $Revision: 1.6 $ */ class HelixPlayer : virtual public Configurable, virtual public AudioPlayerInterface, @@ -253,15 +253,7 @@ class HelixPlayer : virtual public Configurable, * @see #open */ virtual void - close(void) throw () - { - if (isPlaying()) { - stop(); - } - - // nothing else to do here, the Helix Player object does not - // have a close() function... - } + close(void) throw (); /** * Start playing. diff --git a/livesupport/modules/playlistExecutor/src/HelixPlayerTest.cxx b/livesupport/modules/playlistExecutor/src/HelixPlayerTest.cxx index 6c02f59db..2ed1f53a6 100644 --- a/livesupport/modules/playlistExecutor/src/HelixPlayerTest.cxx +++ b/livesupport/modules/playlistExecutor/src/HelixPlayerTest.cxx @@ -22,7 +22,7 @@ Author : $Author: maroy $ - Version : $Revision: 1.6 $ + Version : $Revision: 1.7 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/playlistExecutor/src/Attic/HelixPlayerTest.cxx,v $ ------------------------------------------------------------------------------*/ @@ -207,6 +207,17 @@ HelixPlayerTest :: checkErrorConditions(void) } CPPUNIT_ASSERT(gotException); + // check for opening a wrong URL after opening a proper one + helixPlayer->open("file:var/test.mp3"); + helixPlayer->close(); + gotException = false; + try { + helixPlayer->open("totally/bad/URL"); + } catch (std::invalid_argument &e) { + gotException = true; + } + CPPUNIT_ASSERT(gotException); + helixPlayer->deInitialize(); }