Marc Rousavy 01a79d63ef
chore: Restructure codebase a bit (#1742)
* Move core Camera stuff into `/core/`

* `NativePreviewView` -> `PreviewView`
2023-09-01 13:08:33 +02:00

36 lines
912 B
Kotlin

package com.mrousavy.camera
import android.os.Handler
import android.os.HandlerThread
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.android.asCoroutineDispatcher
import kotlinx.coroutines.asExecutor
import java.util.concurrent.Executor
class CameraQueues {
companion object {
val cameraQueue = CameraQueue("mrousavy/VisionCamera.main")
val videoQueue = CameraQueue("mrousavy/VisionCamera.video")
}
class CameraQueue(name: String) {
val handler: Handler
private val thread: HandlerThread
val executor: Executor
val coroutineDispatcher: CoroutineDispatcher
init {
thread = HandlerThread(name)
thread.start()
handler = Handler(thread.looper)
coroutineDispatcher = handler.asCoroutineDispatcher(name)
executor = coroutineDispatcher.asExecutor()
}
protected fun finalize() {
thread.quitSafely()
}
}
}