update kotlin api for better release native object and add user-friendly apis. (#1275)
This commit is contained in:
@@ -15,10 +15,19 @@ class OnlineStream(var ptr: Long = 0) {
|
||||
|
||||
fun release() = finalize()
|
||||
|
||||
fun use(block: (OnlineStream) -> Unit) {
|
||||
try {
|
||||
block(this)
|
||||
} finally {
|
||||
release()
|
||||
}
|
||||
}
|
||||
|
||||
private external fun acceptWaveform(ptr: Long, samples: FloatArray, sampleRate: Int)
|
||||
private external fun inputFinished(ptr: Long)
|
||||
private external fun delete(ptr: Long)
|
||||
|
||||
|
||||
companion object {
|
||||
init {
|
||||
System.loadLibrary("sherpa-onnx-jni")
|
||||
|
||||
Reference in New Issue
Block a user