Skip to content

Feat/client audio via zenoh frame#307

Merged
FRICK-ELDY merged 7 commits into
mainfrom
feat/client-audio-via-zenoh-frame
May 2, 2026
Merged

Feat/client audio via zenoh frame#307
FRICK-ELDY merged 7 commits into
mainfrom
feat/client-audio-via-zenoh-frame

Conversation

@FRICK-ELDY

Copy link
Copy Markdown
Owner

protoをrender_frameから分離。音キューはContentの任意コールバックで組み立て、描画コンポーネントはencodeのみ担当。

@FRICK-ELDY FRICK-ELDY self-assigned this May 2, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements a server-driven audio cue system, allowing the Elixir backend to trigger sound effects on the Rust client by including relative asset paths in Zenoh render frames. Key changes include new callbacks in the Elixir Content behavior, state management for pending audio cues in BulletHell3D, and updates to the Rust AssetLoader and NetworkRenderBridge to safely load and play these cues. Review feedback identifies a potential performance bottleneck due to synchronous file I/O within the audio thread's main loop and suggests an optimization in the frame reuse logic to avoid redundant cloning and clearing of audio data.

}
AudioCommand::PlaySeFromRelativePath(ref path) => {
if let Some(audio) = &audio {
if let Some(bytes) = loader.load_bytes_relative_path(path) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

オーディオスレッドのメインループ内で同期的なファイル I/O (loader.load_bytes_relative_path(path)) を実行しています。ディスクアクセスが遅い環境では、この処理がオーディオスレッド全体をブロックし、BGM や他の SE の再生に遅延や音切れ(スタッター)を引き起こすリスクがあります。パフォーマンスと安定性の向上のため、アセットのプリロードや、読み込み処理を別スレッドで行うなどの非同期化を検討してください。

Comment on lines 200 to 205
Ok(guard) => {
if let Some(frame) = guard.as_ref() {
return frame.clone();
let mut f = frame.clone();
f.audio_cues.clear();
return f;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

フレームの再利用パスにおいて、毎回 clone() した後に clear() を行っていますが、これでは再利用のたびに不要なクローンとクリアが繰り返されます。元の last_frame 自体を一度 clear() すれば、それ以降の再利用では無駄な処理を省けます。guard.as_mut() を使用してソース側の audio_cues をクリアするように変更することで、パフォーマンスを向上させることができます。

            Ok(mut guard) => {
                if let Some(frame) = guard.as_mut() {
                    frame.audio_cues.clear();
                    return frame.clone();
                }
            }

@FRICK-ELDY FRICK-ELDY merged commit af1670d into main May 2, 2026
@FRICK-ELDY FRICK-ELDY deleted the feat/client-audio-via-zenoh-frame branch May 2, 2026 06:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant