Commit Graph

282 Commits

Author SHA1 Message Date
Alex P b1b64fc8d2 [WIP] Updates: use native C binaries for audio 2025-10-01 20:13:13 +03:00
Alex P 7fc363789e Updates: integrate all dev branch changes 2025-10-01 15:50:39 +03:00
Alex P c42432b129 [WIP] Updates: update build flows to work with the CGO jetkvm_native 2025-10-01 10:04:42 +03:00
Alex P 1bb036add4 Merge branch 'dev' into feat/audio-support 2025-09-30 20:08:33 +00:00
Alex P 51a8ed958d Cleanup: remove silence detection 2025-09-30 14:32:36 +00:00
Alex P 186f3cfbe0 [WIP] Cleanup: cleanup audio code after HDMI switch 2025-09-30 13:32:56 +00:00
Alex P 11830e1123 [WIP] Fix: crackling sound when seeking forward after migrating to HDMI Audio 2025-09-30 13:14:15 +00:00
Alex P a0685877bc [WIP] Fix: crackling sound when seeking forwars 2025-09-30 13:11:16 +00:00
Alex P 5d24eba58e [WIP] Fix: crackling sound when seeking forwars 2025-09-30 12:58:49 +00:00
Alex P f891f14152 [WIP] Updates: simplify audio system 2025-09-30 12:36:41 +00:00
Alex P 918cdba0b7 Updates: adjust gain to avoid audio artifacts 2025-09-30 12:05:03 +00:00
Alex P 4afaf6023a [WIP] Updates: simplify audio system 2025-09-30 11:41:17 +00:00
Alex P 06399820c4 [WIP] Updates: simplify audio system 2025-09-30 11:03:34 +00:00
Alex P d015542088 [WIP] Updates: simplify audio system 2025-09-30 09:36:19 +00:00
Alex P 36b8f74087 [WIP] Updates: simplify audio system 2025-09-30 09:08:55 +00:00
Alex P c8401cc483 [WIP] Updates: simplify audio system 2025-09-30 09:04:07 +00:00
Aveline 657a177462
feat: jetkvm native in cGo 2025-09-29 14:09:30 +02:00
Alex P e5357a6a11 [WIP] Cleanup: PR Cleanup 2025-09-20 22:57:19 +03:00
Alex P fa0626db0a [WIP] Cleanup: PR Cleanup 2025-09-20 01:14:41 +03:00
Alex P e944df8e82 [WIP] Cleanup: PR Cleanup 2025-09-20 00:57:57 +03:00
Alex P c6428818a6 [WIP] Cleanup: PR Cleanup 2025-09-20 00:54:14 +03:00
Alex P c7dd1da73a [WIP] Cleanup: PR Cleanup 2025-09-20 00:21:09 +03:00
Alex P 7dfc9dc5e9 Merge branch 'dev' into feat/audio-support 2025-09-19 12:41:46 +00:00
Aveline afb146d78c
feat: release keyPress automatically (#796)
* feat: release keyPress automatically

* send keepalive when pressing the key

* remove logging

* clean up logging

* chore: use unreliable channel to send keepalive events

* chore: use ordered unreliable channel for pointer events

* chore: adjust auto release key interval

* chore: update logging for kbdAutoReleaseLock

* chore: update comment for KEEPALIVE_INTERVAL

* fix: should cancelAutorelease when pressed is true

* fix: handshake won't happen if webrtc reconnects

* chore: add trace log for writeWithTimeout

* chore: add timeout for KeypressReport

* chore: use the proper key to send release command

* refactor: simplify HID RPC keyboard input handling and improve key state management

- Updated `handleHidRPCKeyboardInput` to return errors directly instead of keys down state.
- Refactored `rpcKeyboardReport` and `rpcKeypressReport` to return errors instead of states.
- Introduced a queue for managing key down state updates in the `Session` struct to prevent input handling stalls.
- Adjusted the `UpdateKeysDown` method to handle state changes more efficiently.
- Removed unnecessary logging and commented-out code for clarity.

* refactor: enhance keyboard auto-release functionality and key state management

* fix: correct Windows default auto-repeat delay comment from 1ms to 1s

* refactor: send keypress as early as possible

* refactor: replace console.warn with console.info for HID RPC channel events

* refactor: remove unused NewKeypressKeepAliveMessage function from HID RPC

* fix: handle error in key release process and log warnings

* fix: log warning on keypress report failure

* fix: update auto-release keyboard interval to 225

* refactor: enhance keep-alive handling and jitter compensation in HID RPC

- Implemented staleness guard to ignore outdated keep-alive packets.
- Added jitter compensation logic to adjust timer extensions based on packet arrival times.
- Introduced new methods for managing keep-alive state and reset functionality in the Session struct.
- Updated auto-release delay mechanism to use dynamic durations based on keep-alive timing.
- Adjusted keep-alive interval in the UI to improve responsiveness.

* gofmt

* clean up code

* chore: use dynamic duration for scheduleAutoRelease

* Use harcoded timer reset value for now

* fix: prevent nil pointer dereference when stopping timers in Close method

* refactor: remove nil check for kbdAutoReleaseTimers in DelayAutoReleaseWithDuration

* refactor: optimize dependencies in useHidRpc hooks

* refactor: streamline keep-alive timer management in useKeyboard hook

* refactor: clarify comments in useKeyboard hook for resetKeyboardState function

* refactor: reduce keysDownStateQueueSize

* refactor: close and reset keysDownStateQueue in newSession function

* chore: resolve conflicts

* resolve conflicts

---------

Co-authored-by: Adam Shiervani <adam.shiervani@gmail.com>
2025-09-18 13:35:47 +02:00
Aveline 72e3013337
feat: send all paste keystrokes to backend (#789)
* feat: send all paste keystrokes to backend

* feat: cancel paste mode

* wip: send macro using hidRPC channel

* add delay

* feat: allow paste progress to be cancelled

* allow user to override delay

* chore: clear keysDownState

* fix: use currentSession.reportHidRPCKeyboardMacroState

* fix: jsonrpc.go:1142:21: Error return value is not checked (errcheck)

* fix: performance issue of Uint8Array concat

* chore: hide delay option when debugMode isn't enabled

* feat: use clientSide macro if backend doesn't support macros

* fix: update keysDownState handling

* minor issues

* refactor

* fix: send duplicated keyDownState

* chore: add max length for paste text

---------

Co-authored-by: Adam Shiervani <adam.shiervani@gmail.com>
2025-09-18 13:00:57 +02:00
Marc 25b102ac34
fix: ensure that security-key backed SSH keys are supported (#807) 2025-09-17 12:14:45 +02:00
Alex P bf50669e3a perf(audio): add ARM NEON SIMD optimizations for audio processing
Implement SIMD-optimized audio operations using ARM NEON for Cortex-A7 targets
Update Makefile and CI configuration to support NEON compilation flags
Add SIMD implementations for common audio operations including:
- Sample clearing and interleaving
- Volume scaling and format conversion
- Channel manipulation and balance adjustment
- Endianness swapping and prefetching
2025-09-16 18:18:19 +00:00
Marc Brooks cf679978be
fix(timesync): ensure that auto-update waits for time sync (#609)
- Added check to not attempt auto update if time sync is needed and not yet successful (delays 30 second to recheck).
- Added resync of time when DHCP or link state changes if online
- Added conditional* fallback from configured* NTP servers to the IP-named NTP servers, and then to the DNS named ones if that fails
- Added conditional* fallback from the configured* HTTP servers to the default DNS named ones.
- Uses the configuration* option for how many queries to run in parallel
- Added known static IPs for time servers (in case DNS resolution isn't up yet)
- Added time.cloudflare.com to fall-back NTP servers
- Added fallback to NTP via hostnames
- Logs the resultant time (and mode)
2025-09-16 15:37:02 +02:00
Alex P c6951fc57e PR Review Optimization: As recommended, use ternary operators instead of if/else for better readability 2025-09-16 16:17:56 +03:00
Alex P b9733566bc Consistency: keep if block multi-line 2025-09-16 16:08:16 +03:00
Alex P 755e1cef28 Cleanup: removed redundant code 2025-09-16 16:03:20 +03:00
Alex P 53e8422ac7 Cleanup: removed redundant code 2025-09-16 16:00:55 +03:00
Alex P b03a9f1171 Fix: remove misplaced const 2025-09-16 15:52:53 +03:00
Alex P fe19379ef1 Cleanup, Optimizations: Small aaudio optimizations 2025-09-16 15:46:55 +03:00
Alex P 7615b5c3ef Cleanup, Optimizations: Small aaudio optimizations 2025-09-16 15:45:03 +03:00
Alex P ab6a918219 Cleanup, Optimizations: Small aaudio optimizations 2025-09-16 15:37:23 +03:00
Alex P 6d2b8e585a Cleanup: removed redundant code, comments, etc. 2025-09-16 15:31:10 +03:00
Alex P 717d84672f Cleanup: removed redundant code, comments, etc. 2025-09-16 15:23:16 +03:00
Alex P d810f06417 [WIP] Cleanup: removed redundant code 2025-09-16 15:17:49 +03:00
Alex P 26ac27f33d [WIP] Cleanup: removed redundant code 2025-09-16 15:14:00 +03:00
Alex P 410f10ff39 [WIP] Maintainability Improvement: Add debug logging throughout the audio system for easy debugging and troubleshooting 2025-09-16 15:05:08 +03:00
Marc Brooks 80a8b9e9e3
feat: Adds IPv6 disabling feature (#803)
* Allow disabling IPv6

Simply ignores any IPv6 addresses in the lease and doesn't offer them to the RPC
Also fixed display issue for IPv6 link local address.
Fixes https://github.com/orgs/jetkvm/projects/7/views/1?pane=issue&itemId=122761546&issue=jetkvm%7Ckvm%7C685

* Don't listen on disabled addresses in mDNS or web server.

* We have to set the IPv4 and IPv6 modes on the server.
2025-09-16 12:44:56 +02:00
Alex P bbeeaf2a00 [WIP] Maintainability Improvement: Add debug logging throughout the audio system for easy debugging and troubleshooting 2025-09-16 11:27:18 +03:00
Alex P 21d7c87fc7 [WIP] Add debug logging throughout the audio system 2025-09-16 11:26:48 +03:00
Alex P 53b5a0a90c [WIP] Maintainability: Add debug / trace logs to make it easy to debug audio input issues 2025-09-16 11:11:18 +03:00
Alex P 1d275099d2 [WIP] Cleanup: function naming 2025-09-16 07:33:34 +00:00
Alex P 1fca01c64d [WIP] Cleanup: remove unnecessary complexity 2025-09-15 23:00:03 +00:00
Alex P aa8a5fa7e7 [WIP] Simplification: PR Simplification 2025-09-16 00:44:26 +03:00
Alex P 48c62c5912 Fix: pcm_snd_wait won't work when device is busy 2025-09-16 00:32:19 +03:00
Alex P 97b2fe0c32 [WIP] Optimizations: Optimize audio system 2025-09-15 21:22:02 +00:00
Alex P 7c4f884704 [WIP] Fix: add commented code back 2025-09-15 12:04:24 +00:00
Alex P 8e54e2650c [WIP] Cleanpup: Remove audio input quality settings to reduce complexity 2025-09-15 12:02:47 +00:00
Alex P 7b3a8ccb95 Fix: indentation 2025-09-15 14:29:02 +03:00
Alex P a8b0a33116 [WIP] Cleanup / Refinement: PR Review 2025-09-14 21:55:31 +00:00
Alex P 260714c27c Cleanup: Simplify Makefile by exporting all needed env vars at the top 2025-09-12 09:47:11 +00:00
Alex P 176e2a450e Fix: add accidentally removed test file back, devcontainer build process on clean devcontainer 2025-09-12 09:10:31 +00:00
Alex P f6a107efd4 Merge branch 'dev' into feat/audio-support 2025-09-12 01:18:46 +03:00
Aveline ea068414dc
feat: validate ssh public key before saving (#794)
* feat: validate ssh public key before saving

* fix: TestValidSSHKeyTypes
2025-09-11 23:32:40 +02:00
Alex P 59b75116f0 Improvement (Maintainability): Make all C code more manageable by moving it to its own dedicated file 2025-09-11 13:27:10 +03:00
Alex P 0c05f087f6 [WIP] Cleanup: Remove hid optimization code, as it is out of scope 2025-09-09 23:31:58 +00:00
Alex P 5781a0a56a Updates: defer the mutex unlock 2025-09-09 22:03:35 +00:00
Alex P e105a352fa [WIP] Updates, Cleanup: use uint64 for non-negative values 2025-09-09 21:54:36 +00:00
Alex P cb3b49fadf Updates: use uint64 since we won't have negative numbers here 2025-09-09 21:37:08 +00:00
Alex P b905570aa7 Cleanup: implement PR Review suggestions 2025-09-09 18:09:19 +00:00
Alex P 7091d7f9cf Fix: Audio Output Enable / Disable 2025-09-09 10:39:47 +00:00
Alex P 9f272de6bb feat(audio): improve socket handling and validation performance
- Add retry logic for socket file removal and listener creation
- Optimize message writing by combining header and data writes
- Move socket paths from temp dir to /var/run
- Refactor OPUS parameter lookup to use map for better readability
- Simplify validation functions for better performance in hotpaths
2025-09-09 10:16:53 +00:00
Alex P cd4121db13 UX Improvement: keep Mic state accross page refreshes 2025-09-09 09:43:39 +00:00
Alex P 85693ce7a2 refactor(audio): optimize performance and simplify code
- Replace mutex locks with atomic operations for counters
- Remove redundant logging calls to reduce overhead
- Simplify error handling and buffer validation
- Add exponential backoff for audio relay stability
- Streamline CGO audio operations for hotpath optimization
2025-09-09 09:12:05 +00:00
Alex P 589379bcd1 [Milestone] Fix: in-flight audio input quality updates 2025-09-09 08:56:24 +00:00
Alex P 76cf1fb706 [Milestone] Improvement: In-flight audio output quality update 2025-09-09 07:44:37 +00:00
Alex P 694af47237 [WIP] Cleanup, Refactor: Reduce PR complexity, common IPC layer 2025-09-09 07:08:32 +00:00
Alex P d9cc9b2867 [WIP] Cleanup: reduce PR complexity 2025-09-09 06:59:55 +00:00
Alex P 69855a4a75 [WIP] Cleanup: reduce PR complexity 2025-09-09 06:52:40 +00:00
Alex P 8ede6afd76 [WIP] Cleanup: PR SImplification 2025-09-09 05:41:20 +00:00
Alex P ab94a87d89 [WIP] Fix: Audio Latency issues: move audio to a dedicated media stream
For more details please see: https://groups.google.com/g/discuss-webrtc/c/ZvAHvkHsb0E
2025-09-09 00:23:15 +00:00
Alex P 29bd256bfd Updates: increase congestion treshold multiplier 2025-09-08 22:58:49 +00:00
Alex P c359ecf7ef [WIP] Change playback latency spikes on Audio Output Quality changes 2025-09-08 22:55:19 +00:00
Alex P e19940a4b0 fix(audio): adjust congestion and CPU thresholds for single-core system
Update congestion threshold multiplier and CPU thresholds to better suit single-core ARM RV1106G3 processor characteristics. Adjust memory thresholds for systems with 200MB total memory.
2025-09-08 22:03:11 +00:00
Alex P 8b46e9931b feat(audio): improve reliability with graceful degradation and async updates
- Implement graceful degradation for congestion handling with configurable thresholds
- Refactor audio relay track updates to be async to prevent deadlocks
- Add timeout-based supervisor stop during quality changes
- Optimize buffer pool configuration and cleanup strategies
2025-09-08 21:47:39 +00:00
Alex P d1c5671842 perf(audio): increase buffer sizes and timeouts for quality change bursts
Significantly increase message pool, channel buffer, and adaptive buffer sizes to better handle quality change bursts. Adjust timeouts and intervals for improved responsiveness.
2025-09-08 21:17:06 +00:00
Alex P 9305ce5dbf refactor(audio): remove redundant config variable assignments
Replace repeated local config variable assignments with direct Config access
to reduce memory allocations and improve code maintainability
2025-09-08 21:04:07 +00:00
Alex P af37c1581b refactor(audio): replace GetConfig() calls with direct Config access
This change replaces all instances of GetConfig() function calls with direct access to the Config variable throughout the audio package. The modification improves performance by eliminating function call overhead and simplifies the codebase by removing unnecessary indirection.

The commit also includes minor optimizations in validation logic and connection handling, while maintaining all existing functionality. Error handling remains robust with appropriate fallbacks when config values are not available.

Additional improvements include:
- Enhanced connection health monitoring in UnifiedAudioClient
- Optimized validation functions using cached config values
- Reduced memory allocations in hot paths
- Improved error recovery during quality changes
2025-09-08 17:30:49 +00:00
Alex P 33be5acaa0 feat(audio): improve audio quality handling and recovery mechanisms
- Add server stats reset and frame drop recovery functions
- Implement global audio server instance management
- Add WebRTC audio track replacement capability
- Improve audio relay initialization with retry logic
- Enhance quality change handling with adaptive buffer management
- Add global helper functions for audio quality control
2025-09-08 12:48:22 +00:00
Alex P 817223cb91 feat(audio): implement zero-copy batch processing with reference counting
Add batch reference counting and zero-copy frame management for optimized audio processing. Includes:
- BatchReferenceManager for efficient reference counting
- ZeroCopyFrameSlice utilities for frame management
- BatchZeroCopyProcessor for high-performance batch operations
- Adaptive optimization interval based on stability metrics
- Improved memory management with zero-copy frames
2025-09-08 09:08:07 +00:00
Alex P 432d185c6a refactor(audio): improve memory management with atomic operations and chunk allocation
- Replace mutex-protected refCount with atomic operations in ZeroCopyFramePool
- Implement chunk-based allocation in AudioBufferPool to reduce allocations
- Add proper reference counting with atomic operations in ZeroCopyAudioFrame
- Optimize buffer pool sizing based on buffer size
2025-09-08 08:25:42 +00:00
Alex P 6f81edd101 perf(audio): make refCount operations atomic and optimize frame pooling
Replace mutex-protected refCount operations with atomic operations to improve performance in concurrent scenarios.
Simplify frame release logic and add hitCount metric for pool usage tracking.
2025-09-08 08:20:43 +00:00
Alex P 93b58618e8 refactor(audio): consolidate supervision logic into base implementation
Move common supervision loop logic to BaseSupervisor with configurable parameters
Simplify input/output supervisor implementations by using base template
Update function comments to be more concise
2025-09-08 05:53:06 +00:00
Alex P f38897ba9e refactor(audio): move channel and process management to base supervisor
Consolidate duplicate channel and process management code from input/output supervisors into BaseSupervisor
Add new methods for channel initialization and cleanup
Standardize process termination and monitoring behavior
2025-09-07 20:14:33 +00:00
Alex P 1664e8822e refactor(audio): improve process management and error handling
- Remove unused setRunning method from BaseSupervisor
- Refactor IPC input reader to use running flag and mutex
- Add atomic state management to InputSupervisor
- Implement proper channel cleanup and process termination
- Improve error handling and logging throughout
2025-09-07 19:35:14 +00:00
Alex P 9f0ebf65c8 [WIP] Simplification 2025-09-07 19:13:35 +00:00
Alex P 16cefe06f0 refactor(audio): replace mute functionality with start/stop for microphone
- Replace MuteMicrophone calls with StartMicrophone/StopMicrophone for clearer behavior
- Update microphone state broadcasting to reflect actual subprocess status
- Modify UI to use enable/disable terminology instead of mute/unmute
- Ensure microphone device changes properly restart the active microphone
2025-09-07 18:32:42 +00:00
Alex P 7f80d4d90f [WIP] Improvements: improve Audio Input Activation / Deactivation process so it is faster 2025-09-07 16:17:06 +00:00
Alex P 4c66cdadae feat(audio): add microphone stop endpoint and improve mute handling
- Implement new POST /microphone/stop endpoint
- Refactor mute handling to properly start/stop audio processes
- Add callback mechanism for audio relay to reconnect to current session
- Simplify UI microphone controls by combining mute/start-stop functionality
2025-09-06 20:17:29 +00:00
Alex P ca88a70515 Fix: Microphone & audio on page load, PID field parsing in audio input supervisor 2025-09-06 06:11:29 +00:00
Alex P 776982995b fix(audio): correct mute state broadcast in audio control service
Use BroadcastAudioMuteChanged instead of BroadcastAudioDeviceChanged to properly reflect mute state changes
2025-09-05 22:10:14 +00:00
Alex P f5e582f941 [WIP] Updates: Reduce PR complexity 2025-09-05 21:47:21 +00:00
Alex P 94b7ecb3ba [WIP] Updates / FIles reorg: reduce PR complexity 2025-09-05 21:34:23 +00:00
Alex P 2ae04307fa refactor(audio): standardize component logging names and cleanup
- Add component name constants for consistent logging across audio modules
- Remove redundant debug logs and outdated comments
- Delete obsolete naming standards documentation file
2025-09-05 21:12:17 +00:00
Alex P d55bf84179 Fix: currently selected preset not coming from the API 2025-09-05 17:33:13 +00:00
Alex P 1b7ea0fd41 Refactoring: Move most audio business logic into the audio package 2025-09-05 17:22:14 +00:00