fix: Fix maxImages have been acquired
error in Frame Processor (#2430)
* fix: maxImages when frameprocessor error * fix: Use `try`/`finally` for safety --------- Co-authored-by: Marc Rousavy <me@mrousavy.com>
This commit is contained in:
parent
4041ee8cbd
commit
7e2889cf84
@ -110,20 +110,22 @@ class VideoPipeline(
|
|||||||
Log.i(TAG, "ImageReader::onImageAvailable!")
|
Log.i(TAG, "ImageReader::onImageAvailable!")
|
||||||
val image = reader.acquireNextImage() ?: return@setOnImageAvailableListener
|
val image = reader.acquireNextImage() ?: return@setOnImageAvailableListener
|
||||||
|
|
||||||
try {
|
|
||||||
// TODO: Get correct orientation and isMirrored
|
// TODO: Get correct orientation and isMirrored
|
||||||
val frame = Frame(image, image.timestamp, Orientation.PORTRAIT, isMirrored)
|
val frame = Frame(image, image.timestamp, Orientation.PORTRAIT, isMirrored)
|
||||||
frame.incrementRefCount()
|
frame.incrementRefCount()
|
||||||
|
|
||||||
|
try {
|
||||||
frameProcessor?.call(frame)
|
frameProcessor?.call(frame)
|
||||||
|
|
||||||
if (hasOutputs) {
|
if (hasOutputs) {
|
||||||
// If we have outputs (e.g. a RecordingSession), pass the frame along to the OpenGL pipeline
|
// If we have outputs (e.g. a RecordingSession), pass the frame along to the OpenGL pipeline
|
||||||
imageWriter!!.queueInputImage(image)
|
imageWriter!!.queueInputImage(image)
|
||||||
}
|
}
|
||||||
|
|
||||||
frame.decrementRefCount()
|
|
||||||
} catch (e: Throwable) {
|
} 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)
|
}, CameraQueues.videoQueue.handler)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user