From 7aada92be908b6328dd0f7a24700ca52d3d34f58 Mon Sep 17 00:00:00 2001 From: evgeny Date: Thu, 8 Oct 2026 10:29:29 +0200 Subject: [PATCH] android: preserve reply context while recording voice --- tools/chatgui-android/libutun_lite/voice_recorder.c | 7 ++++++- tools/chatgui-android/libutun_lite/voice_recorder.h | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/chatgui-android/libutun_lite/voice_recorder.c b/tools/chatgui-android/libutun_lite/voice_recorder.c index ab45ffe1..3416beb0 100644 --- a/tools/chatgui-android/libutun_lite/voice_recorder.c +++ b/tools/chatgui-android/libutun_lite/voice_recorder.c @@ -25,6 +25,8 @@ struct voice_recorder { int active; char channel_id[64]; + uint8_t reply_to[32]; + uint64_t request_id; int sample_rate; int channels; int frame_samples; @@ -106,7 +108,7 @@ void voice_recorder_deinit(void) { pthread_mutex_unlock(&g_init_mtx); } -int voice_recorder_start(const char* channel_id, int sample_rate, int channels) { +int voice_recorder_start(const char* channel_id, int sample_rate, int channels, const uint8_t reply_to[32], uint64_t request_id) { if (!channel_id || !channel_id[0] || strlen(channel_id) >= 64 || sample_rate != 48000 || channels != 1) { DEBUG_ERROR(DEBUG_CATEGORY_MEDIA, "voice start: invalid target or capture format rate=%d channels=%d", sample_rate, channels); return -1; @@ -129,6 +131,8 @@ int voice_recorder_start(const char* channel_id, int sample_rate, int channels) g_rec->channels = channels; g_rec->frame_samples = sample_rate * FRAME_MS / 1000; snprintf(g_rec->channel_id, sizeof(g_rec->channel_id), "%s", channel_id ? channel_id : ""); + memcpy(g_rec->reply_to, reply_to, sizeof(g_rec->reply_to)); + g_rec->request_id = request_id; g_rec->pcm_count = 0; g_rec->active = 1; @@ -213,6 +217,7 @@ int voice_recorder_stop(int* out_duration_ms) { } req->inst = instance_lite_get_instance(); req->info.kind = ATTACHMENT_VOICE; req->preset = g_rec->preset; req->is_dm = !strncmp(g_rec->channel_id, "dm:", 3); + if (!req->is_dm) { memcpy(req->reply_to, g_rec->reply_to, sizeof(req->reply_to)); req->request_id = g_rec->request_id; } snprintf(req->target, sizeof(req->target), "%s", g_rec->channel_id + (req->is_dm ? 3 : 0)); if (g_rec->compressor && g_rec->compressor_enabled) { struct audio_compressor* replacement = audio_compressor_clone_config(g_rec->compressor); diff --git a/tools/chatgui-android/libutun_lite/voice_recorder.h b/tools/chatgui-android/libutun_lite/voice_recorder.h index 157e1982..1d2e19af 100644 --- a/tools/chatgui-android/libutun_lite/voice_recorder.h +++ b/tools/chatgui-android/libutun_lite/voice_recorder.h @@ -18,7 +18,7 @@ struct voice_recorder; int voice_recorder_init(const char* db_path); void voice_recorder_deinit(void); -int voice_recorder_start(const char* channel_id, int sample_rate, int channels); +int voice_recorder_start(const char* channel_id, int sample_rate, int channels, const uint8_t reply_to[32], uint64_t request_id); int voice_recorder_feed(const int16_t* samples, int count); int voice_recorder_stop(int* out_duration_ms); void voice_recorder_cancel(void);