Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ package fr.g123k.torch_compat.impl

import android.content.Context
import android.content.pm.PackageManager
import android.graphics.SurfaceTexture;
import android.hardware.Camera

class TorchCamera1Impl(private val context: Context) : BaseTorch() {

private var camera: Camera? = null
private var surface: SurfaceTexture? = null

private fun initCamera(): Camera? {
if (camera == null) {
Expand All @@ -17,6 +19,8 @@ class TorchCamera1Impl(private val context: Context) : BaseTorch() {
} catch (e: Exception) {
null
}
surface = SurfaceTexture(0)
camera?.setPreviewTexture(surface)
}

return camera
Expand Down Expand Up @@ -51,8 +55,9 @@ class TorchCamera1Impl(private val context: Context) : BaseTorch() {
}

override fun dispose() {
surface?.release()
camera?.release()
camera = null
}

}
}