From 3aab944038fe2c70c7045c9929e4b6e6b5d1e72f Mon Sep 17 00:00:00 2001 From: Hans Date: Mon, 21 Oct 2024 23:55:29 +0800 Subject: [PATCH] fix(Android): fix android implement --- android/src/main/java/com/barkrn/BarkContext.kt | 12 ++++-------- android/src/oldarch/BarkRnSpec.kt | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/android/src/main/java/com/barkrn/BarkContext.kt b/android/src/main/java/com/barkrn/BarkContext.kt index 2e86ca8..9578f50 100644 --- a/android/src/main/java/com/barkrn/BarkContext.kt +++ b/android/src/main/java/com/barkrn/BarkContext.kt @@ -1,13 +1,9 @@ package com.barkrn class BarkContext { - private var context: Long = 0 + private var context: Long = 0L - class BarkResult(success: Boolean, load_time: Int, eval_time: Int) { - val success: Boolean - val load_time: Int - val eval_time: Int - } + class BarkResult(success: Boolean, load_time: Int, eval_time: Int) external fun nativeInitContext(model_path: String, params: Map): Long external fun nativeGenerate(context: Long, text: String, out_path: String, threads: Int): BarkResult @@ -25,9 +21,9 @@ class BarkContext { } fun release() { - if (context != 0) { + if (context != 0L) { nativeReleaseContext(context) - context = 0 + context = 0L } } } diff --git a/android/src/oldarch/BarkRnSpec.kt b/android/src/oldarch/BarkRnSpec.kt index 366d97d..bf57f94 100644 --- a/android/src/oldarch/BarkRnSpec.kt +++ b/android/src/oldarch/BarkRnSpec.kt @@ -9,7 +9,7 @@ abstract class BarkRnSpec internal constructor(context: ReactApplicationContext) ReactContextBaseJavaModule(context) { abstract fun init_context(model_path: String, params: ReadableMap, promise: Promise) - abstract fun generate(id: Int, text: String, threads: Int, audio_path: String, promise: Promise) + abstract fun generate(id: Int, text: String, out_path: String, threads: Int, promise: Promise) abstract fun release_context(id: Int, promise: Promise) abstract fun release_all_contexts(promise: Promise) }