@@ -32,10 +32,7 @@ ExternalTextureGL::~ExternalTextureGL() {
32
32
glDeleteTextures (1 , &state_->gl_texture );
33
33
}
34
34
state_.release ();
35
- if (texture_tbm_surface_) {
36
- tbm_surface_internal_unref (texture_tbm_surface_);
37
- texture_tbm_surface_ = NULL ;
38
- }
35
+ DestructionTbmSurface ();
39
36
mutex_.unlock ();
40
37
}
41
38
@@ -47,12 +44,12 @@ bool ExternalTextureGL::OnFrameAvailable(tbm_surface_h tbm_surface) {
47
44
return false ;
48
45
}
49
46
if (texture_tbm_surface_) {
50
- LoggerE (" texture_tbm_surface_ does not destruction, discard" );
47
+ LoggerD (" texture_tbm_surface_ does not destruction, discard" );
51
48
mutex_.unlock ();
52
49
return false ;
53
50
}
54
51
if (!tbm_surface_internal_is_valid (tbm_surface)) {
55
- LoggerE (" tbm_surface not valid, pass" );
52
+ LoggerD (" tbm_surface not valid, pass" );
56
53
mutex_.unlock ();
57
54
return false ;
58
55
}
@@ -66,12 +63,13 @@ bool ExternalTextureGL::PopulateTextureWithIdentifier(
66
63
size_t width, size_t height, FlutterOpenGLTexture* opengl_texture) {
67
64
mutex_.lock ();
68
65
if (!texture_tbm_surface_) {
69
- LoggerE (" texture_tbm_surface_ is NULL" );
66
+ LoggerD (" texture_tbm_surface_ is NULL" );
70
67
mutex_.unlock ();
71
68
return false ;
72
69
}
73
70
if (!tbm_surface_internal_is_valid (texture_tbm_surface_)) {
74
- LoggerE (" tbm_surface not valid" );
71
+ LoggerD (" tbm_surface not valid" );
72
+ DestructionTbmSurface ();
75
73
mutex_.unlock ();
76
74
return false ;
77
75
}
@@ -122,20 +120,23 @@ bool ExternalTextureGL::PopulateTextureWithIdentifier(
122
120
return true ;
123
121
}
124
122
125
- void ExternalTextureGL::DestructionTbmSurface () {
123
+ void ExternalTextureGL::DestructionTbmSurfaceWithLock () {
126
124
mutex_.lock ();
125
+ DestructionTbmSurface ();
126
+ mutex_.unlock ();
127
+ }
128
+
129
+ void ExternalTextureGL::DestructionTbmSurface () {
127
130
if (!texture_tbm_surface_) {
128
131
LoggerE (" tbm_surface_h is NULL" );
129
- mutex_.unlock ();
130
132
return ;
131
133
}
132
134
tbm_surface_internal_unref (texture_tbm_surface_);
133
135
texture_tbm_surface_ = NULL ;
134
- mutex_.unlock ();
135
136
}
136
137
137
138
void ExternalTextureGL::destructionCallback (void * user_data) {
138
139
ExternalTextureGL* externalTextureGL =
139
140
reinterpret_cast <ExternalTextureGL*>(user_data);
140
- externalTextureGL->DestructionTbmSurface ();
141
+ externalTextureGL->DestructionTbmSurfaceWithLock ();
141
142
}
0 commit comments