Commit Graph
100 Commits
Author SHA1 Message Date
Cameron Gutman edb4e9e05f Use atomics for initialized variable in input functions 2026-11-10 23:59:52 -06:00
Cameron Gutman c3360b7102 Use atomics for thread cancellation 2026-11-10 23:34:03 -06:00
Cameron Gutman 7d884fadc3 Make active object counts debug-only and atomic 2026-11-10 23:17:05 -06:00
Cameron Gutman 7fd0f25967 Use atomic_int for LBQ currentSize 2026-11-10 23:02:43 -06:00
Cameron Gutman b0deb0a265 Start adopting C11 atomics 2026-11-10 22:17:55 -06:00
Cameron Gutman 3b6ee9d916 Remove LiPeekNextVideoFrame API
Due to internal queue flushes outside of the app's control, this
API has fundamental UAF issues and is not possible to use safely.
2026-11-10 21:25:16 -06:00
Cameron Gutman 4aa7ea4e84 Fix double-close of audio socket in error paths 2026-11-10 21:07:26 -06:00
Cameron Gutman 348d5d1e32 Fix potential leaks on queue shutdown 2026-11-10 21:03:51 -06:00
Cameron Gutman 3387805deb Consistently handle the frame index as 32-bit 2026-11-10 20:21:33 -06:00
Cameron Gutman ee160c9193 Correctly parse padded STUN attributes 2026-11-03 01:23:49 -06:00
Cameron Gutman 2e18599b26 Validate the STUN message length field 2026-11-03 01:09:25 -06:00
Cameron Gutman 7bf16de8e2 Verify source addresses for STUN responses 2026-11-03 00:49:12 -06:00
Cameron Gutman 134eee49e0 Wait for a valid STUN response to stop sending
We previously would stop on any received message, including a STUN
binding error response or even a non-STUN garbage message.
2026-11-03 00:10:17 -06:00
Cameron Gutman f462147ffd Fix format string mismatch 2026-11-02 23:26:35 -06:00
Cameron Gutman 41d6c1db74 Fix unused parameter 2026-11-02 23:25:50 -06:00
Cameron Gutman f050b13b6a Add explicit cast to make MSVC happy 2026-11-01 15:11:58 -06:00
Cameron Gutman 7d61e2d95f Don't provide ENet backpressure when sending large payloads 2026-11-01 15:07:59 -06:00
Cameron Gutman 4853e70489 Add jumbo control stream messages for larger than 16-bit payloads 2026-11-01 15:07:12 -06:00
Cameron Gutman c7dff22963 Add replay detection to RTSP and control streams
Replays can do very little harm in these contexts, but let's detect and prevent them anyways.

Fixes #165
Closes #170
2026-11-01 14:07:45 -06:00
Cameron Gutman 421bd74e01 End mouse motion batches on mouse button events 2026-10-22 21:26:18 -05:00
Cameron Gutman f1cca2dd6b Fix a couple pen event batching issues 2026-10-22 21:16:11 -05:00
Cameron Gutman 970b0729c5 Fix use after free of queued controller packets
We could attempt to use a freed controller packet if
- The connection terminated with one still queued
- We hit the maximum input queue size limit

In either of those cases we could both fail to send
the desired input and cause memory corruption.
2026-10-22 20:44:37 -05:00
Cameron Gutman 448b2c6868 Latch mouse deltas before sending to prevent starvation
It's possible a client sending rapid relative mouse motion
could completely monopolize the input thread and prevent it
from exiting the loop.
2026-10-22 20:38:22 -05:00
Cameron Gutman 04053843c9 Pack NV_UNICODE_PACKET densely for Sunshine
This reduces overhead up to 32x for large text blocks and avoids
flooding the ENet connection with packets all at once.
2026-10-19 22:51:41 -05:00
Cameron Gutman 4a95eb35b2 Send UTF-8 events on the keyboard channel
This avoids racing with regular keyboard events that could affect the input.
2026-10-19 01:25:18 -05:00
Cameron Gutman 342b106bbb Perform control stream encryption in-place 2026-10-19 01:10:46 -05:00
Cameron Gutman aeba988e0a Rework RTSP parser to fix many spec compliance issues 2026-10-14 17:11:45 -05:00
Cameron Gutman 5ec839727a Fix memory leak if duplicate RTSP options are inserted 2026-10-14 01:25:49 -05:00
Cameron Gutman e2722dc837 Fix uninitialized stack data in the periodic ping payload 2026-10-12 23:31:33 -05:00
Cameron Gutman f900dd4767 Add MODIFIER_EXTENDED flag to indicate extended keys 2026-09-26 14:50:13 -05:00
Cameron Gutman 5a2632990f Add section 7 exception for app store distribution
Fixes #30
2026-09-26 13:27:15 -05:00
Cameron Gutman 62e066388f Don't speculatively report losses if RFI is disabled
Not only does it unnecessarily cause guaranteed loss of the target frame, it can lead to 120 consecutive frames dropped if we fully receive that frame since we've already triggered an IDR frame wait but didn't tell the depacketizer to request an IDR frame.

