Merge pull request #6256 from 21pages/android_ci
Revert "fix android ci, replace use with try-finally"
This commit is contained in:
commit
1f51d37ae6
@ -349,17 +349,12 @@ class MainService : Service() {
|
|||||||
).apply {
|
).apply {
|
||||||
setOnImageAvailableListener({ imageReader: ImageReader ->
|
setOnImageAvailableListener({ imageReader: ImageReader ->
|
||||||
try {
|
try {
|
||||||
// https://stackoverflow.com/questions/35136715/try-with-resources-use-extension-function-in-kotlin-does-not-always-work
|
imageReader.acquireLatestImage().use { image ->
|
||||||
// https://stackoverflow.com/questions/72537045/kotlin-use-with-autocloseable-type-and-a-lambda-returning-boolean
|
if (image == null) return@setOnImageAvailableListener
|
||||||
val image = imageReader.acquireLatestImage()
|
|
||||||
if (image == null) return@setOnImageAvailableListener
|
|
||||||
try {
|
|
||||||
val planes = image.planes
|
val planes = image.planes
|
||||||
val buffer = planes[0].buffer
|
val buffer = planes[0].buffer
|
||||||
buffer.rewind()
|
buffer.rewind()
|
||||||
onVideoFrameUpdate(buffer)
|
onVideoFrameUpdate(buffer)
|
||||||
} finally {
|
|
||||||
image.close()
|
|
||||||
}
|
}
|
||||||
} catch (ignored: java.lang.Exception) {
|
} catch (ignored: java.lang.Exception) {
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user