android: fix voice recording — init g_rec, move includes, check startRecording result
- voice_recorder_init(db_path) in utun_bridge_init (was never called, g_rec stayed NULL) - voice_recorder_deinit() in utun_bridge_destroy - ViewModel: set _isRecording only after startRecording() succeeds
This commit is contained in:
1 parent
50214d50c1
commit
fc2adcf81d
2 files changed
+8
-4
No files matched your search
@@ -195,11 +195,14 @@ class ChatViewModel : ViewModel() {
|
||||
|
||||
fun startVoiceRecording() {
|
||||
val ch = _currentChannel.value ?: return
|
||||
if (!audioRecorder.startRecording(ch.id)) {
|
||||
LogManager.addLog("ERROR", "VM", "voice recording failed to start")
|
||||
return
|
||||
}
|
||||
_isRecording.value = true
|
||||
_isRecordingLocked.value = false
|
||||
recordingStartTimeMs = System.currentTimeMillis()
|
||||
_recordingDurationMs.value = 0
|
||||
audioRecorder.startRecording(ch.id)
|
||||
LogManager.addLog("INFO", "VM", "voice recording started ch=${ch.id}")
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#include "../libutun_lite/utun_config_api.h"
|
||||
#include "../libutun_lite/invite_link_c.h"
|
||||
#include "../libutun_lite/instance_lite.h"
|
||||
#include "../libutun_lite/voice_recorder.h"
|
||||
#include "../libutun_lite/attachment_sender.h"
|
||||
#include "../../../lib/debug_config.h"
|
||||
#include "../../../lib/u_async.h"
|
||||
#include "../../../lib/mem.h"
|
||||
@@ -140,10 +142,12 @@ bool utun_bridge_init(const char* db_path, int control_port,
|
||||
|
||||
bridge_log(BLEV_INFO, "bridge init: db=%s port=%d (stub, use nativeStart for real init)",
|
||||
db_path ? db_path : "(null)", control_port);
|
||||
voice_recorder_init(db_path);
|
||||
return true;
|
||||
}
|
||||
|
||||
void utun_bridge_destroy(void) {
|
||||
voice_recorder_deinit();
|
||||
instance_lite_stop();
|
||||
g_on_log = NULL;
|
||||
g_on_event = NULL;
|
||||
@@ -428,9 +432,6 @@ int utun_bridge_is_responsive(void) {
|
||||
* Voice recording
|
||||
* ────────────────────────────────────────────────────────────────── */
|
||||
|
||||
#include "../libutun_lite/voice_recorder.h"
|
||||
#include "../libutun_lite/attachment_sender.h"
|
||||
|
||||
int utun_bridge_voice_start(const char* channel_id) {
|
||||
return voice_recorder_start(channel_id, 48000, 1);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user