@@ -32,10 +32,7 @@ ExternalTextureGL::~ExternalTextureGL() {
3232 glDeleteTextures (1 , &state_->gl_texture );
3333 }
3434 state_.release ();
35- if (texture_tbm_surface_) {
36- tbm_surface_internal_unref (texture_tbm_surface_);
37- texture_tbm_surface_ = NULL ;
38- }
35+ DestructionTbmSurface ();
3936 mutex_.unlock ();
4037}
4138
@@ -47,12 +44,12 @@ bool ExternalTextureGL::OnFrameAvailable(tbm_surface_h tbm_surface) {
4744 return false ;
4845 }
4946 if (texture_tbm_surface_) {
50- LoggerE (" texture_tbm_surface_ does not destruction, discard" );
47+ LoggerD (" texture_tbm_surface_ does not destruction, discard" );
5148 mutex_.unlock ();
5249 return false ;
5350 }
5451 if (!tbm_surface_internal_is_valid (tbm_surface)) {
55- LoggerE (" tbm_surface not valid, pass" );
52+ LoggerD (" tbm_surface not valid, pass" );
5653 mutex_.unlock ();
5754 return false ;
5855 }
@@ -66,12 +63,13 @@ bool ExternalTextureGL::PopulateTextureWithIdentifier(
6663 size_t width, size_t height, FlutterOpenGLTexture* opengl_texture) {
6764 mutex_.lock ();
6865 if (!texture_tbm_surface_) {
69- LoggerE (" texture_tbm_surface_ is NULL" );
66+ LoggerD (" texture_tbm_surface_ is NULL" );
7067 mutex_.unlock ();
7168 return false ;
7269 }
7370 if (!tbm_surface_internal_is_valid (texture_tbm_surface_)) {
74- LoggerE (" tbm_surface not valid" );
71+ LoggerD (" tbm_surface not valid" );
72+ DestructionTbmSurface ();
7573 mutex_.unlock ();
7674 return false ;
7775 }
@@ -122,20 +120,23 @@ bool ExternalTextureGL::PopulateTextureWithIdentifier(
122120 return true ;
123121}
124122
125- void ExternalTextureGL::DestructionTbmSurface () {
123+ void ExternalTextureGL::DestructionTbmSurfaceWithLock () {
126124 mutex_.lock ();
125+ DestructionTbmSurface ();
126+ mutex_.unlock ();
127+ }
128+
129+ void ExternalTextureGL::DestructionTbmSurface () {
127130 if (!texture_tbm_surface_) {
128131 LoggerE (" tbm_surface_h is NULL" );
129- mutex_.unlock ();
130132 return ;
131133 }
132134 tbm_surface_internal_unref (texture_tbm_surface_);
133135 texture_tbm_surface_ = NULL ;
134- mutex_.unlock ();
135136}
136137
137138void ExternalTextureGL::destructionCallback (void * user_data) {
138139 ExternalTextureGL* externalTextureGL =
139140 reinterpret_cast <ExternalTextureGL*>(user_data);
140- externalTextureGL->DestructionTbmSurface ();
141+ externalTextureGL->DestructionTbmSurfaceWithLock ();
141142}
0 commit comments