Skip to content

Commit

Permalink
fix(core): fix concurrent access on outputSurfaces when releasing sur…
Browse files Browse the repository at this point in the history
…faceprocessor
  • Loading branch information
ThibaultBee committed Nov 30, 2024
1 parent eb99947 commit 5295371
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ import java.util.concurrent.atomic.AtomicBoolean

class SurfaceProcessor(
val dynamicRangeProfile: DynamicRangeProfile
) : ISurfaceProcessorInternal,
SurfaceTexture.OnFrameAvailableListener {
) : ISurfaceProcessorInternal, SurfaceTexture.OnFrameAvailableListener {
private val renderer = OpenGlRenderer()

private val isReleaseRequested = AtomicBoolean(false)
Expand Down Expand Up @@ -147,8 +146,8 @@ class SurfaceProcessor(
if (isReleased && surfaceInputs.isEmpty()) {
// Once release is called, we can stop sending frame to output surfaces.
surfaceOutputs.forEach { it.close() }
removeAllOutputSurfaces()

surfaceOutputs.clear()
renderer.release()
glThread.quit()
}
Expand Down Expand Up @@ -184,9 +183,7 @@ class SurfaceProcessor(
}

private fun <T> executeSafely(
block: () -> T,
onSuccess: ((T) -> Unit),
onError: ((Throwable) -> Unit)
block: () -> T, onSuccess: ((T) -> Unit), onError: ((Throwable) -> Unit)
) {
try {
glHandler.post {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ open class DefaultStreamer(
// Sources
audioSourceInternal?.release()
videoSourceInternal?.release()
surfaceProcessor?.removeAllOutputSurfaces()

surfaceProcessor?.release()

// Encoders
Expand Down

0 comments on commit 5295371

Please sign in to comment.