From 5e1c50edf8d7d0bec05e6ff68ed7e0bb233ca441 Mon Sep 17 00:00:00 2001 From: "j.foucher" Date: Mon, 2 Mar 2026 14:38:49 +0100 Subject: [PATCH] Add diagnostic logs for Opus codec initialization and audio multicast - Log at InitOpusCodec: FVoiceModule availability, encoder/decoder creation, net role - Log at HandleAudioReceived: warn once if encoder is null or role is not Authority - These fire unconditionally (not behind bDebug) to catch the root cause Co-Authored-By: Claude Opus 4.6 --- .../PS_AI_ConvAgent_ElevenLabsComponent.cpp | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/Unreal/PS_AI_Agent/Plugins/PS_AI_ConvAgent/Source/PS_AI_ConvAgent/Private/PS_AI_ConvAgent_ElevenLabsComponent.cpp b/Unreal/PS_AI_Agent/Plugins/PS_AI_ConvAgent/Source/PS_AI_ConvAgent/Private/PS_AI_ConvAgent_ElevenLabsComponent.cpp index a2db8d2..a42ad9c 100644 --- a/Unreal/PS_AI_Agent/Plugins/PS_AI_ConvAgent/Source/PS_AI_ConvAgent/Private/PS_AI_ConvAgent_ElevenLabsComponent.cpp +++ b/Unreal/PS_AI_Agent/Plugins/PS_AI_ConvAgent/Source/PS_AI_ConvAgent/Private/PS_AI_ConvAgent_ElevenLabsComponent.cpp @@ -638,6 +638,19 @@ void UPS_AI_ConvAgent_ElevenLabsComponent::HandleAudioReceived(const TArray(GetOwnerRole()), static_cast(ROLE_Authority), + OpusEncoder.IsValid() ? TEXT("VALID") : TEXT("NULL"), + FVoiceModule::IsAvailable() ? TEXT("available") : TEXT("UNAVAILABLE")); + } + } if (GetOwnerRole() == ROLE_Authority && OpusEncoder.IsValid()) { uint32 CompressedSize = static_cast(OpusWorkBuffer.Num()); @@ -1453,10 +1466,16 @@ void UPS_AI_ConvAgent_ElevenLabsComponent::MulticastAgentStartedGenerating_Imple // ───────────────────────────────────────────────────────────────────────────── void UPS_AI_ConvAgent_ElevenLabsComponent::InitOpusCodec() { - if (!FVoiceModule::IsAvailable()) return; + if (!FVoiceModule::IsAvailable()) + { + UE_LOG(LogPS_AI_ConvAgent_ElevenLabs, Warning, + TEXT("[OPUS] FVoiceModule NOT available — Opus codec disabled. Network audio will NOT work.")); + return; + } FVoiceModule& VoiceModule = FVoiceModule::Get(); - if (GetOwnerRole() == ROLE_Authority) + const ENetRole Role = GetOwnerRole(); + if (Role == ROLE_Authority) { OpusEncoder = VoiceModule.CreateVoiceEncoder( PS_AI_ConvAgent_Audio_ElevenLabs::SampleRate, @@ -1469,6 +1488,12 @@ void UPS_AI_ConvAgent_ElevenLabsComponent::InitOpusCodec() PS_AI_ConvAgent_Audio_ElevenLabs::Channels); OpusWorkBuffer.SetNumUninitialized(8 * 1024); // 8 KB scratch buffer for Opus encode/decode + + UE_LOG(LogPS_AI_ConvAgent_ElevenLabs, Log, + TEXT("[OPUS] Init complete — Role=%d Encoder=%s Decoder=%s"), + static_cast(Role), + OpusEncoder.IsValid() ? TEXT("OK") : TEXT("NULL"), + OpusDecoder.IsValid() ? TEXT("OK") : TEXT("NULL")); } // ─────────────────────────────────────────────────────────────────────────────