Commit Graph

298 Commits

Author SHA1 Message Date
Alex P aa0fe18b4a Merge branch 'dev' into feat/audio-support
Integrate latest dev branch changes including:
- HID RPC handshake improvements
- Video sleep mode functionality
- IPv6 address sorting fixes
- OTA update flow improvements
- Video stream lifecycle management

All audio functionality preserved and tested.
2025-11-24 23:30:49 +02:00
Alex P 9d86b02e66 Integrate libspeexdsp for high-quality audio resampling
Replace ALSA plugin layer resampling with libspeexdsp for improved audio
quality and reliability. This implementation uses direct hardware access
(hw:) instead of ALSA plugins (plughw:) and handles sample rate conversion
with SpeexDSP's high-quality sinc-based resampler.

Key changes:
- Add libspeexdsp 1.2.1 with ARM NEON optimizations to build dependencies
- Switch from plughw: to hw: device access for lower latency
- Implement conditional resampling (only when hardware rate ≠ 48kHz)
- Use SPEEX_RESAMPLER_QUALITY_DESKTOP for high-quality interpolation
- Add automatic audio dependency building in dev_deploy.sh

Quality improvements:
- Fix race condition in resampler cleanup with mutex protection
- Fix memory leak on resampler re-initialization
- Add buffer overflow validation (3840 frame limit for 192kHz)
- Improve error logging for resampling, encoding, and ALSA configuration
- Simplify code structure while maintaining all functionality

