fix: enable VU meter updates by calling SetVURefreshRate

VU meters were not lighting up because the native audio client was
never told to start sending VU data. This fix adds the SetVURefreshRate(150)
call when joining a session to enable VU updates every 150ms.

Also adds a ref pattern in useMixerStore to prevent potential stale
closure issues in the handleBridgeCallback VU callback handler.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Nuwan 2026-01-23 18:47:52 +05:30
parent d8ae60e251
commit c3eb6b7d1a
2 changed files with 18 additions and 4 deletions

View File

@ -437,6 +437,7 @@ const JKSessionScreen = () => {
const joinSession = async () => {
await jamClient.SetVURefreshRate(150);
await jamClient.SessionRegisterCallback("JK.HandleBridgeCallback2");
await jamClient.SessionSetAlertCallback("JK.HandleAlertCallback");
await jamClient.RegisterRecordingCallbacks("JK.HandleRecordingStartResult", "JK.HandleRecordingStopResult", "JK.HandleRecordingStarted", "JK.HandleRecordingStopped", "JK.HandleRecordingAborted");

View File

@ -34,6 +34,7 @@ export default function useMixerStore() {
jamClient,
} = useJamServerContext();
const mixerHelper = useMixersContext();
const mixerHelperRef = useRef(null);
const logger = console; // Replace with your logging mechanism if needed
//const { updateVU } = useVuHelpers();
@ -64,6 +65,11 @@ export default function useMixerStore() {
6: "MetroFile"
};
// Keep mixerHelperRef in sync with current mixerHelper
useEffect(() => {
mixerHelperRef.current = mixerHelper;
}, [mixerHelper]);
// Initialize global callbacks
useEffect(() => {
if (!window.JK) window.JK = {};
@ -165,11 +171,18 @@ export default function useMixerStore() {
// value is a DB value from -80 to 20. Convert to float from 0.0-1.0
//console.log('handleBridgeCallback@mixers',@mixers)
// console.log("mixerHelper.isReady", mixerHelper.isReady.current);
if (mixerHelper.isReady.current) {
// console.log("mixerHelper handleBridgeCallback: ", mixerId, mode, leftValue, rightValue, leftClipping, rightClipping);
// Use ref to get current mixerHelper (fixes stale closure issue)
const currentMixerHelper = mixerHelperRef.current;
mixerHelper.updateVU(mixerId, mode, (leftValue + 80) / 80, leftClipping, (rightValue + 80) / 80, rightClipping);
if (currentMixerHelper?.isReady.current) {
currentMixerHelper.updateVU(
mixerId,
mode,
(leftValue + 80) / 80,
leftClipping,
(rightValue + 80) / 80,
rightClipping
);
}
}
}