Skip to content

Commit 534cf8c

Browse files
committed
fix(ui): force to remove the preview surface before making it invalid.
1 parent c0e329c commit 534cf8c

File tree

1 file changed

+7
-0
lines changed
  • ui/src/main/java/io/github/thibaultbee/streampack/ui/views

1 file changed

+7
-0
lines changed

ui/src/main/java/io/github/thibaultbee/streampack/ui/views/PreviewView.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,13 @@ class PreviewView @JvmOverloads constructor(
384384
try {
385385
Logger.d(TAG, "Starting preview")
386386
videoSource.previewMutex.withLock {
387+
/**
388+
* [requestSurface] will make the current preview [Surface] invalid.
389+
* Force the [videoSource] to remove the preview [Surface] before the [Surface] is invalid.
390+
* It prevents race conditions with the [videoSource] configuration.
391+
*/
392+
videoSource.stopPreview()
393+
videoSource.resetPreview()
387394
val surface = requestSurface(viewfinderBuilder)
388395
videoSource.startPreview(surface)
389396
}

0 commit comments

Comments
 (0)