Skip to content

Commit

Permalink
fix: Fix maxImages have been acquired error in Frame Processor (#2430)
Browse files Browse the repository at this point in the history
* fix: maxImages when frameprocessor error

* fix: Use `try`/`finally` for safety

---------

Co-authored-by: Marc Rousavy <me@mrousavy.com>
  • Loading branch information
danieloprado and mrousavy authored Jan 25, 2024
1 parent 4041ee8 commit 7e2889c
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,22 @@ class VideoPipeline(
Log.i(TAG, "ImageReader::onImageAvailable!")
val image = reader.acquireNextImage() ?: return@setOnImageAvailableListener

// TODO: Get correct orientation and isMirrored
val frame = Frame(image, image.timestamp, Orientation.PORTRAIT, isMirrored)
frame.incrementRefCount()

try {
// TODO: Get correct orientation and isMirrored
val frame = Frame(image, image.timestamp, Orientation.PORTRAIT, isMirrored)
frame.incrementRefCount()
frameProcessor?.call(frame)

if (hasOutputs) {
// If we have outputs (e.g. a RecordingSession), pass the frame along to the OpenGL pipeline
imageWriter!!.queueInputImage(image)
}

frame.decrementRefCount()
} catch (e: Throwable) {
Log.e(TAG, "Failed to call Frame Processor!", e)
Log.e(TAG, "FrameProcessor/ImageReader pipeline threw an error!", e)
throw e
} finally {
frame.decrementRefCount()
}
}, CameraQueues.videoQueue.handler)

Expand Down

1 comment on commit 7e2889c

@vercel
Copy link

@vercel vercel bot commented on 7e2889c Jan 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.