fix(audio): reframe send path to channel frame_ms; pin codec to 48 kHz
The AudioEngine capture clock is fixed at 48 kHz / 20 ms (960-sample frames), but a channel may set any Opus frame_ms (2.5..60 ms, voice.md §3) and the server enforces it unclamped. on_capture_frame handed the engine's 960-sample frame straight to an encoder configured for the channel's window: frame_ms > 20 was silently ignored, and frame_ms < 20 broke entirely (receiver sized its decode buffer too small -> OPUS_BUFFER_TOO_SMALL -> dead audio). Affected the hardware mic and vc_stream_feed_pcm alike. Reframe each captured/fed block to ls.frame_samples via a per-LocalStream accumulator (pre-sized at announce, no RT-thread alloc) before encode_and_send_frame; the 20 ms case stays a zero-copy fast path. Also pin the codec to 48 kHz in opus_params_from_audio_config — it was honoring a non-48k effective sample_rate against a 48 kHz PCM clock. New ctest frame_ms_reframe covers 40 ms (accumulate) and 10 ms (split) feed->encode->relay->decode->sink round trips. ctest --preset dev 25/25. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -202,4 +202,13 @@ if(VOICECAT_USE_VCPKG_DEPS)
|
||||
target_include_directories(test_external_pcm PRIVATE ${VC_TEST_INTERNAL_INCLUDES})
|
||||
add_test(NAME external_pcm COMMAND test_external_pcm)
|
||||
set_tests_properties(external_pcm PROPERTIES TIMEOUT 90)
|
||||
|
||||
# Non-20ms channel frame_ms: the fixed 48k/20ms engine clock is reframed to the channel's
|
||||
# Opus window before encoding. 40ms (accumulate) and 10ms (split) feed->sink round trips.
|
||||
add_executable(test_frame_ms_reframe test_frame_ms_reframe.cpp)
|
||||
target_link_libraries(test_frame_ms_reframe PRIVATE voicecat::server)
|
||||
target_compile_features(test_frame_ms_reframe PRIVATE cxx_std_20)
|
||||
target_include_directories(test_frame_ms_reframe PRIVATE ${VC_TEST_INTERNAL_INCLUDES})
|
||||
add_test(NAME frame_ms_reframe COMMAND test_frame_ms_reframe)
|
||||
set_tests_properties(frame_ms_reframe PROPERTIES TIMEOUT 90)
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user