Closes #147
2026-09-08 23:25:43 -05:00
Cameron Gutman be438856af Fix handling of a partially dropped IDR frame 2026-09-08 22:58:14 -05:00
Cameron Gutman d85371cd8c Fix RFI after a multi-block frame loss 2026-09-08 22:48:59 -05:00
Cameron Gutman 518b244152 Rewrite MbedTLS codepaths to use the modern PSA APIs
This also fixes an issue that caused audio decryption to fail on MbedTLS 3.x.

Closes #142
2026-08-18 21:37:13 -05:00
Cameron Gutman 1f764276e8 Switch to upstream nanors with native SIMD and GFNI runtime dispatching 2026-07-04 15:32:12 -04:00
Cameron Gutman 99c45d35ad Fix compatibility with GCC versions that lack __has_builtin() 2026-07-03 13:17:00 -05:00
Cameron Gutman 1fddbcb7c6 Don't leak rswrapper into our headers 2026-07-03 13:09:27 -05:00
Cameron Gutman 2600beaf13 Add support for controllers with dual touchpads 2026-05-14 22:13:45 -05:00
Cameron Gutman 7022b337a9 Refactor BSD socket errors for Win32 and add EMSGSIZE 2026-03-28 15:03:38 -05:00
Cameron Gutman b187204769 Restore fallback scalar path for x86 2026-02-19 20:04:31 -06:00
Cameron Gutman 3872285d8c Fix incorrectly enabling SSSE3 on all x64 Windows platforms 2026-02-19 20:03:20 -06:00
Cameron Gutman a063522db4 Use the SIMDe 128-bit path for all non-x86 systems
SIMDe includes support for AltiVec, LSX, NEON, and more. It also includes fallbacks that are optimized for compiler autovectorization for other architectures (like RISC-V RVV)

