Skip to content

Commit

Permalink
fix VideoViewControllerBaseMixin.disposeRender not be called with flu…
Browse files Browse the repository at this point in the history
…tter texture rendering
  • Loading branch information
littleGnAl committed Mar 29, 2023
1 parent f6006ba commit 930fbbe
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions lib/src/impl/video_view_controller_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ extension VideoViewControllerBaseExt on VideoViewControllerBase {
mixin VideoViewControllerBaseMixin implements VideoViewControllerBase {
int _textureId = kTextureNotInit;

bool _isSetupView = false;
bool _isCreatedRender = false;
bool _isDisposeRender = false;

@internal
Expand Down Expand Up @@ -74,7 +74,7 @@ mixin VideoViewControllerBaseMixin implements VideoViewControllerBase {
@override
Future<void> dispose() async {
_isDisposeRender = true;
_isSetupView = false;
_isCreatedRender = false;
}

@protected
Expand Down Expand Up @@ -111,11 +111,11 @@ mixin VideoViewControllerBaseMixin implements VideoViewControllerBase {
@internal
@override
Future<void> disposeRender() async {
if (!_isSetupView) {
if (!_isCreatedRender || _isDisposeRender) {
return;
}
_isDisposeRender = true;
_isSetupView = false;
_isCreatedRender = false;

await disposeRenderInternal();
}
Expand All @@ -126,12 +126,20 @@ mixin VideoViewControllerBaseMixin implements VideoViewControllerBase {
int uid,
String channelId,
int videoSourceType,
) {
return rtcEngine.globalVideoViewController.createTextureRender(
) async {
if (_isCreatedRender) {
return kTextureNotInit;
}
final textureId =
await rtcEngine.globalVideoViewController.createTextureRender(
uid,
channelId,
videoSourceType,
);

_isCreatedRender = true;

return textureId;
}

@override
Expand Down Expand Up @@ -173,13 +181,13 @@ mixin VideoViewControllerBaseMixin implements VideoViewControllerBase {

@override
Future<void> setupView(int nativeViewPtr) async {
if (_isDisposeRender) {
if (_isCreatedRender) {
return;
}

await setupNativeViewInternal(nativeViewPtr);

_isSetupView = true;
_isCreatedRender = true;
}

@internal
Expand Down

0 comments on commit 930fbbe

Please sign in to comment.