-
Notifications
You must be signed in to change notification settings - Fork 263
JetKVM Advanced, CGO-based 2-way Audio Support #718
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
pennycoders
wants to merge
442
commits into
jetkvm:dev
Choose a base branch
from
pennycoders:feat/audio-support
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+4,328
−352
Open
Changes from 250 commits
Commits
Show all changes
442 commits
Select commit
Hold shift + click to select a range
260714c
Cleanup: Simplify Makefile by exporting all needed env vars at the top
pennycoders c70440f
Merge branch 'dev' into feat/audio-support
pennycoders a8b0a33
[WIP] Cleanup / Refinement: PR Review
pennycoders 154fb5c
[WIP] Cleanpup: Remove audio input quality settings to reduce complexity
pennycoders 7b3a8cc
Fix: indentation
pennycoders 365dc4a
[WIP] Cleanpup: Remove audio input quality settings to reduce complexity
pennycoders 8e54e26
[WIP] Cleanpup: Remove audio input quality settings to reduce complexity
pennycoders 7c4f884
[WIP] Fix: add commented code back
pennycoders 97b2fe0
[WIP] Optimizations: Optimize audio system
pennycoders 48c62c5
Fix: pcm_snd_wait won't work when device is busy
pennycoders aa8a5fa
[WIP] Simplification: PR Simplification
pennycoders 1fca01c
[WIP] Cleanup: remove unnecessary complexity
pennycoders 1d27509
[WIP] Cleanup: function naming
pennycoders 53b5a0a
[WIP] Maintainability: Add debug / trace logs to make it easy to debu…
pennycoders 21d7c87
[WIP] Add debug logging throughout the audio system
pennycoders bbeeaf2
[WIP] Maintainability Improvement: Add debug logging throughout the a…
pennycoders 410f10f
[WIP] Maintainability Improvement: Add debug logging throughout the a…
pennycoders 26ac27f
[WIP] Cleanup: removed redundant code
pennycoders d810f06
[WIP] Cleanup: removed redundant code
pennycoders 717d846
Cleanup: removed redundant code, comments, etc.
pennycoders 6d2b8e5
Cleanup: removed redundant code, comments, etc.
pennycoders ab6a918
Cleanup, Optimizations: Small aaudio optimizations
pennycoders 7615b5c
Cleanup, Optimizations: Small aaudio optimizations
pennycoders fe19379
Cleanup, Optimizations: Small aaudio optimizations
pennycoders b03a9f1
Fix: remove misplaced const
pennycoders 53e8422
Cleanup: removed redundant code
pennycoders 755e1ce
Cleanup: removed redundant code
pennycoders b973356
Consistency: keep if block multi-line
pennycoders c6951fc
PR Review Optimization: As recommended, use ternary operators instead…
pennycoders bf50669
perf(audio): add ARM NEON SIMD optimizations for audio processing
pennycoders b9ae450
PR Cleanup: reset .golangci.yml to its original state
pennycoders 7dfc9dc
Merge branch 'dev' into feat/audio-support
pennycoders ce6e130
[WIP] Cleanup: PR cleanup
pennycoders c7dd1da
[WIP] Cleanup: PR Cleanup
pennycoders c642881
[WIP] Cleanup: PR Cleanup
pennycoders e944df8
[WIP] Cleanup: PR Cleanup
pennycoders fa0626d
[WIP] Cleanup: PR Cleanup
pennycoders 41bb28e
[WIP] Cleanup: PR Cleanup
pennycoders e5357a6
[WIP] Cleanup: PR Cleanup
pennycoders 8c87af8
[WIP] Cleanup: PR cleanup - restore commented logs
pennycoders 60076fb
[WIP] CLeanup: Remove unused or redundant code or comments
pennycoders a079faa
Fix: make sure audio output enable / disable doesn't need a refresh i…
pennycoders 90fbfb6
[WIP] Improvements: Improve audio resume mechanism after Hardware Set…
pennycoders 04ae11e
[WIP] Improvements: Improve audio resume mechanism after Hardware Set…
pennycoders 2194666
Improvement: improve audio input restauration mechanism
pennycoders 63eb58e
[WIP] Improvements, Bugfixes: Improve audio experience when running i…
pennycoders 6db4a93
[WIP] Improvements, Bugfixes: Improve audio experience when running i…
pennycoders cd5d3ed
[WIP] Improvements, Bugfixes: Improve audio experience when running i…
pennycoders b33d681
[WIP] Improvements, Bugfixes: Improve audio experience when running i…
pennycoders e6a6a18
[WIP] Improvements, Bugfixes: Improve audio experience when running i…
pennycoders 63a6a4a
Merge branch 'dev' into feat/audio-support
pennycoders c8401cc
[WIP] Updates: simplify audio system
pennycoders 36b8f74
[WIP] Updates: simplify audio system
pennycoders d015542
[WIP] Updates: simplify audio system
pennycoders 0639982
[WIP] Updates: simplify audio system
pennycoders 4afaf60
[WIP] Updates: simplify audio system
pennycoders 918cdba
Updates: adjust gain to avoid audio artifacts
pennycoders f891f14
[WIP] Updates: simplify audio system
pennycoders 5d24eba
[WIP] Fix: crackling sound when seeking forwars
pennycoders a068587
[WIP] Fix: crackling sound when seeking forwars
pennycoders 11830e1
[WIP] Fix: crackling sound when seeking forward after migrating to HD…
pennycoders 186f3cf
[WIP] Cleanup: cleanup audio code after HDMI switch
pennycoders 51a8ed9
Cleanup: remove silence detection
pennycoders 1bb036a
Merge branch 'dev' into feat/audio-support
pennycoders c42432b
[WIP] Updates: update build flows to work with the CGO jetkvm_native
pennycoders 7fc3637
Updates: integrate all dev branch changes
pennycoders 4e5523d
Merge branch 'dev' into feat/audio-support
pennycoders b1b64fc
[WIP] Updates: use native C binaries for audio
pennycoders bf943cc
[WIP] Updates: reduce PR complexity
pennycoders 78a9e6d
[WIP] Updates: reduce PR complexity
pennycoders 81134b9
[WIP] Updates: reduce PR complexity
pennycoders c2d343b
[WIP] Updates: reduce PR complexity
pennycoders f5ab131
[WIP] Updates: reduce PR complexity
pennycoders 2aa07e3
[WIP] Updates: reduce PR complexity
pennycoders 78c3dc3
Refactor: Simplify / rewrite Audio
pennycoders 8bd3706
fix: Address linting errors in audio code
pennycoders e0bdbdd
fix: Replace 'any' with proper React.ChangeEvent type in AudioPopover
pennycoders 639eecb
fix: Add noise gate to prevent amplifying silence artifacts
pennycoders 3b609d2
refactor: Simplify audio implementation
pennycoders 6728c49
feat: Optimize audio quality and default to USB audio
pennycoders dcc0851
[WIP] Updates: support in-process mode
pennycoders aa0b487
[WIP] Updates: support in-process mode
pennycoders 24ca56b
[WIP] Updates: support in-process mode
pennycoders 2349f60
[WIP] Updates: support in-process mode
pennycoders d93253c
[WIP] Updates: support in-process mode
pennycoders d848948
[WIP] Updates: support in-process mode
pennycoders 1caf57f
Cleanup: PR Comments
pennycoders eaaada8
Merge branch 'feat/dual-audio-mode' into feat/audio-support
pennycoders 8caa5fc
refactor: Remove subprocess audio infrastructure, use CGO-only
pennycoders 7442bdc
Cleanup: reduce drift from dev
pennycoders 558512a
Merge branch 'dev' into feat/audio-support
pennycoders 7ad72de
Merge branch 'dev' into feat/audio-support
pennycoders 34bfa6f
Merge branch 'dev' into feat/audio-support
pennycoders 8b7fcb3
Merge branch 'dev' into feat/audio-support
IDisposable bcaa04f
Merge dev into feat/audio-support
pennycoders 3b849cc
fix: move ipcMsgTypeOpus constant to source.go for cross-platform builds
pennycoders a61d2c5
feat: add proper translations for audio features across all languages
pennycoders c55a4e2
fix: add AudioOutputSource field to Config struct
pennycoders b092ea1
fix: use translation key for audio button in ActionBar
pennycoders a3ed215
docs: document JetKVM ARMv7 architecture and lint requirements
pennycoders c42caf1
feat: add translations and fix audio settings page
pennycoders f528902
fix: verify audio source change and show accurate feedback
pennycoders c3c34c6
fix: add stub implementation for CGO audio on non-ARM platforms
pennycoders 4e6ae02
chore: revert golangci-lint config and remove audio stub
pennycoders 7f29ff0
Fix: app not loading via HTTP
pennycoders df87d9f
fix: remove continuous sleep mode check to prevent audio interference
pennycoders bff2aba
Merge branch 'dev' into feat/audio-support
pennycoders e2bf5d4
Merge branch 'dev' into feat/audio-support
pennycoders c5ec1da
fix: enable audio playback via manual start stream button
pennycoders ca9fa32
fix: track audio autoplay status separately to handle Safari blocking…
pennycoders 2e40a04
fix: prevent race condition in audio output source switching by readi…
pennycoders df33207
Updates: bump Makefile VERSION to 0.4.9
pennycoders e9186e3
Updates: revert VERSION to 0.4.8
pennycoders 7635b97
fix: use atomic.Bool for audio source to prevent mutex contention dur…
pennycoders fbb52e7
fix: wait for audio relay goroutine to exit before disconnecting source
pennycoders 65975a1
Merge branch 'dev' into feat/audio-support
pennycoders da5ca6b
Merge branch 'dev' into feat/audio-support
pennycoders 6553142
fix: update default EDID to enable audio support
pennycoders f40f5a7
temp: disable audio source selection while HDMI audio issues are diag…
pennycoders 2514c56
feat: add audio dependencies to Docker build context
adamshiervani 9127bd2
feat: enhance audio settings UI and localization
adamshiervani e6e9c6b
feat: add microphone auto-enable setting with session-based opt-in
pennycoders 6a60de5
feat: persist audio preferences to backend config
pennycoders e26e962
fix: handle audio track recreation to prevent microphone failures
pennycoders c95ee9e
feat: add visual feedback for auto-enable microphone toggle
pennycoders f3fc4f4
fix: improve microphone reliability and auto-enable behavior
pennycoders af0e044
refactor: use atomic.Pointer for thread-safe inputSource access
pennycoders f20fac7
fix: improve microphone handling and cleanup
pennycoders c34440b
refactor: fix infinite useEffect
adamshiervani 522f6cf
Revert "refactor: use atomic.Pointer for thread-safe inputSource access"
pennycoders 3261efa
fix: prevent audio disconnect from blocking new WebRTC sessions
pennycoders 82977ab
Enhancement: Make the code more DRY
pennycoders 0514a70
Enhancement: Make the code more DRY
pennycoders 0e63e6d
Updates: add logging on error, revert Makefile lint targets
pennycoders 98d20d4
Merge branch 'dev' into feat/audio-support
pennycoders 22a16c7
Fix: coredump issue
pennycoders abe61c8
Fixes / Updates: Update outside mutex comment, move outputSource, out…
pennycoders 33ee474
Fix: prevent concurrent Opus decoder access during session transfers
pennycoders d3a3846
feat: wait for channel to open before triggering initial state update…
adamshiervani 31903c4
Fix: extend audio mutex to prevent concurrent initialization crashes
pennycoders cedd086
fix: normalize Unicode characters in paste modal for proper detection…
nitishagar 400b347
Fix: add stub implementations for non-ARM platforms to fix lint
pennycoders 17f5241
Fix: increase ALSA buffer size to reduce audio crackling
pennycoders e0b1d5f
fix: show HDMI overlays in fullscreen mode (#974)
nitishagar 9e69a0c
Fix: set EDID before video init to ensure audio capability detection
pennycoders e79c6f7
Add audio output source switching and improve shutdown handling
pennycoders 922a715
Add runtime configurable audio parameters with UI controls
pennycoders 5b5fc40
Merge branch 'dev' into feat/audio-support
pennycoders 0fe9cab
Remove unused audio_settings_input translations
pennycoders 1e22e00
Auto-switch audio output to HDMI when USB audio emulation is disabled
pennycoders 9371868
Fix: increase Opus buffer size to 1500 bytes and add bounds check
pennycoders 9f0d9c4
Fix: skip redundant USB gadget reconfigurations to prevent HID disrup…
pennycoders df76cd0
Fix: reopen HID files on USB state transitions to prevent stale handles
pennycoders 11dadeb
Fix: improve EDID compatibility and add audio configuration options
pennycoders 236291a
Fix: eliminate audio warping by auto-adapting to actual device sample…
pennycoders 9c57fe8
Change: make sample rate read-only and auto-detected
pennycoders 3f141c8
Add log files and development artifacts to gitignore
pennycoders 94cab8b
Fix: prevent race condition crash in audio playback using pthread mut…
pennycoders 2b276e1
Remove unused update_opus_encoder_params function
pennycoders a6c5e46
Align inline comments in Config struct
pennycoders d7dc8c2
Update audio.c header comment to reflect variable sample rate
pennycoders 6a7f9e9
Fix race condition in setAudioTrack by using single critical section
pennycoders 437a63d
Add bounds check for Opus packets in Go layer
pennycoders a305217
Merge branch 'dev' into feat/audio-support
pennycoders 051950f
Fix critical deadlock when switching audio sources
pennycoders a6b7ac5
Eliminate hang completely by making ALSA interruption immediate
pennycoders b15cbc5
Clean up redundant comments for maintainability
pennycoders 12d7ac6
Fix USB HID errors during browser refresh
pennycoders cd2d4d7
Remove additional redundant comments
pennycoders 2e84354
Fix shutdown log level and order per PR review
pennycoders a1a2b9d
Remove unnecessary assignment when USB devices unchanged
pennycoders ba831dc
Ran npm run i18n to sort the message strings.
IDisposable cbba7f2
Removed unused translations.
IDisposable 7f930e0
Add missing translations for new connection stats
IDisposable 9b2500b
Extract alsaDevice configuration to helper
IDisposable 8c7764a
Ensure the stopAudio() always runs
IDisposable 1ec9941
Simplify audio management
IDisposable bc2a5f8
Merge pull request #1 from IDisposable/small-tweaks
pennycoders 2f622df
Fix input audio source swap bug
pennycoders 0022599
Fix audio channel separation and improve quality defaults
pennycoders 4783021
Fix USB audio channels and remove redundant synchronization
pennycoders 0e299aa
Deduplicate ALSA error handling and cleanup code
pennycoders befdfc7
Fix type mismatch in ALSA error handler
pennycoders da4c6c7
Use efficient uint8_t for recovery attempt counters
pennycoders c88b98c
Fix critical audio race conditions and align configuration defaults
pennycoders 0168fcb
Make config.EdidString the single source of truth for EDID
pennycoders 0dbf2df
Update default EDID for improved compatibility
pennycoders ee23e3b
Refactor audio subsystem for improved maintainability
pennycoders 7fc90b8
Make audio source switching instant with async initialization
pennycoders 8d69780
Update audio source switch notification to indicate 30-60s delay
pennycoders 1d570a8
Fix critical audio race conditions and improve reliability
pennycoders 3897a61
Fix critical comment inaccuracies in audio code
pennycoders 4160462
Remove inaccurate and redundant comments
pennycoders fe4fb33
Fix misleading comment and incorrect Go terminology
pennycoders fba4eab
Merge branch 'dev' into feat/audio-support
pennycoders a6cbf20
Fix audio capture to force Opus-compatible sample rates
pennycoders edd06e2
Fix UI hanging when toggling audio output enable/disable
pennycoders 3cd5bdd
Make RestartAudioOutput async to prevent RPC hanging
pennycoders 3ed663b
Enable ALSA software resampling for hw: devices
pennycoders 5f7c906
Simplify audio configuration and error handling
pennycoders 4001ef6
Fix silent failures and improve documentation
pennycoders 584b9fe
Fix comment inaccuracies and restore lint targets
pennycoders 1dfb4ab
Make audio sample rate user-configurable
pennycoders 57baa14
Fix frame size calculation for configurable sample rates
pennycoders 2040db6
Fix USB Audio Gadget sample rate constraints
pennycoders 0be9dbc
Enable ALSA rate resampling for configurable audio sample rates
pennycoders ae9cf78
fix(ota): set updating to false when no updates are available (#996)
ym 05446df
fix(network): IPv6 addresses sorting was using wrong references (#997)
ym 2175e5f
fix: hidRPC handshake packet should be only sent once (#969)
ym d0f1b75
fix: stop video stream before enabling sleep mode (#999)
ym 9d86b02
Integrate libspeexdsp for high-quality audio resampling
pennycoders ac568c7
Fix HDMI hotplug crash by releasing mutex during blocking ALSA I/O
pennycoders 7296638
Update default EDID to JetKVM 1920x1080@60Hz with audio support
pennycoders 3692cda
Fix reversed stereo channels by querying ALSA channel map
pennycoders 6989782
Remove redundant ALSA plugins (plug, rate) from build
pennycoders 9e6ffb3
Add ARM NEON soft-clipper to prevent clipping on sharp transients
pennycoders 2ef6cb2
Improve soft-clipper with validation, error handling, and overflow pr…
pennycoders 60fcd91
Update default EDID to 1920x1080@60Hz
pennycoders fb6dbe5
Disable assertions in ALSA static library build
pennycoders 5ed7008
Add NULL checks before snd_pcm_close() calls
pennycoders d4bd9db
Improve audio capture reliability and remove soft-clipping
pennycoders 818a2ca
Update DefaultEDID to force 60Hz video output
pennycoders db2dc88
Fix HDMI audio sample rate detection for non-48kHz sources
pennycoders 81ff87f
Address code review feedback and optimize stereo channel swapping
pennycoders 0f8b368
Fix critical error handling and race conditions in audio system
pennycoders dc0ccf9
Fix HIGH priority issues in audio system
pennycoders 8debd07
Remove redundant comments and fix time import
pennycoders cc7e608
Add automatic HDMI sample rate change detection
pennycoders aa0fe18
Merge branch 'dev' into feat/audio-support
pennycoders 7580d00
Fix HDMI hotplug video restart after sleep mode changes
pennycoders f324496
Merge branch 'dev' into feat/audio-support
pennycoders 3d1c2a1
Remove dead code and redundant checks in audio implementation
pennycoders d42024b
Fix audio quality and cleanup issues in audio implementation
pennycoders 55bf170
Add memory barrier and improve error logging in audio implementation
pennycoders aeb6881
Fix misleading comment about decoder sample rate
pennycoders fe940cd
Fix buffer aliasing and cleanup unused fields in audio
pennycoders 4cadf38
Remove unused sample rate and frame size parameters
pennycoders 82562b7
Remove unnecessary NULL checks in configure_alsa_device
pennycoders 9fe46d5
Skip TC358743 sample rate detection for USB audio
pennycoders 89c0b28
Merge remote-tracking branch 'origin/dev' into feat/audio-support
pennycoders 594efa6
Change default EDID display name to JetKVM
pennycoders 5d43b37
Update default EDID with HDMI audio support
pennycoders 820efe5
Update default EDID to compliant 1.3 with HDMI audio support
pennycoders 17471f0
Merge remote-tracking branch 'origin/dev' into feat/audio-support
pennycoders 0113ddc
Consolidate lint targets and add lint-fix for comprehensive auto-fix
pennycoders 8417531
fix(audio): use Center Front channel position for mono USB microphone
pennycoders f39a838
fix(audio): filter TC358743 I2S clock-stop glitches
pennycoders 9aa2c03
fix(build): run install_audio_deps.sh in Dockerfile.build
pennycoders c91bcfc
Merge branch 'dev' into feat/audio-support
pennycoders c52924b
Merge branch 'dev' into feat/audio-support
IDisposable File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| #!/bin/bash | ||
| # .devcontainer/install_audio_deps.sh | ||
| # Build ALSA and Opus static libs for ARM in /opt/jetkvm-audio-libs | ||
| set -e | ||
|
|
||
| # Sudo wrapper function | ||
| function use_sudo() { | ||
| if [ "$UID" -eq 0 ] || [ -z "$(which sudo 2>/dev/null)" ]; then | ||
| "$@" | ||
| else | ||
| sudo -E "$@" | ||
| fi | ||
| } | ||
|
|
||
| # Accept version parameters or use defaults | ||
| ALSA_VERSION="${1:-1.2.14}" | ||
| OPUS_VERSION="${2:-1.5.2}" | ||
| SPEEXDSP_VERSION="${3:-1.2.1}" | ||
|
|
||
| AUDIO_LIBS_DIR="/opt/jetkvm-audio-libs" | ||
| BUILDKIT_PATH="/opt/jetkvm-native-buildkit" | ||
| BUILDKIT_FLAVOR="arm-rockchip830-linux-uclibcgnueabihf" | ||
| CROSS_PREFIX="$BUILDKIT_PATH/bin/$BUILDKIT_FLAVOR" | ||
|
|
||
| # Create directory with proper permissions | ||
| use_sudo mkdir -p "$AUDIO_LIBS_DIR" | ||
| use_sudo chmod 777 "$AUDIO_LIBS_DIR" | ||
| cd "$AUDIO_LIBS_DIR" | ||
|
|
||
| # Download sources | ||
| [ -f alsa-lib-${ALSA_VERSION}.tar.bz2 ] || wget -N https://www.alsa-project.org/files/pub/lib/alsa-lib-${ALSA_VERSION}.tar.bz2 | ||
| [ -f opus-${OPUS_VERSION}.tar.gz ] || wget -N https://downloads.xiph.org/releases/opus/opus-${OPUS_VERSION}.tar.gz | ||
| [ -f speexdsp-${SPEEXDSP_VERSION}.tar.gz ] || wget -N https://ftp.osuosl.org/pub/xiph/releases/speex/speexdsp-${SPEEXDSP_VERSION}.tar.gz | ||
|
|
||
| # Extract | ||
| [ -d alsa-lib-${ALSA_VERSION} ] || tar xf alsa-lib-${ALSA_VERSION}.tar.bz2 | ||
| [ -d opus-${OPUS_VERSION} ] || tar xf opus-${OPUS_VERSION}.tar.gz | ||
| [ -d speexdsp-${SPEEXDSP_VERSION} ] || tar xf speexdsp-${SPEEXDSP_VERSION}.tar.gz | ||
|
|
||
| # ARM Cortex-A7 optimization flags with NEON support | ||
| OPTIM_CFLAGS="-O2 -mfpu=neon -mtune=cortex-a7 -mfloat-abi=hard -DNDEBUG" | ||
|
|
||
| export CC="${CROSS_PREFIX}-gcc" | ||
| export CFLAGS="$OPTIM_CFLAGS" | ||
| export CXXFLAGS="$OPTIM_CFLAGS" | ||
|
|
||
| # Build ALSA | ||
| cd alsa-lib-${ALSA_VERSION} | ||
| if [ ! -f .built ]; then | ||
| chown -R $(whoami):$(whoami) . | ||
| # Minimal ALSA configuration for direct hw: device access with SpeexDSP resampling | ||
| CFLAGS="$OPTIM_CFLAGS" ./configure --host $BUILDKIT_FLAVOR \ | ||
| --enable-static=yes --enable-shared=no \ | ||
| --with-pcm-plugins=linear,copy \ | ||
| --disable-seq --disable-rawmidi --disable-ucm \ | ||
| --disable-python --disable-old-symbols \ | ||
| --disable-topology --disable-hwdep --disable-mixer \ | ||
| --disable-alisp --disable-aload --disable-resmgr | ||
| make -j$(nproc) | ||
| touch .built | ||
| fi | ||
| cd .. | ||
|
|
||
| # Build Opus | ||
| cd opus-${OPUS_VERSION} | ||
| if [ ! -f .built ]; then | ||
| chown -R $(whoami):$(whoami) . | ||
| CFLAGS="$OPTIM_CFLAGS" ./configure --host $BUILDKIT_FLAVOR --enable-static=yes --enable-shared=no --enable-fixed-point | ||
| make -j$(nproc) | ||
| touch .built | ||
| fi | ||
| cd .. | ||
|
|
||
| # Build SpeexDSP | ||
| cd speexdsp-${SPEEXDSP_VERSION} | ||
| if [ ! -f .built ]; then | ||
| chown -R $(whoami):$(whoami) . | ||
| # NEON-optimized high-quality resampler | ||
| CFLAGS="$OPTIM_CFLAGS" ./configure --host $BUILDKIT_FLAVOR \ | ||
| --enable-static=yes --enable-shared=no \ | ||
| --enable-neon \ | ||
| --disable-examples | ||
| make -j$(nproc) | ||
| touch .built | ||
| fi | ||
| cd .. | ||
|
|
||
| echo "ALSA, Opus, and SpeexDSP built in $AUDIO_LIBS_DIR" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| # JetKVM Copilot Instructions | ||
|
|
||
| ## Architecture Overview | ||
|
|
||
| JetKVM is a high-performance KVM-over-IP solution with **bidirectional architecture**: a Go backend running on ARM hardware and a React/TypeScript frontend served by the device. The system provides real-time video streaming, HID input, virtual media mounting, and **2-way audio support** via WebRTC. | ||
|
|
||
| ### Core Components | ||
|
|
||
| - **Backend**: Go application (`main.go`, `web.go`, `webrtc.go`) handling WebRTC, HTTP APIs, hardware interfaces | ||
| - **Frontend**: React/TypeScript SPA (`ui/src/`) with Vite build system, served as embedded static files | ||
| - **Hardware Layer**: CGO bridge (`internal/native/`) to ARM SoC for video capture, USB gadget, display control | ||
| - **Audio System**: In-process CGO implementation (`internal/audio/`) with ALSA/Opus for USB Audio Gadget streaming | ||
| - **USB Gadget**: Configurable emulation (`internal/usbgadget/`) - keyboard, mouse, mass storage, **audio device** | ||
|
|
||
| ## Development Workflows | ||
|
|
||
| ### Quick Development Commands | ||
| ```bash | ||
| # Full development deployment (most common) | ||
| ./dev_deploy.sh -r <DEVICE_IP> | ||
|
|
||
| # UI-only changes (faster iteration) | ||
| cd ui && ./dev_device.sh <DEVICE_IP> | ||
|
|
||
| # Backend-only changes (skip UI build) | ||
| ./dev_deploy.sh -r <DEVICE_IP> --skip-ui-build | ||
|
|
||
| # Build for release | ||
| make build_release | ||
| ``` | ||
|
|
||
| ### Critical Build Dependencies | ||
| - **Audio libraries**: `make build_audio_deps` builds ALSA and Opus static libs for ARM | ||
| - **Native CGO**: `make build_native` compiles hardware interface layer | ||
| - **Cross-compilation**: ARM7 with buildkit toolchain at `/opt/jetkvm-native-buildkit` | ||
|
|
||
| ### Testing | ||
| ```bash | ||
| # Run Go tests on device | ||
| ./dev_deploy.sh -r <DEVICE_IP> --run-go-tests | ||
|
|
||
| # UI linting | ||
| cd ui && npm run lint | ||
| ``` | ||
|
|
||
| ## Project-Specific Patterns | ||
|
|
||
| ### Configuration Management | ||
| - **Single config file**: `/userdata/kvm_config.json` persisted across updates | ||
| - **Config struct**: `config.go` with JSON tags, atomic operations for thread safety | ||
| - **Migration pattern**: Use `ensureConfigLoaded()` before config access | ||
|
|
||
| ### WebRTC Architecture | ||
| - **Session management**: `webrtc.go` handles peer connections with connection pooling | ||
| - **Media tracks**: Separate video and **stereo audio tracks** in independent MediaStreams | ||
| - **Data channels**: RPC (ordered), HID (unordered), upload, terminal, serial channels | ||
| - **SDP munging**: Frontend modifies SDP for Opus stereo parameters (`OPUS_STEREO_PARAMS`) | ||
|
|
||
| ### Audio Implementation Details | ||
| - **USB Audio Gadget**: UAC1 device presenting as stereo speakers + microphone | ||
| - **Bidirectional streaming**: Output (device→browser) and input (browser→device) | ||
| - **CGO integration**: `internal/audio/cgo_source.go` bridges Go↔C for ALSA operations | ||
| - **Frame-based processing**: 20ms Opus frames (960 samples @ 48kHz) for low latency | ||
|
|
||
| ### Frontend State Management | ||
| - **Zustand stores**: `hooks/stores.ts` - RTC, UI, Settings, Video state with persistence | ||
| - **JSON-RPC communication**: `useJsonRpc` hook for backend API calls | ||
| - **Localization**: Paraglide.js with compile-time validation - all UI strings use `m.key()` pattern | ||
|
|
||
| ### USB Gadget Configuration | ||
| - **Configfs-based**: Dynamic reconfiguration via `/sys/kernel/config/usb_gadget/` | ||
| - **Transaction pattern**: `WithTransaction()` ensures atomic gadget changes | ||
| - **Device composition**: Keyboard + mouse + mass storage + **audio** with individual toggle support | ||
|
|
||
| ## Integration Patterns | ||
|
|
||
| ### Backend API Structure | ||
| - **JSON-RPC over WebSocket**: Primary communication via data channels | ||
| - **HTTP endpoints**: `/api/*` for REST operations, `/static/*` for UI assets | ||
| - **Configuration endpoints**: `rpc*` functions in `jsonrpc.go` with parameter validation | ||
|
|
||
| ### Cross-Component Communication | ||
| - **Video pipeline**: `native.go` → WebRTC track → browser via H.264 streaming | ||
| - **HID input**: Browser → WebRTC data channel → `internal/usbgadget/hid_*.go` → Linux gadget | ||
| - **Audio pipeline**: ALSA capture → Opus encode → WebRTC → browser speakers (and reverse for mic) | ||
| - **Virtual media**: HTTP upload → storage → NBD server → USB mass storage gadget | ||
|
|
||
| ### Error Handling Patterns | ||
| - **Graceful degradation**: Audio/video failures don't crash core functionality | ||
| - **Session isolation**: Per-connection logging with `connectionID` context | ||
| - **Recovery mechanisms**: USB gadget timeouts, audio restart on device changes | ||
|
|
||
| ## Key Files for Common Tasks | ||
|
|
||
| ### Adding new RPC endpoints | ||
| 1. Add handler function in `jsonrpc.go` | ||
| 2. Register in `rpcHandlers` map | ||
| 3. Add frontend hook in `useJsonRpc` | ||
|
|
||
| ### USB device modifications | ||
| - `internal/usbgadget/config.go` - gadget composition and attributes | ||
| - `internal/usbgadget/hid_*.go` - HID device implementations | ||
|
|
||
| ### Audio feature development | ||
| - `audio.go` - high-level audio management and session integration | ||
| - `internal/audio/` - CGO sources, relays, and C audio processing | ||
|
|
||
| ### Frontend feature development | ||
| - `ui/src/routes/` - page components | ||
| - `ui/src/components/` - reusable UI components | ||
| - `ui/localization/messages/en.json` - localizable strings | ||
|
|
||
| --- | ||
|
|
||
| *This codebase uses advanced patterns like CGO, USB gadgets, and real-time media streaming. Focus on understanding the session lifecycle and cross-compilation requirements for effective development.* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.