Fix the issue for VPSS-884
authorEonseokLee <eonseok.lee@samsung.com>
Wed, 15 May 2013 04:32:26 +0000 (13:32 +0900)
committerEonseokLee <eonseok.lee@samsung.com>
Wed, 15 May 2013 04:47:54 +0000 (13:47 +0900)
Change-Id: Ia4c2b7bfda65449fa1f91707a82a0601625829c7
Signed-off-by: EonseokLee <eonseok.lee@samsung.com>
src/FMedia_PlayerImpl.cpp
src/inc/FMedia_PlayerImpl.h

index 3eb3abe..b9ec52a 100644 (file)
@@ -269,6 +269,12 @@ _PlayerImpl::Construct(IPlayerEventListener& listener, const Tizen::Graphics::Bu
                SysTryCatch(NID_MEDIA, __hCanvas != 0, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used.  __hCanvas = %d", __hCanvas);
        }
 
+       __pEndOfStreamHandler.reset(new (std::nothrow) Thread);
+       SysTryReturn(NID_MEDIA, __pEndOfStreamHandler.get() != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                       "[E_OUT_OF_MEMORY]could not create memory for End of steam handling thread");
+       r = __pEndOfStreamHandler->Construct(*this);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Thread::Construct failed", GetErrorMessage(r));
+
        __pMutex->Acquire();
        SysTryLog(NID_MEDIA, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
        __playerCount++;
@@ -352,6 +358,12 @@ _PlayerImpl::Construct(IPlayerEventListener& listener, IPlayerVideoEventListener
        r = SetLooping(false);
        SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Failed to perform SetLooping operation.", GetErrorMessage(r));
 
+       __pEndOfStreamHandler.reset(new (std::nothrow) Thread);
+       SysTryReturn(NID_MEDIA, __pEndOfStreamHandler.get() != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                       "[E_OUT_OF_MEMORY]could not create memory for End of steam handling thread");
+       r = __pEndOfStreamHandler->Construct(*this);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Thread::Construct failed", GetErrorMessage(r));
+
        __pMutex->Acquire();
        SysTryLog(NID_MEDIA, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
        __playerCount++;
@@ -422,6 +434,12 @@ _PlayerImpl::Construct(IPlayerEventListener& listener, Tizen::Graphics::Opengl::
        r = SetLooping(false);
        SysTryCatch(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Propagating. Failed to perform SetLooping operation.", GetErrorMessage(r));
 
+       __pEndOfStreamHandler.reset(new (std::nothrow) Thread);
+       SysTryReturn(NID_MEDIA, __pEndOfStreamHandler.get() != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
+                       "[E_OUT_OF_MEMORY]could not create memory for End of steam handling thread");
+       r = __pEndOfStreamHandler->Construct(*this);
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, r, r, "[%s] Thread::Construct failed", GetErrorMessage(r));
+
        __pMutex->Acquire();
        SysTryLog(NID_MEDIA, r == E_SUCCESS, "[%s] Propagating.", GetErrorMessage(r));
        __playerCount++;
@@ -1606,6 +1624,15 @@ _PlayerImpl::PlayerSeekCompletedCallBack(void *pUserData)
        pPlyarImpl->HandlePlayerSeekCompleted();
 }
 
+//This is used exclusively for End of stream handling
+Tizen::Base::Object*
+_PlayerImpl::Run(void)
+{
+       player_stop(__hPlayer);
+       __currentState = PLAYER_STATE_ENDOFCLIP;
+       SendEvent(_PLAYER_EVENT_ENDOFCLIP, 0);
+}
+
 //Tizen Handle Functions
 void
 _PlayerImpl::HandlePlayerPrepared(int errorCode)
@@ -1633,9 +1660,9 @@ _PlayerImpl::HandlePlayerPrepared(int errorCode)
 void
 _PlayerImpl::HandlePlayerCompleted(void)
 {
-       player_stop(__hPlayer);
-       __currentState = PLAYER_STATE_ENDOFCLIP;
-       SendEvent(_PLAYER_EVENT_ENDOFCLIP, 0);
+       result r = E_SUCCESS;
+       r = __pEndOfStreamHandler->Start();
+       SysTryReturn(NID_MEDIA, r == E_SUCCESS, , r, "[%s] Thread::Start failed", GetErrorMessage(r));
 }
 
 void
index d0dd52e..38c0a6f 100644 (file)
@@ -54,6 +54,7 @@ enum _PlayerEventType;
 class _OSP_EXPORT_ _PlayerImpl
        : public Tizen::Base::Object
        , public Tizen::Base::Runtime::ITimerEventListener
+       , public Tizen::Base::Runtime::IRunnable
 {
                enum Orientation
        {
@@ -111,6 +112,7 @@ public:
        int GetHttpStreamingDownloadProgress(void) const;
 
        void OnTimerExpired(Tizen::Base::Runtime::Timer& timer);
+       Tizen::Base::Object* Run(void);
 
        static void PlayerStartedCallBack(void *pUserData);
        static void PlayerCompletedCallBack(void *pUserData);
@@ -166,6 +168,7 @@ private:
        std::unique_ptr<_PlayerProgressiveDownloadEvent> __pPlayerProgressiveDownloadEvent;
        std::unique_ptr<Tizen::Base::Runtime::Timer> __pPdTimer;
        std::unique_ptr<Tizen::Base::ByteBuffer> __pTargetByteBuffer;
+       std::unique_ptr<Tizen::Base::Runtime::Thread> __pEndOfStreamHandler;
        static std::unique_ptr<Tizen::Base::Runtime::Mutex> __pMutex;
        static bool __isInstanceMutexInitialized;