Since there's no runtime dispatching for these, they will be selected depending on which instructions are enabled by the toolchain at compile-time.
2026-02-19 19:29:11 -06:00
Cameron Gutman 5551d29ba2 Use SIMDe for NEON acceleration 2026-02-19 00:14:42 -06:00
Cameron Gutman 1d0e91d91a Add ARM64 targets to CI 2026-02-15 21:45:58 -06:00
Cameron Gutman b6b95b68b7 Enable CI for all branches 2026-02-15 21:40:01 -06:00
Cameron Gutman 6250fa29ee Update ENet for FreeBSD compatibility 2026-02-06 23:24:42 -06:00
Cameron Gutman 07c32c80f9 Use a valid port when calling connect() for local address detection
BSDs (including Darwin) don't like using port 0.
2026-02-06 22:53:54 -06:00
Cameron Gutman 435bc6a5a4 Fix pthread_attr leak 2026-01-11 01:46:30 -06:00
Cameron Gutman 3a377e7d7b Only set an explicit pthread stack size on Vita 2026-01-05 00:23:31 -06:00
Cameron Gutman 0586f3d65f Fix thread context leak on non-Vita platforms 2026-01-05 00:21:35 -06:00
Cameron Gutman b126e481a1 Improve locking for batched mouse and gamepad sensor events
By unlocking the mutex before we enqueue the new entry, we can avoid the input thread immediately contending on the mutex after the new item wakes it up.
2025-11-25 17:30:01 -06:00
Cameron Gutman 20c05eda6a Don't lock the ENet mutex when querying for RTT information 2025-11-25 17:26:01 -06:00
Cameron Gutman 2d984f4b0d Update ENet for improved FreeBSD support 2025-11-09 20:36:42 -06:00
Cameron Gutman e59a5f5b53 Rewrite gamepad input batching to batch on the enqueue-side
- Allows successful batching of interleaved input from multiple controllers
- Avoids enqueue/dequeue overhead and memory allocation when batching
2025-11-09 15:47:12 -06:00
Cameron Gutman 5f2280183c Fix CGN subnet mask 2025-07-15 09:59:57 -05:00
Cameron Gutman 0975a8684f Implement workaround for bad synthesized IPv6 addresses when connecting through a v4-only VPN on iOS 2025-07-14 22:27:54 -05:00
Cameron Gutman 262537959f Create dependabot.yml 2025-07-05 18:53:47 -05:00
Cameron Gutman 58902e342f Zero output parameters when BbGet*() fails 2025-06-08 15:49:52 -05:00
Cameron Gutman 84f37631c2 Add ByteBuffer APIs for reading/writing multiple bytes 2025-06-08 15:46:47 -05:00
Cameron Gutman d3d3e6cf01 Port improved ping interval logic into the control receive loop 2024-10-20 17:34:35 -05:00
Cameron Gutman 12e603eceb Further improve ENet ping interval wait logic 2024-10-20 17:15:04 -05:00
Cameron Gutman 04a2f1131c Update ENet with improved wakeup logic for enet_host_service() 2024-10-20 16:36:12 -05:00
Cameron Gutman dff1690fe1 Validate channel count before parsing Opus param string 2024-10-15 23:00:16 -05:00
Cameron Gutman 8599b6042a Use SO_NONBLOCK on Haiku 2024-06-10 23:45:51 -05:00
Cameron Gutman e49637d153 Bump enet submodule for Haiku support 2024-06-10 23:45:10 -05:00
Cameron Gutman c245fe599d Use higher packet size for remote streaming over end-to-end IPv6 connection
The IPv6 spec guarantees a minimum of 1280 byte MTUs
2024-05-29 13:57:50 -04:00
Cameron Gutman 5e75d4e1f1 Fix -Wsign-compare warning 2024-05-25 18:31:43 -05:00
Cameron Gutman a3e57feadd Update CI images 2024-05-25 18:31:09 -05:00
Cameron Gutman eb21561541 Don't depend on outputDataLength to be initialized with mbedTLS
OpenSSL has no such requirement, so MbedTLS breakages snuck in.
2024-03-05 21:09:57 -06:00
Cameron Gutman 48d7f1ace1 Fix incorrect function definition 2024-02-25 15:52:04 -06:00
Cameron Gutman ba1fc33672 Fix spurious asserts in the unencrypted audio path with Sunshine 2024-02-20 18:03:50 -06:00
Cameron Gutman 046c231b33 Update ENet submodule to use Wii U userbuffers 2024-02-18 13:41:31 -06:00
Cameron Gutman 8af4562af6 Assert that active objects exist in deleters 2024-02-17 18:20:24 -06:00
Cameron Gutman 59f7f62b62 Fix thread detachment on Vita 2024-02-17 18:14:49 -06:00
Cameron Gutman 9686f6942f Consolidate PltCloseThread() and PltJoinThread() 2024-02-17 18:14:03 -06:00
Cameron Gutman ec171fd7ca Don't use VersionHelpers.h on UWP 2024-02-03 17:20:13 -06:00
Cameron Gutman cbd0ec1b25 Fix signed/unsigned mismatch warnings 2024-02-03 15:20:56 -06:00
Cameron Gutman 92abf6e11d Update ENet with ECN/L4S support for Windows too 2024-02-03 15:19:13 -06:00
Cameron Gutman dc71a16bae Update ENet with ECN/L4S support 2024-02-03 15:14:47 -06:00
Cameron Gutman 7ab34e709a Improve encrypted RTSP message validation 2024-02-03 14:39:12 -06:00
Cameron Gutman 955f13a18d Implement RTSP encryption support 2024-02-02 22:55:53 -06:00
Cameron Gutman 0f3fa30f62 Update ENet with 3DS fixes and iOS/macOS QoS tagging fix 2024-02-01 18:30:22 -06:00
Cameron Gutman 3acba578b1 Update ENet with QoS tagging fixes 2024-02-01 01:20:19 -06:00
Cameron Gutman c0e3dc64a4 Add basic QoS attributes to our A/V sockets 2024-02-01 00:15:47 -06:00
Cameron Gutman 68153174bc Update ENet to improve connection robustness during transient network interruptions 2024-01-24 23:26:41 -06:00
Cameron Gutman fb2b103e51 Fix propagation of errors from enet_host_service() in sendMessageEnet() 2024-01-24 22:41:03 -06:00
Cameron Gutman e8113f0e66 Use the spare field in the encrypted video header as the frame number
This allows us to skip decrypting extra FEC shards after a frame was reassembled.
2024-01-24 18:36:37 -06:00
Cameron Gutman a517f7cbca Fix -Wsign-compare warnings in debug build 2024-01-18 21:35:20 -06:00
Cameron Gutman 2597b5e779 Use a 12-byte AES-GCM IV for the new encryption features 2024-01-18 18:29:47 -06:00
Cameron Gutman 298f356acb Adjust the requested packet size to account for the encryption header 2024-01-14 18:42:41 -06:00
Cameron Gutman 06f18be4bf Allow negotiation of audio encryption using new encryption flags 2024-01-14 14:10:45 -06:00
Cameron Gutman b74b6e883c Add video encryption support 2024-01-14 14:04:52 -06:00
Cameron Gutman 6083a75d1b Ensure no IV collisions 2024-01-14 13:18:22 -06:00
Cameron Gutman 3430ee2c3a Add control stream encryption v2 support 2024-01-14 12:58:48 -06:00
Cameron Gutman b6bbb4fb26 Add new RTSP encryption flags 2024-01-14 12:08:37 -06:00
Cameron Gutman 15b55a441b Add LiGetExtraLaunchArgs()
The string returned from this function should be appended to the end of the /resume and /launch query parameters.
2024-01-14 11:48:59 -06:00
Cameron Gutman 723cac034b Discard unencrypted packets on encrypted control stream 2024-01-14 11:41:01 -06:00
Cameron Gutman 6e9ed871bc Add support for X-SS-Connect-Data in RTSP SETUP for control stream
This allows the host to provide a 32-bit integer that will be sent
in the data of the ENet connect event, similar to X-SS-Ping-Payload
for video and audio.

The host can use this data to uniquely identify a client when IP
addresses are not stable across the various separate connections,
such as when the client is behind a Carrier-Grade NAT.
2023-12-28 16:56:06 -06:00
Cameron Gutman 50d8dcb072 Update ENet submodule with Apple dual stack socket fix 2023-12-28 16:10:55 -06:00