SetSource() is called multiple times at the same time when playing multiple Videos. 11/222811/9
authorJoogab Yun <joogab.yun@samsung.com>
Mon, 20 Jan 2020 08:04:51 +0000 (17:04 +0900)
committerJoogab Yun <joogab.yun@samsung.com>
Tue, 21 Jan 2020 01:48:48 +0000 (10:48 +0900)
At the same time, mTbmSurface may not sync when PrepareTexture() is executed.

So I add a mutex lock, and valid check

Change-Id: I807a9bee58fa920879bbdfa1867325c43e9f7730

dali/internal/imaging/tizen/native-image-source-impl-tizen.cpp [changed mode: 0644->0755]
dali/internal/imaging/tizen/native-image-source-impl-tizen.h

old mode 100644 (file)
new mode 100755 (executable)
index 57c2f60..987a357
@@ -89,7 +89,8 @@ NativeImageSourceTizen::NativeImageSourceTizen( uint32_t width, uint32_t height,
   mEglImageKHR( NULL ),
   mEglGraphics( NULL ),
   mEglImageExtensions( NULL ),
-  mSetSource( false )
+  mSetSource( false ),
+  mMutex()
 {
   DALI_ASSERT_ALWAYS( Adaptor::IsAvailable() );
 
@@ -209,6 +210,7 @@ Any NativeImageSourceTizen::GetNativeImageSource() const
 
 bool NativeImageSourceTizen::GetPixels(std::vector<unsigned char>& pixbuf, unsigned& width, unsigned& height, Pixel::Format& pixelFormat) const
 {
+  Dali::Mutex::ScopedLock lock( mMutex );
   if( mTbmSurface != NULL )
   {
     tbm_surface_info_s surface_info;
@@ -315,6 +317,7 @@ bool NativeImageSourceTizen::EncodeToFile(const std::string& filename) const
 
 void NativeImageSourceTizen::SetSource( Any source )
 {
+  Dali::Mutex::ScopedLock lock( mMutex );
   if( mOwnTbmSurface )
   {
     if( mTbmSurface != NULL && tbm_surface_destroy( mTbmSurface ) != TBM_SURFACE_ERROR_NONE )
@@ -402,7 +405,7 @@ bool NativeImageSourceTizen::GlExtensionCreate()
   // casting from an unsigned int to a void *, which should then be cast back
   // to an unsigned int in the driver.
   EGLClientBuffer eglBuffer = reinterpret_cast< EGLClientBuffer >(mTbmSurface);
-  if( !eglBuffer )
+  if( !eglBuffer || !tbm_surface_internal_is_valid( mTbmSurface ) )
   {
     return false;
   }
@@ -417,6 +420,7 @@ bool NativeImageSourceTizen::GlExtensionCreate()
 
 void NativeImageSourceTizen::GlExtensionDestroy()
 {
+  Dali::Mutex::ScopedLock lock( mMutex );
   if( mEglImageKHR )
   {
     mEglImageExtensions->DestroyImageKHR(mEglImageKHR);
@@ -434,6 +438,7 @@ uint32_t NativeImageSourceTizen::TargetTexture()
 
 void NativeImageSourceTizen::PrepareTexture()
 {
+  Dali::Mutex::ScopedLock lock( mMutex );
   if( mSetSource )
   {
     void* eglImage = mEglImageKHR;
index 7a746e8..fdeca56 100755 (executable)
@@ -21,6 +21,7 @@
 // EXTERNAL INCLUDES
 #include <tbm_surface.h>
 #include <dali/devel-api/images/native-image-interface-extension.h>
+#include <dali/devel-api/threading/mutex.h>
 #include <dali/public-api/common/dali-vector.h>
 
 // INTERNAL INCLUDES
@@ -190,6 +191,7 @@ private:
   EglGraphics* mEglGraphics;                  ///< EGL Graphics
   EglImageExtensions* mEglImageExtensions;    ///< The EGL Image Extensions
   bool mSetSource;
+  mutable Dali::Mutex mMutex;
 };
 
 } // namespace Adaptor