Commit Graph
100 Commits
Author SHA1 Message Date
Cameron Gutman b618ef2575 Fix C23 const correctness warnings 2026-11-27 12:23:27 -06:00
Cameron Gutman 94c65fd364 Remove references to the deprecated Chrome client 2026-11-13 00:45:35 -06:00
Cameron Gutman 67996eca5d Improve check for clock_gettime() and use it on Darwin
Also remove the CMake check which was broken anyway.
2026-11-13 00:34:21 -06:00
Cameron Gutman 30b928f6ae Fix enet_socket_wait() with 0 timeout on 3DS 2026-11-13 00:02:56 -06:00
Cameron Gutman a879f89736 Change sleep duration to unsigned 2026-11-12 23:50:55 -06:00
Cameron Gutman 98210be217 Remove separate __APPLE__ header section 2026-11-12 23:48:46 -06:00
Cameron Gutman cf68e15ee3 Prevent overflow in Win32 PltGetMicroseconds() 2026-11-12 23:48:46 -06:00
Cameron Gutman e6b1aaf0b8 Fix pollSockets() with timeout 0 on 3DS 2026-11-12 23:48:46 -06:00
Cameron Gutman 2804982d91 Fix PltSleepMs() handling of large sleep durations 2026-11-12 23:48:29 -06:00
Cameron Gutman 18922a1b32 Reject audio packets with no payload
It causes our Opus header validation to access uninitialized memory.
2026-11-12 22:29:27 -06:00
Cameron Gutman 2b45ee9f64 Fix PKCS7 padding for 16-byte aligned blocks 2026-11-12 22:28:14 -06:00
Cameron Gutman a1aa0a1801 Change LiSendMultiControllerEvent number/mask arguments to unsigned
The modulo operator will not work as expected with negative numbers.
2026-11-12 22:10:28 -06:00
Cameron Gutman f0df33caf8 Fix check for invalid motionType values 2026-11-12 22:04:20 -06:00
Cameron Gutman dc09c9f2e8 Fix incorrect mask logic in isInSubnetV6 2026-11-12 22:02:24 -06:00
Cameron Gutman 0b4a44d19c Fix missing global reinitialization when starting a new stream 2026-11-12 21:31:27 -06:00
Cameron Gutman ae6633eedc Keep RFI and IDR waits mutually exclusive 2026-11-12 21:22:23 -06:00
Cameron Gutman e64327c864 Add a lock to fix races in the VideoDepacketizer 2026-11-12 21:19:09 -06:00
Cameron Gutman a0262e78eb Fix data race in LiGetEstimatedRttInfo 2026-11-12 20:03:52 -06:00
Cameron Gutman d5b38a3ac6 Fix potentially missing ENet batching in mouse and UTF-8 cases 2026-11-11 15:39:14 -06:00
Cameron Gutman 541e396833 Redesign the RTP stats APIs to be race-free
We now accumulate the stats internally via atomic operations and copy
them into the caller's buffer when requested.

While we could expose the atomic fields in the public ABI, we want to
avoid this due to MSVC's C11 atomic implementation having no ABI
guarantees with the /experimental flag.
2026-11-11 15:22:31 -06:00
Cameron Gutman 08ebedb8aa Correctly synchronize early calls to timing functions 2026-11-11 15:18:19 -06:00
Cameron Gutman 74a61b9f27 Synchronize HDR metadata updates 2026-11-11 14:44:50 -06:00
Cameron Gutman 274ec03d85 Don't rewrite constant fields of enqueued controller packets
Even though it's writing the same values, it's still a data race.
2026-11-11 14:09:46 -06:00
Cameron Gutman eac4c469c7 Fix multi-waiter cases for Lbq and PLT_EVENT
We don't hit the broken cases today, but we could in the future.
2026-11-11 02:32:31 -06:00
Cameron Gutman e44e4290ed Use relaxed atomic for receivedDataFromPeer 2026-11-11 00:11:20 -06:00
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