From 4ae05edb7e176339665e35b93780c308c1944529 Mon Sep 17 00:00:00 2001 From: Joogab Yun Date: Mon, 20 Jan 2020 17:04:51 +0900 Subject: [PATCH] SetSource() is called multiple times at the same time when playing multiple Videos. 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 | 9 +++++++-- dali/internal/imaging/tizen/native-image-source-impl-tizen.h | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) mode change 100644 => 100755 dali/internal/imaging/tizen/native-image-source-impl-tizen.cpp diff --git a/dali/internal/imaging/tizen/native-image-source-impl-tizen.cpp b/dali/internal/imaging/tizen/native-image-source-impl-tizen.cpp old mode 100644 new mode 100755 index 57c2f60..987a357 --- a/dali/internal/imaging/tizen/native-image-source-impl-tizen.cpp +++ b/dali/internal/imaging/tizen/native-image-source-impl-tizen.cpp @@ -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& 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; diff --git a/dali/internal/imaging/tizen/native-image-source-impl-tizen.h b/dali/internal/imaging/tizen/native-image-source-impl-tizen.h index 7a746e8..fdeca56 100755 --- a/dali/internal/imaging/tizen/native-image-source-impl-tizen.h +++ b/dali/internal/imaging/tizen/native-image-source-impl-tizen.h @@ -21,6 +21,7 @@ // EXTERNAL INCLUDES #include #include +#include #include // 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 -- 2.7.4