Commit Graph
692 Commits
Author SHA1 Message Date
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 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
Drackrath 874ac9548f Add LI_CTYPE_STEAM controller type 2026-08-18 21:46:34 -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
Christopher Madrigal 82e2514854 Fix compilation for 3DS (#140)
* Changes to enhance support for 3DS

* Align helpers to correct type at compile

* explicity declare/initialize operational val where used
2026-07-11 22:47:14 -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
ReenigneArcher 47b4d338b1 Skip Reed-Solomon SIMD variants for NXDK 2026-06-23 21:22:27 -05:00
ReenigneArcher 40d87314d0 Add NXDK (Xbox) support 2026-06-23 17:58:10 -05:00
Cameron Gutman 2600beaf13 Add support for controllers with dual touchpads 2026-05-14 22:13:45 -05:00
foxirain 7b026e77be Harden RTSP handling for malformed Session headers and oversized responses 2026-03-30 08:32:12 -05:00
Cameron Gutman 7022b337a9 Refactor BSD socket errors for Win32 and add EMSGSIZE 2026-03-28 15:03:38 -05:00
MrCreativ3001 3fa9191330 Use lowercase windows headers for easier cross-compilation 2026-02-20 19:33:13 -06:00
Andy Grundman de364b6ecd Use nanors for optimized Reed-Solomon FEC decoding (#125) 2026-02-18 23:36:52 -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
7mile 305993b013 fix: use UDP connect to probe local address (#121) 2026-01-29 18:52:06 -06:00
ns6089 2a5a1f3e8a Add support for LTR ACK control messages (#122)
* Add support for LTR ACK control messages
2026-01-20 21:47:38 -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 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
AorsiniYT 1c86405fd0 Fix: Add inclusion of <psp2/kernel/processmgr.h> for Vita compatibility 2025-11-07 00:37:14 -06:00
Andy Grundman e356b2cfde Change presentationTimeMs to presentationTimeUs: retain more resolution when dealing with RTP video timestamps from Sunshine. Include raw rtpTimestamp value for use with integer time APIs. 2025-11-06 20:27:01 -06:00
Andy Grundman fdd026518c macOS/iOS: use clock_gettime_nsec_np(CLOCK_UPTIME_RAW) instead of mach_absolute_time() per Apple's recommendation.
Move has_monotonic_time variable into the final variant of platform-specific time code (used by Linux/Unix).
2025-11-06 20:27:01 -06:00
Andy Grundman a3ebaaf015 Use uint64_t for DECODE_UNIT presentationTimeMs
This still holds a millisecond value sourced from RTP timestamp, but since we're changing the API anyway, now is a good time to future-proof this field.
2025-11-06 20:27:01 -06:00
Andy Grundman 82ee2d6590 Improve support for high-resolution stats
* This patch adds a new microsecond-resolution function call, LiGetMicroseconds(), to complement
the existing LiGetMillis(). Many variables used by stats have been updated to work at this
higher resolution and now provide better results when displaying e.g. sub-millisecond frametime stats.
To try and avoid confusion, variables that now contain microseconds have been renamed with a suffix
of 'Us', and those ending in 'Ms' contain milliseconds. I originally experimented with nanoseconds but it
felt like overkill for our needs.

Public API in Limelight.h:
uint64_t LiGetMicroseconds(void);
uint64_t LiGetMillis(void);
const RTP_AUDIO_STATS* LiGetRTPAudioStats(void);  // provides access to RTP data for the overlay stats
const RTP_VIDEO_STATS* LiGetRTPVideoStats(void);

Note: Users of this library may need to make changes. If using LiGetMillis() to track the duration of
something that is shown to the user, consider switching to LiGetMicroseconds(). Remember to divide by
1000 at time of display to show in milliseconds.
2025-11-06 20:27:01 -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
camelcx c86e0537d1 Fix some edge case on small MTU devices using qsv codec (#107)
Add fall back logic to prevent edge case where SPS SPP is not included in the same packet and key IDR frame is mislabeled as P frame causing assertion error at validation.
2025-07-05 19:13:06 -05:00
armin-25689 29f298ec88 build: Add __FreeBSD__ compilation condition for pthread_setname_np() 2025-07-05 18:58:07 -05:00
34074c9ec0 Fixes for Moonlight compatibility on the PS Vita. (#110)
* Use pthread for vita thread managment

* Add thread name to pthread and remove ipv6 from vita

* Fix inclusion of pthread.h so that it is only included on specific platforms (__vita__)

* Fix memory release in ThreadProc for psvita platform

---------

Co-authored-by: MetalfaceScout <logan.mathis@utahtech.edu>
Co-authored-by: Logan Mathis <33127568+MetalfaceScout@users.noreply.github.com>
2025-07-05 18:57:33 -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
ABeltramo e95feaf495 Protocol extension: DualSense adaptive trigger support (#102) 2025-03-25 18:16:11 -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 dff1690fe1 Validate channel count before parsing Opus param string 2024-10-15 23:00:16 -05:00
ns6089 0fa805d973 Guard against rtsp response with no content 2024-10-15 22:48:59 -05:00