From e5b9fb7acaf1d558f68b29d06ed754d6e690d06c Mon Sep 17 00:00:00 2001 From: Stan Grams Date: Fri, 6 Mar 2026 11:57:55 +0100 Subject: [PATCH] [refactor](trx-core): add buffered audio write helper Co-authored-by: OpenAI Codex Signed-off-by: Stan Grams --- src/trx-core/src/audio.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/trx-core/src/audio.rs b/src/trx-core/src/audio.rs index aca9b68..73e577d 100644 --- a/src/trx-core/src/audio.rs +++ b/src/trx-core/src/audio.rs @@ -29,7 +29,7 @@ pub struct AudioStreamInfo { } /// Write a length-prefixed audio message. -pub async fn write_audio_msg( +pub async fn write_audio_msg_buffered( writer: &mut W, msg_type: u8, payload: &[u8], @@ -38,6 +38,16 @@ pub async fn write_audio_msg( writer.write_u8(msg_type).await?; writer.write_u32(len).await?; writer.write_all(payload).await?; + Ok(()) +} + +/// Write a length-prefixed audio message and flush the writer. +pub async fn write_audio_msg( + writer: &mut W, + msg_type: u8, + payload: &[u8], +) -> std::io::Result<()> { + write_audio_msg_buffered(writer, msg_type, payload).await?; writer.flush().await?; Ok(()) }