Technical details:
- Hardware negotiates actual sample rate (e.g., HDMI may vary)
- SpeexDSP converts hardware rate → 48kHz for Opus encoding
- USB Audio Gadget hardcoded to 48kHz (no resampling overhead)
- Static buffer allocation for zero allocation in hot path
- WebRTC requires 48kHz RTP clock rate per RFC 7587
2025-11-21 16:29:02 +02:00
Aveline 2175e5f6b6 fix: hidRPC handshake packet should be only sent once (#969) 2025-11-21 13:31:13 +01:00
Alex P 2040db6094 Fix USB Audio Gadget sample rate constraints
USB Audio Gadget (hw:1,0) hardware only supports 48kHz for both capture
and playback due to configfs p_srate/c_srate being hardcoded. This commit
ensures both audio paths respect this hardware limitation:

- Output path: Force 48kHz when using hw:1,0, allow configurable rates for HDMI
- Input path: Always use 48kHz regardless of UI configuration
- Calculate frame size dynamically based on actual sample rate used

Also removes redundant comments that don't add debugging or maintainability value.
2025-11-21 01:56:56 +02:00
Alex P 1dfb4ab77f Make audio sample rate user-configurable
- Add sample rate dropdown in UI with Opus-supported rates (8k/12k/16k/24k/48kHz)
- Add sampleRate parameter to setAudioConfig RPC handler
- Validate sample rate is one of the 5 Opus-compatible values
- Configuration takes effect on next audio restart (Apply button)
2025-11-21 01:38:00 +02:00
Alex P fba4eabf3b Merge branch 'dev' into feat/audio-support
Integrated latest dev branch changes including:
- Native process refactoring with gRPC architecture
- OTA update system refactor with new component-based updates
- Updated build system and dependencies
- UI improvements and bug fixes

Post-merge fixes applied:
- Remove duplicate OTA RPC function declarations (now in ota.go)
- Fix GetDefaultEDID reference to use native.DefaultEDID constant
- Fix IsUpdatePending to use otaState.IsUpdatePending() method
- Add missing OTA RPC handler registrations for new update system

All audio functionality from feat/audio-support preserved.
All dev branch functionality preserved.
2025-11-20 23:47:44 +02:00
Adam Shiervani 3652c4ceea
fix: enhance reboot state management with health check and redirect options (#994) 2025-11-20 18:25:21 +01:00
Adam Shiervani ba8a169ef2
refactor: remove unused state for log download in FailSafeModeOverlay (#993) 2025-11-20 17:48:56 +01:00
Adam Shiervani 661110cdb5
fix: update downgrade navigation parameter (#992) 2025-11-20 17:33:34 +01:00
Adam Shiervani 0a09d9e8bf
feat: add hostname change detection and reboot requirement in network settings (#989) 2025-11-20 16:36:02 +01:00
Adam Shiervani 0952c6abf2
chore: use en by default (#988) 2025-11-20 16:34:02 +01:00
Nitish Agarwal 78cef12c97
fix: mobile viewport cropping on video element (#985) 2025-11-20 13:55:24 +01:00
Alex P 1d570a8cbf Fix critical audio race conditions and improve reliability
- Replace volatile with C11 atomics for proper ARM memory barriers
- Fix race condition in audio source swapping (swap to nil before cleanup)
- Prevent double-close of ALSA handles via atomic ownership claim
- Add exponential backoff with 10-retry circuit breaker to prevent infinite loops
- Improve error propagation to report dual failures
- Add defensive null checks for concurrent access safety
- Simplify UI error handling with helper functions
- Fix TypeScript compilation error in packet loss dropdown
2025-11-19 17:19:46 +02:00
Aveline 752fb55799
refactor: OTA (#912)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Adam Shiervani <adam.shiervani@gmail.com>
2025-11-19 15:20:59 +01:00
Alex P 8d69780061 Update audio source switch notification to indicate 30-60s delay
The HDMI audio device can take 30-60 seconds to initialize due to
TC358743 hardware characteristics. Updated success notification in
all languages to inform users that audio will start shortly.
2025-11-19 14:23:26 +02:00
Alex P ee23e3bf22 Refactor audio subsystem for improved maintainability
Changes:
- Consolidate duplicate stop logic into helper functions
- Fix RPC getAudioConfig to return actual runtime values instead of
  inconsistent defaults (bitrate was returning 128 vs actual 192)
- Improve setAudioTrack mutex handling to eliminate nested locking
- Simplify ALSA error retry logic by reorganizing conditional branches
- Split CGO Connect() into separate input/output methods for clarity
- Use map lookup for sample rate validation instead of long if-chain
- Add inline comments documenting validation steps

All changes preserve existing functionality while reducing code
duplication and improving readability. Tested with both HDMI and
USB audio sources.
2025-11-19 13:42:51 +02:00
Alex P 0168fcbdbd Make config.EdidString the single source of truth for EDID
- Set DefaultEDID in config defaults instead of empty string
- Pass config EDID to Native.Start() to fix initialization race condition
- Update DefaultEDID to MacBook-compatible value (2ch, 48kHz, 16/20/24-bit)
- Add getDefaultEDID RPC endpoint for UI to fetch backend constant
- Update UI to dynamically fetch default EDID instead of hardcoding
- Remove all EDID fallback logic now that config always has a value
- Simplify rpcGetEDID to return config value directly

This ensures the configured EDID is used from startup and eliminates
sync issues between backend constant, config, and UI.
2025-11-19 11:08:32 +02:00
Alex P 0022599b03 Fix audio channel separation and improve quality defaults
- Separate capture_channels (stereo HDMI) from playback_channels (mono mic)
  to prevent initialization conflicts that were breaking stereo output
- Optimize defaults for LAN use: 192kbps bitrate, complexity 8, 0% packet
  loss compensation, DTX disabled (eliminates static and improves clarity)
- Add comprehensive race condition protection in C audio layer with handle
  validity checks and mutex-protected cleanup operations
- Enable USB audio volume control and configure microphone as mono
- Add centralized AUDIO_DEFAULTS constant in UI with localized labels
- Add missing time import to fix compilation

This resolves audio quality issues and crash scenarios when switching
between HDMI and USB audio sources.
2025-11-18 13:38:06 +02:00
Marc Brooks 7f930e01b3
Add missing translations for new connection stats 2025-11-17 20:11:33 -06:00
Marc Brooks cbba7f255a
Removed unused translations. 2025-11-17 20:11:33 -06:00
Marc Brooks ba831dc682
Ran npm run i18n to sort the message strings. 2025-11-17 20:11:32 -06:00
Alex P 9c57fe86c4 Change: make sample rate read-only and auto-detected
The sample rate cannot be configured by users - it's determined by the audio
source (HDMI device or USB gadget client). The previous UI gave the false
impression that users could select a sample rate, but the value was always
overridden by hardware detection.

Changes:
- Convert sample rate UI from dropdown to read-only display
- Show "(auto-detected from source)" label next to the value
- Remove sampleRate parameter from setAudioConfig RPC
- Update translations to clarify auto-detection
- Backend sample rate validation remains for backwards compatibility

The C code now automatically detects and adapts to whatever rate the hardware
supports, creating the Opus encoder/decoder with matching parameters to
eliminate pitch/speed distortion.
2025-11-18 00:53:15 +02:00
Alex P 11dadebb93 Fix: improve EDID compatibility and add audio configuration options
- Update default EDID with registered manufacturer ID (Dell) and proper 24-inch display dimensions (52x32cm) for better macOS/OS compatibility
- Add configurable sample rate (32/44.1/48/96 kHz) to support different HDMI audio sources
- Add packet loss compensation percentage control for FEC overhead tuning
- Fix config migration to ensure new audio parameters get defaults for existing configs
- Update all language translations for new audio settings
2025-11-18 00:53:15 +02:00
Alex P 9f0d9c4689 Fix: skip redundant USB gadget reconfigurations to prevent HID disruption
- Add Devices.Equals() method to compare USB device configurations
- Add GetGadgetDevices() to retrieve current device state
- Skip gadget reconfiguration when device state is unchanged
- Remove 6 unused audio translation keys from all language files
2025-11-17 22:48:02 +02:00
Alex P 0fe9cab988 Remove unused audio_settings_input translations 2025-11-17 22:48:02 +02:00
Alex 5b5fc40a08 Merge branch 'dev' into feat/audio-support 2025-11-17 22:19:44 +02:00
Alex P 922a7158e7 Add runtime configurable audio parameters with UI controls
- Add config fields for bitrate, complexity, DTX, FEC, buffer periods
- Add RPC methods for get/set audio config and restart
- Add UI settings page with controls for all audio parameters
- Add Apply Settings button to restart audio with new config
- Add config migration for backwards compatibility
- Add translations for all 9 languages
- Clean up redundant comments and optimize log levels
2025-11-17 21:51:08 +02:00
Alex P e79c6f730e Add audio output source switching and improve shutdown handling
- Add HDMI/USB audio source selection in settings UI
- Add stop flags for graceful audio shutdown
- Use immediate PCM drop instead of drain for faster switching
- Add HDMI connection refresh RPC method
- Add GetDefaultEDID helper method
2025-11-17 20:45:34 +02:00
Nitish Agarwal d49e2680d0
fix: show HDMI overlays in fullscreen mode (#974) 2025-11-17 14:28:28 +01:00
Nitish Agarwal e0b1d5fee3 fix: show HDMI overlays in fullscreen mode (#974) 2025-11-17 14:28:28 +01:00
Nitish Agarwal e293edb069
fix: normalize Unicode characters in paste modal for proper detection (#976) 2025-11-17 10:15:03 +01:00
Nitish Agarwal cedd086602 fix: normalize Unicode characters in paste modal for proper detection (#976) 2025-11-17 10:15:03 +01:00
Alex P 98d20d4ffa Merge branch 'dev' into feat/audio-support 2025-11-11 21:40:29 +02:00
Aveline 5fb4c629dd
feat: failsafe mode (#952)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Adam Shiervani <adam.shiervani@gmail.com>
Co-authored-by: Marc Brooks <IDisposable@gmail.com>
2025-11-11 13:13:42 +01:00
Aveline cf629bed46
feat: add remote IP address to connection stats sidebar (#944) 2025-11-11 12:00:37 +01:00
Marc Brooks 31ea366e51
chore: upgrade UI packages (except vite) (#954) 2025-11-10 14:53:18 +01:00
Marc Brooks 7f2dcc84b4
fix: don't reload page if we didn't attempt an upgrade. (#955) 2025-11-10 12:58:57 +01:00
Adam Shiervani c34440b43f refactor: fix infinite useEffect 2025-11-10 09:43:10 +01:00
Alex P f20fac7dd6 fix: improve microphone handling and cleanup
- Use mono audio instead of stereo for microphone input
- Add cleanup to stop audio track on component unmount
- Explicitly set AudioTrack to nil when creation fails
2025-11-09 13:39:38 +02:00
Alex P f3fc4f4669 fix: improve microphone reliability and auto-enable behavior
- Prevent concurrent getUserMedia requests to fix toggle flakiness
- Add automatic track recovery when microphone track ends unexpectedly
- Fix auto-enable to only trigger on session start, not when toggling setting
- Ensure backend RPC is sent when auto-enable triggers
- Properly clean up old tracks before requesting new ones
2025-11-07 14:20:59 +02:00
Adam Shiervani 5f15d8b2f6
refactor: More robust handling of jsonrpc calls (#915)
Co-authored-by: Marc Brooks <IDisposable@gmail.com>
2025-11-06 11:12:19 +01:00
Aveline 28919bf37c
fix: await sleep needs to be called inside async function (#946) 2025-11-05 13:25:13 -06:00
Marc Brooks 4090592112
chore: add delay before forced page-reload (#916) 2025-11-04 15:12:03 +01:00
Alex P c95ee9eadf feat: add visual feedback for auto-enable microphone toggle
Added success notifications when toggling auto-enable microphone setting.
Includes translations for all supported languages.
2025-11-04 11:17:29 +02:00
Alex P 6a60de519c feat: persist audio preferences to backend config
- Add AudioInputAutoEnable and AudioOutputEnabled fields to backend config
- Implement RPC methods for get/set audio input auto-enable preference
- Load audio output enabled state from config on startup
- Make manual microphone toggle call backend to enable audio pipeline
- Auto-enable preference now persists across incognito sessions
- Reset microphone state to off when reaching login pages
- Fix issue where manual mic toggle required auto-enable to be on
2025-11-04 08:52:27 +02:00
Alex P e6e9c6bb02 feat: add microphone auto-enable setting with session-based opt-in
Implement session-based microphone control with optional auto-enable:
- Microphone disabled by default, only requests permission when enabled
- Added persistent "Auto-enable Microphone" setting in audio settings
- Setting syncs to backend and works across browsers/devices
- Auto-enable respects secure context (HTTPS/localhost only)
- Refactored secure context check into reusable utility function
- Removed unused audioInputEnabled store properties
2025-11-03 22:09:39 +02:00
Adam Shiervani 9127bd22d9 feat: enhance audio settings UI and localization
Added new audio-related UI components and improved localization for multiple languages. The SettingsItem component now supports badge links and variants, enhancing the user experience. Updated the AudioPopover to include quick audio controls for speakers and microphone, with descriptions and HTTPS-only warnings where applicable.
2025-11-03 13:55:57 +01:00
Alex P f40f5a7b39 temp: disable audio source selection while HDMI audio issues are diagnosed
Temporarily remove the ability to switch between HDMI and USB audio
output sources. The application now uses USB audio (hw:1,0) exclusively
until HDMI audio capture issues are resolved.

Changes:
- Remove AudioOutputSource config field
- Remove audio source switching logic and UI
- Hardcode USB audio output device
- Remove related RPC methods
2025-11-03 10:49:35 +02:00
dependabot[bot] 10c4c959a8
build(deps): bump react-router from 7.9.4 to 7.9.5 in /ui (#931)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-11-02 14:27:14 +01:00
dependabot[bot] 69b7682002
build(deps-dev): bump @eslint/compat from 1.4.0 to 1.4.1 in /ui (#924)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-11-02 14:27:03 +01:00