changed audio listener interface to use plain pointers insteas of Ptr<>::Ref
This commit is contained in:
parent
8b56186766
commit
19da95806a
4 changed files with 49 additions and 66 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.10 $
|
Version : $Revision: 1.11 $
|
||||||
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 $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -68,8 +68,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.10 $
|
* @version $Revision: 1.11 $
|
||||||
*/
|
*/
|
||||||
class AudioPlayerInterface
|
class AudioPlayerInterface
|
||||||
{
|
{
|
||||||
|
@ -106,7 +106,7 @@ class AudioPlayerInterface
|
||||||
* @see #detach
|
* @see #detach
|
||||||
*/
|
*/
|
||||||
virtual void
|
virtual void
|
||||||
attachListener(Ptr<AudioPlayerEventListener>::Ref eventListener)
|
attachListener(AudioPlayerEventListener* eventListener)
|
||||||
throw () = 0;
|
throw () = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -120,7 +120,7 @@ class AudioPlayerInterface
|
||||||
* @see #attach
|
* @see #attach
|
||||||
*/
|
*/
|
||||||
virtual void
|
virtual void
|
||||||
detachListener(Ptr<AudioPlayerEventListener>::Ref eventListener)
|
detachListener(AudioPlayerEventListener* eventListener)
|
||||||
throw (std::invalid_argument) = 0;
|
throw (std::invalid_argument) = 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.19 $
|
Version : $Revision: 1.20 $
|
||||||
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 $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -273,7 +273,7 @@ HelixPlayer :: deInitialize(void) throw ()
|
||||||
* Attach an event listener.
|
* Attach an event listener.
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
HelixPlayer :: attachListener(Ptr<AudioPlayerEventListener>::Ref eventListener)
|
HelixPlayer :: attachListener(AudioPlayerEventListener* eventListener)
|
||||||
throw ()
|
throw ()
|
||||||
{
|
{
|
||||||
listeners.push_back(eventListener);
|
listeners.push_back(eventListener);
|
||||||
|
@ -284,14 +284,14 @@ HelixPlayer :: attachListener(Ptr<AudioPlayerEventListener>::Ref eventListener)
|
||||||
* Detach an event listener.
|
* Detach an event listener.
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
HelixPlayer :: detachListener(Ptr<AudioPlayerEventListener>::Ref eventListener)
|
HelixPlayer :: detachListener(AudioPlayerEventListener* eventListener)
|
||||||
throw (std::invalid_argument)
|
throw (std::invalid_argument)
|
||||||
{
|
{
|
||||||
ListenerVector::iterator it = listeners.begin();
|
ListenerVector::iterator it = listeners.begin();
|
||||||
ListenerVector::iterator end = listeners.end();
|
ListenerVector::iterator end = listeners.end();
|
||||||
|
|
||||||
while (it != end) {
|
while (it != end) {
|
||||||
if ((*it).get() == eventListener.get()) {
|
if (*it == eventListener) {
|
||||||
listeners.erase(it);
|
listeners.erase(it);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.16 $
|
Version : $Revision: 1.17 $
|
||||||
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 $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -111,8 +111,8 @@ using namespace LiveSupport::Core;
|
||||||
* <!ATTLIST helixPlayer fadeLookAheatTime #IMPLIED >
|
* <!ATTLIST helixPlayer fadeLookAheatTime #IMPLIED >
|
||||||
* </pre></code>
|
* </pre></code>
|
||||||
*
|
*
|
||||||
* @author $Author: maroy $
|
* @author $Author: fgerlits $
|
||||||
* @version $Revision: 1.16 $
|
* @version $Revision: 1.17 $
|
||||||
*/
|
*/
|
||||||
class HelixPlayer : virtual public Configurable,
|
class HelixPlayer : virtual public Configurable,
|
||||||
virtual public AudioPlayerInterface,
|
virtual public AudioPlayerInterface,
|
||||||
|
@ -198,7 +198,7 @@ class HelixPlayer : virtual public Configurable,
|
||||||
* Just a shorthand notation, to make reference to the type
|
* Just a shorthand notation, to make reference to the type
|
||||||
* easier.
|
* easier.
|
||||||
*/
|
*/
|
||||||
typedef std::vector<Ptr<AudioPlayerEventListener>::Ref>
|
typedef std::vector<AudioPlayerEventListener*>
|
||||||
ListenerVector;
|
ListenerVector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -322,7 +322,7 @@ class HelixPlayer : virtual public Configurable,
|
||||||
* @see #detach
|
* @see #detach
|
||||||
*/
|
*/
|
||||||
virtual void
|
virtual void
|
||||||
attachListener(Ptr<AudioPlayerEventListener>::Ref eventListener)
|
attachListener(AudioPlayerEventListener* eventListener)
|
||||||
throw ();
|
throw ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -334,7 +334,7 @@ class HelixPlayer : virtual public Configurable,
|
||||||
* @see #attach
|
* @see #attach
|
||||||
*/
|
*/
|
||||||
virtual void
|
virtual void
|
||||||
detachListener(Ptr<AudioPlayerEventListener>::Ref eventListener)
|
detachListener(AudioPlayerEventListener* eventListener)
|
||||||
throw (std::invalid_argument);
|
throw (std::invalid_argument);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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.11 $
|
Version : $Revision: 1.12 $
|
||||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/playlistExecutor/src/Attic/HelixPlayerTest.cxx,v $
|
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/playlistExecutor/src/Attic/HelixPlayerTest.cxx,v $
|
||||||
|
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
@ -445,39 +445,28 @@ HelixPlayerTest :: eventListenerAttachTest(void)
|
||||||
|
|
||||||
Ptr<TestEventListener>::Ref listener1(new TestEventListener());
|
Ptr<TestEventListener>::Ref listener1(new TestEventListener());
|
||||||
Ptr<TestEventListener>::Ref listener2(new TestEventListener());
|
Ptr<TestEventListener>::Ref listener2(new TestEventListener());
|
||||||
bool gotException;
|
|
||||||
|
|
||||||
// try with one listener
|
// try with one listener
|
||||||
helixPlayer->attachListener(listener1);
|
helixPlayer->attachListener(listener1.get());
|
||||||
try {
|
CPPUNIT_ASSERT_NO_THROW(
|
||||||
helixPlayer->detachListener(listener1);
|
helixPlayer->detachListener(listener1.get())
|
||||||
} catch (std::invalid_argument &e) {
|
);
|
||||||
CPPUNIT_FAIL(e.what());
|
CPPUNIT_ASSERT_THROW(
|
||||||
}
|
helixPlayer->detachListener(listener1.get()),
|
||||||
gotException = false;
|
std::invalid_argument
|
||||||
try {
|
);
|
||||||
helixPlayer->detachListener(listener1);
|
|
||||||
} catch (std::invalid_argument &e) {
|
|
||||||
gotException = true;
|
|
||||||
}
|
|
||||||
CPPUNIT_ASSERT(gotException);
|
|
||||||
|
|
||||||
// try with two listeners
|
// try with two listeners
|
||||||
helixPlayer->attachListener(listener1);
|
helixPlayer->attachListener(listener1.get());
|
||||||
gotException = false;
|
CPPUNIT_ASSERT_THROW(
|
||||||
try {
|
helixPlayer->detachListener(listener2.get()),
|
||||||
helixPlayer->detachListener(listener2);
|
std::invalid_argument
|
||||||
} catch (std::invalid_argument &e) {
|
);
|
||||||
gotException = true;
|
helixPlayer->attachListener(listener2.get());
|
||||||
}
|
CPPUNIT_ASSERT_NO_THROW(
|
||||||
CPPUNIT_ASSERT(gotException);
|
helixPlayer->detachListener(listener1.get());
|
||||||
helixPlayer->attachListener(listener2);
|
);
|
||||||
try {
|
|
||||||
helixPlayer->detachListener(listener1);
|
|
||||||
} catch (std::invalid_argument &e) {
|
|
||||||
CPPUNIT_FAIL(e.what());
|
|
||||||
}
|
|
||||||
|
|
||||||
helixPlayer->deInitialize();
|
helixPlayer->deInitialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -493,15 +482,13 @@ HelixPlayerTest :: eventListenerTest(void)
|
||||||
|
|
||||||
Ptr<time_duration>::Ref sleepT(new time_duration(microseconds(10)));
|
Ptr<time_duration>::Ref sleepT(new time_duration(microseconds(10)));
|
||||||
Ptr<TestEventListener>::Ref listener1(new TestEventListener());
|
Ptr<TestEventListener>::Ref listener1(new TestEventListener());
|
||||||
helixPlayer->attachListener(listener1);
|
helixPlayer->attachListener(listener1.get());
|
||||||
|
|
||||||
// try with one listener
|
// try with one listener
|
||||||
CPPUNIT_ASSERT(!listener1->stopFlag);
|
CPPUNIT_ASSERT(!listener1->stopFlag);
|
||||||
try {
|
CPPUNIT_ASSERT_NO_THROW(
|
||||||
helixPlayer->open("file:var/test.mp3");
|
helixPlayer->open("file:var/test.mp3");
|
||||||
} catch (std::invalid_argument &e) {
|
);
|
||||||
CPPUNIT_FAIL(e.what());
|
|
||||||
}
|
|
||||||
CPPUNIT_ASSERT(!helixPlayer->isPlaying());
|
CPPUNIT_ASSERT(!helixPlayer->isPlaying());
|
||||||
CPPUNIT_ASSERT(!listener1->stopFlag);
|
CPPUNIT_ASSERT(!listener1->stopFlag);
|
||||||
helixPlayer->start();
|
helixPlayer->start();
|
||||||
|
@ -517,15 +504,13 @@ HelixPlayerTest :: eventListenerTest(void)
|
||||||
|
|
||||||
// try with two listeners
|
// try with two listeners
|
||||||
Ptr<TestEventListener>::Ref listener2(new TestEventListener());
|
Ptr<TestEventListener>::Ref listener2(new TestEventListener());
|
||||||
helixPlayer->attachListener(listener2);
|
helixPlayer->attachListener(listener2.get());
|
||||||
|
|
||||||
CPPUNIT_ASSERT(!listener1->stopFlag);
|
CPPUNIT_ASSERT(!listener1->stopFlag);
|
||||||
CPPUNIT_ASSERT(!listener2->stopFlag);
|
CPPUNIT_ASSERT(!listener2->stopFlag);
|
||||||
try {
|
CPPUNIT_ASSERT_NO_THROW(
|
||||||
helixPlayer->open("file:var/test.mp3");
|
helixPlayer->open("file:var/test.mp3");
|
||||||
} catch (std::invalid_argument &e) {
|
);
|
||||||
CPPUNIT_FAIL(e.what());
|
|
||||||
}
|
|
||||||
CPPUNIT_ASSERT(!helixPlayer->isPlaying());
|
CPPUNIT_ASSERT(!helixPlayer->isPlaying());
|
||||||
CPPUNIT_ASSERT(!listener1->stopFlag);
|
CPPUNIT_ASSERT(!listener1->stopFlag);
|
||||||
CPPUNIT_ASSERT(!listener2->stopFlag);
|
CPPUNIT_ASSERT(!listener2->stopFlag);
|
||||||
|
@ -545,14 +530,13 @@ HelixPlayerTest :: eventListenerTest(void)
|
||||||
listener2->stopFlag = false;
|
listener2->stopFlag = false;
|
||||||
|
|
||||||
// try with only the second listener
|
// try with only the second listener
|
||||||
helixPlayer->detachListener(listener1);
|
CPPUNIT_ASSERT_NO_THROW(
|
||||||
|
helixPlayer->detachListener(listener1.get());
|
||||||
|
);
|
||||||
CPPUNIT_ASSERT(!listener2->stopFlag);
|
CPPUNIT_ASSERT(!listener2->stopFlag);
|
||||||
try {
|
CPPUNIT_ASSERT_NO_THROW(
|
||||||
helixPlayer->open("file:var/test.mp3");
|
helixPlayer->open("file:var/test.mp3");
|
||||||
} catch (std::invalid_argument &e) {
|
);
|
||||||
CPPUNIT_FAIL(e.what());
|
|
||||||
}
|
|
||||||
CPPUNIT_ASSERT(!helixPlayer->isPlaying());
|
CPPUNIT_ASSERT(!helixPlayer->isPlaying());
|
||||||
CPPUNIT_ASSERT(!listener2->stopFlag);
|
CPPUNIT_ASSERT(!listener2->stopFlag);
|
||||||
helixPlayer->start();
|
helixPlayer->start();
|
||||||
|
@ -566,7 +550,6 @@ HelixPlayerTest :: eventListenerTest(void)
|
||||||
CPPUNIT_ASSERT(listener2->stopFlag);
|
CPPUNIT_ASSERT(listener2->stopFlag);
|
||||||
listener2->stopFlag = false;
|
listener2->stopFlag = false;
|
||||||
|
|
||||||
|
|
||||||
helixPlayer->close();
|
helixPlayer->close();
|
||||||
helixPlayer->deInitialize();
|
helixPlayer->deInitialize();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue