DualSense haptics and controller speaker sound bluethooth #969

Manually merged
github merged 10 commits from gh-pr/969/head into gh-pr/969/base 2026-11-26 09:38:39 +00:00
Owner

@⁠Pyxellator on GitHub · 2026-10-02 09:59 UTC · original
main → main · +1394 −134 · 11 files · 10 commits · merged 2026-10-02 10:55 UTC

Summary

DualSense haptics and controller speaker audio previously relied on the USB audio endpoint. This PR sends both over Bluetooth using DualSense HID audio reports, so games such as Astro’s Playroom can use these effects wirelessly.
Bluetooth audio reports are prepared on a worker thread to keep encoding and HID writes off the emulation audio path. The audio queue is bounded to prevent delay from building up after a Bluetooth stall. Normal rumble resumes when haptic playback ends.

The PR also adds Opus for Bluetooth speaker encoding and includes macOS test allocation fixes needed for CI.

Testing

  • Linux: kyty_emulator build and pad_haptics, memory_tracker, and page_manager tests passed.
  • Windows: DualSense vibration and controller audio were tested over Bluetooth in Astro’s Playroom.

AI use

Implementation and automated tests were developed with Codex at my direction. I tested the controller behavior described above.

**@⁠Pyxellator** on GitHub · 2026-10-02 09:59 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/969) `main` → `main` · +1394 −134 · 11 files · 10 commits · merged 2026-10-02 10:55 UTC ### **Summary** DualSense haptics and controller speaker audio previously relied on the USB audio endpoint. This PR sends both over Bluetooth using DualSense HID audio reports, so games such as Astro’s Playroom can use these effects wirelessly. Bluetooth audio reports are prepared on a worker thread to keep encoding and HID writes off the emulation audio path. The audio queue is bounded to prevent delay from building up after a Bluetooth stall. Normal rumble resumes when haptic playback ends. The PR also adds Opus for Bluetooth speaker encoding and includes macOS test allocation fixes needed for CI. ### **Testing** - Linux: kyty_emulator build and pad_haptics, memory_tracker, and page_manager tests passed. - Windows: DualSense vibration and controller audio were tested over Bluetooth in Astro’s Playroom. ### **AI use** Implementation and automated tests were developed with Codex at my direction. I tested the controller behavior described above.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:38:38 +00:00
github manually merged commit 1d7a9ce395 into gh-pr/969/base 2026-11-26 09:38:39 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-02 10:03 UTC · original · edited 2026-10-02 10:35 UTC

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 2d978f48-8641-4567-b72e-e440a1bcc4d4

📥 Commits

Reviewing files that changed from the base of the PR and between 78762bb48b and f147c69354.

📒 Files selected for processing (2)
  • src/libs/audio.cpp
  • tests/AudioOutTimingTests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.


📝 Walkthrough

Walkthrough

The change adds Bluetooth HID audio and haptics for wireless DualSense controllers, using Opus for speaker audio. Haptics and general audio routing distinguish Bluetooth from wired controllers, and audio buffering and pacing are updated. Audio output APIs reject zero sample frequency. Tests cover Bluetooth reports, routing, failures, concurrency, and buffering. Memory and page-manager tests now search multiple fixed guest addresses.

Suggested reviewers: mhakkuh, nmzik, cosmo

Priority: ➖ Normal

Change: Feature

Merge Risk: 🔵 Low · up to f147c

Zero-frequency output requests now fail cleanly. The USB timing test may still pass through fallback pacing if USB-specific pacing regresses, so a focused boundary case would improve confidence; no current runtime failure is established.

Security Architecture Review

Security architecture risk: 🔵 Low · up to f147c

Wireless output is constrained by controller identity checks, bounded transport queues, and stale-report protection. No introduced security vulnerability was established, but device-identity lifetime and cleanup during stalled or failed writes remain incompletely verified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The newly reachable sensitive outcome is guest-influenced speaker and haptic output through host HID access to selected supported controllers. Relevant failure exposure includes emulator-process resources and controller output state; device selection is constrained by the host controller choice and per-open identity filters.

Trust Boundaries and Controls

  • observed — Guest audio submissions do not supply a HID path or controller identity to the transport. Audio obtains the active controller from the host controller layer. Opening requires wireless PS5 type, supported vendor/product, a valid matching serial address, Bluetooth bus, eligible usage, and exactly one matching HID path. These are device-selection controls, not cryptographic device authentication.

Resilience and Maintainability Implications

  • observed — Encoding or HID-write failure marks a session failed and prevents subsequent sending. Cleanup remains tied to later queue failure handling, explicit close, or shutdown. Close waits for an in-flight write and shutdown joins the shared worker; these paths do not show an independent completion deadline.

Hardening Proposals

  • proposed — Establish the controller-ID lifetime contract and verify recovery with a HID write that fails or does not complete. Specifically verify device identity after reconnect, resource release without another audio submission, and bounded close/shutdown behavior before relying on these lifecycle guarantees.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 3.37% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 89 functions across 9 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: DualSense haptics and controller speaker audio over Bluetooth. It contains a spelling error in “bluethooth,” but remains understandable and related.
Description check ✅ Passed The description accurately describes Bluetooth HID audio reports, worker-thread processing, bounded audio queues, Opus encoding, testing, and macOS CI fixes. It is directly related to the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-02 10:03 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/969#issuecomment-5949885393) · edited 2026-10-02 10:35 UTC <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/969?cs_source=review_comment"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=2" alt="Review in Change Stack →" width="220" height="32"></a> Navigate logical layers of code changes, visualize relationships, and explore their blast radius. <!-- review_stack_entry_end --> <!-- recent_review_start --> No actionable comments were generated in the recent review. 🎉 <details> <summary>ℹ️ Recent review info</summary> <details> <summary>⚙️ Run configuration</summary> **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml **Review profile**: CHILL **Plan**: Advanced **Run ID**: `2d978f48-8641-4567-b72e-e440a1bcc4d4` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 78762bb48b34e8c043aae6a5721bc9180e1311cb and f147c693540683ace4cc67fd47e06e45c63e3602. </details> <details> <summary>📒 Files selected for processing (2)</summary> * `src/libs/audio.cpp` * `tests/AudioOutTimingTests.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review. </details> --- <!-- recent_review_end --> <!-- walkthrough_start --> <details> <summary>📝 Walkthrough</summary> ## Walkthrough The change adds Bluetooth HID audio and haptics for wireless DualSense controllers, using Opus for speaker audio. Haptics and general audio routing distinguish Bluetooth from wired controllers, and audio buffering and pacing are updated. Audio output APIs reject zero sample frequency. Tests cover Bluetooth reports, routing, failures, concurrency, and buffering. Memory and page-manager tests now search multiple fixed guest addresses. **Suggested reviewers:** `mhakkuh`, `nmzik`, `cosmo` </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ➖ Normal <!-- change_assessment_commit:"f147c693540683ace4cc67fd47e06e45c63e3602" --> **Change:** Feature <!-- change_assessment_end --> <!-- final_review_risk_start --> **Merge Risk:** _🔵 Low_ · up to `f147c` <!-- final_review_risk_coverage:{"sourceCommitId":"f147c693540683ace4cc67fd47e06e45c63e3602","coveredCommitId":"f147c693540683ace4cc67fd47e06e45c63e3602","kind":"reviewed"} --> Zero-frequency output requests now fail cleanly. The USB timing test may still pass through fallback pacing if USB-specific pacing regresses, so a focused boundary case would improve confidence; no current runtime failure is established. <!-- final_review_risk_end --> <!-- architecture_review_start --> ### Security Architecture Review **Security architecture risk:** _🔵 Low_ · up to `f147c` Wireless output is constrained by controller identity checks, bounded transport queues, and stale-report protection. No introduced security vulnerability was established, but device-identity lifetime and cleanup during stalled or failed writes remain incompletely verified. **Retained concerns** No architecture-level concerns identified. <details> <summary>Security review details</summary> **Security Blast Radius** - _inferred_ — The newly reachable sensitive outcome is guest-influenced speaker and haptic output through host HID access to selected supported controllers. Relevant failure exposure includes emulator-process resources and controller output state; device selection is constrained by the host controller choice and per-open identity filters. **Trust Boundaries and Controls** - _observed_ — Guest audio submissions do not supply a HID path or controller identity to the transport. Audio obtains the active controller from the host controller layer. Opening requires wireless PS5 type, supported vendor/product, a valid matching serial address, Bluetooth bus, eligible usage, and exactly one matching HID path. These are device-selection controls, not cryptographic device authentication. **Resilience and Maintainability Implications** - _observed_ — Encoding or HID-write failure marks a session failed and prevents subsequent sending. Cleanup remains tied to later queue failure handling, explicit close, or shutdown. Close waits for an in-flight write and shutdown joins the shared worker; these paths do not show an independent completion deadline. **Hardening Proposals** - _proposed_ — Establish the controller-ID lifetime contract and verify recovery with a HID write that fails or does not complete. Specifically verify device identity after reconnect, resource release without another audio submission, and bounded close/shutdown behavior before relying on these lifecycle guarantees. </details> <!-- architecture_review_end --> <!-- pre_merge_checks_walkthrough_start --> <details> <summary>🚥 Pre-merge checks | ✅ 4 | ❌ 1</summary> ### ❌ Failed checks (1 warning) | Check name | Status | Explanation | Resolution | | :----------------: | :--------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ⚠️ Warning | Docstring coverage is 3.37% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 89 functions across 9 files. | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary>✅ Passed checks (4 passed)</summary> | Check name | Status | Explanation | | :------------------------: | :------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Title check | ✅ Passed | The title clearly identifies the main change: DualSense haptics and controller speaker audio over Bluetooth. It contains a spelling error in “bluethooth,” but remains understandable and related. | | Description check | ✅ Passed | The description accurately describes Bluetooth HID audio reports, worker-thread processing, bounded audio queues, Opus encoding, testing, and macOS CI fixes. It is directly related to the changeset. | | Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. | </details> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- autopilot:start --> - [ ] <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autopilot</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts > Autopilot is currently an internal CodeRabbit preview. <!-- autopilot:end --> <!-- tips_start --> --- Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=969)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary>❤️ Share</summary> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
@ -0,0 +406,4 @@
break;
}
queued = std::max(0, SDL_GetAudioStreamQueued(stream->audio));
}
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-02 10:03 UTC · original · edited 2026-10-02 10:17 UTC

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Haptic overflow discards almost the whole queue, not the oldest report slot.

The discarded buffer holds 2 * OPUS_FRAMES * 2 floats, which is 7680 bytes. SDL_GetAudioStreamData measures this request in the output format.

  • Speaker stream (45 kHz stereo): 7680 bytes is 960 output frames. That is one 21.3 ms report slot, so the loop works as the comment says.
  • Haptic stream (3 kHz stereo): 7680 bytes is 960 output frames, which is 320 ms. The queue holds at most 80 ms of input, which is about 240 output frames.

So on a haptic stream, the first read drains everything SDL can produce. Only the resampler lookahead survives. After a Bluetooth write stall, haptics therefore lose up to 80 ms of buffered waveform. This is the gap the comment says the code avoids. TestBluetoothOverflowKeepsRecentAudio tests only the speaker stream, so it does not catch this.

Fix: size each discard read to one report slot for the stream type. A haptic slot is 128 floats (64 stereo frames).

🐛 Proposed fix
 		std::array<float, 2 * OPUS_FRAMES * 2> discarded {};
+		// One report slot in the stream's output format.
+		const int slot_bytes = static_cast<int>(
+		    (stream->speaker ? discarded.size() : 128) * sizeof(float));
 		const int target = static_cast<int>(max_frames * 2 * sizeof(float)) - bytes;
 		while (queued > target) {
-			if (SDL_GetAudioStreamData(stream->audio, discarded.data(), sizeof(discarded)) <= 0) {
+			if (SDL_GetAudioStreamData(stream->audio, discarded.data(), slot_bytes) <= 0) {
 				SDL_ClearAudioStream(stream->audio);
 				break;
 			}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

		std::array<float, 2 * OPUS_FRAMES * 2> discarded {};
		// One report slot in the stream's output format.
		const int slot_bytes = static_cast<int>(
		    (stream->speaker ? discarded.size() : 128) * sizeof(float));
		const int target = static_cast<int>(max_frames * 2 * sizeof(float)) - bytes;
		while (queued > target) {
			if (SDL_GetAudioStreamData(stream->audio, discarded.data(), slot_bytes) <= 0) {
				SDL_ClearAudioStream(stream->audio);
				break;
			}
			queued = std::max(0, SDL_GetAudioStreamQueued(stream->audio));
		}

✅ Addressed in commits 44ba657 to 78762bb

**@⁠coderabbitai[bot]** on GitHub · 2026-10-02 10:03 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/969#discussion_r4164743821) · edited 2026-10-02 10:17 UTC _🎯 Functional Correctness_ | _🟡 Minor_ | _⚡ Quick win_ **Haptic overflow discards almost the whole queue, not the oldest report slot.** The `discarded` buffer holds `2 * OPUS_FRAMES * 2` floats, which is 7680 bytes. `SDL_GetAudioStreamData` measures this request in the output format. - Speaker stream (45 kHz stereo): 7680 bytes is 960 output frames. That is one 21.3 ms report slot, so the loop works as the comment says. - Haptic stream (3 kHz stereo): 7680 bytes is 960 output frames, which is 320 ms. The queue holds at most 80 ms of input, which is about 240 output frames. So on a haptic stream, the first read drains everything SDL can produce. Only the resampler lookahead survives. After a Bluetooth write stall, haptics therefore lose up to 80 ms of buffered waveform. This is the gap the comment says the code avoids. `TestBluetoothOverflowKeepsRecentAudio` tests only the speaker stream, so it does not catch this. Fix: size each discard read to one report slot for the stream type. A haptic slot is 128 floats (64 stereo frames). <details> <summary>🐛 Proposed fix</summary> ```diff std::array<float, 2 * OPUS_FRAMES * 2> discarded {}; + // One report slot in the stream's output format. + const int slot_bytes = static_cast<int>( + (stream->speaker ? discarded.size() : 128) * sizeof(float)); const int target = static_cast<int>(max_frames * 2 * sizeof(float)) - bytes; while (queued > target) { - if (SDL_GetAudioStreamData(stream->audio, discarded.data(), sizeof(discarded)) <= 0) { + if (SDL_GetAudioStreamData(stream->audio, discarded.data(), slot_bytes) <= 0) { SDL_ClearAudioStream(stream->audio); break; } ``` </details> <!-- suggestion_start --> <details> <summary>📝 Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. ```suggestion std::array<float, 2 * OPUS_FRAMES * 2> discarded {}; // One report slot in the stream's output format. const int slot_bytes = static_cast<int>( (stream->speaker ? discarded.size() : 128) * sizeof(float)); const int target = static_cast<int>(max_frames * 2 * sizeof(float)) - bytes; while (queued > target) { if (SDL_GetAudioStreamData(stream->audio, discarded.data(), slot_bytes) <= 0) { SDL_ClearAudioStream(stream->audio); break; } queued = std::max(0, SDL_GetAudioStreamQueued(stream->audio)); } ``` </details> <!-- suggestion_end --> <!-- fingerprinting:phantom:medusa:pangolin --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:3ac116ea54b3d9d667d4fdfa --> <!-- This is an auto-generated reply by CodeRabbit --> ✅ Addressed in commits 44ba657 to 78762bb <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-02 10:03 UTC · original · reviewed

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: fe537d28-f8a7-4508-92e8-4fc33621b015

📥 Commits

Reviewing files that changed from the base of the PR and between 39e23ac92e and 0ad4080dea.

📒 Files selected for processing (9)
  • CMakeLists.txt
  • src/libs/audio.cpp
  • src/libs/dualSenseBluetooth.cpp
  • src/libs/dualSenseBluetooth.h
  • src/libs/dualSenseHaptics.cpp
  • src/libs/dualSenseHaptics.h
  • tests/MemoryTrackerTests.cpp
  • tests/PadHapticsTests.cpp
  • tests/PageManagerTests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-02 10:03 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/969#pullrequestreview-5390573791) · **reviewed** **Actionable comments posted: 1** --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml **Review profile**: CHILL **Plan**: Advanced **Run ID**: `fe537d28-f8a7-4508-92e8-4fc33621b015` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 39e23ac92e5ad8e9d65daa21ec003ba1305ea2f8 and 0ad4080dea45928b7672a07c79ada68d5d553307. </details> <details> <summary>📒 Files selected for processing (9)</summary> * `CMakeLists.txt` * `src/libs/audio.cpp` * `src/libs/dualSenseBluetooth.cpp` * `src/libs/dualSenseBluetooth.h` * `src/libs/dualSenseHaptics.cpp` * `src/libs/dualSenseHaptics.h` * `tests/MemoryTrackerTests.cpp` * `tests/PadHapticsTests.cpp` * `tests/PageManagerTests.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
@ -0,0 +406,4 @@
break;
}
queued = std::max(0, SDL_GetAudioStreamQueued(stream->audio));
}
Author
Owner

@⁠Pyxellator on GitHub · 2026-10-02 10:07 UTC · original

ok, i´m fixing it

**@⁠Pyxellator** on GitHub · 2026-10-02 10:07 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/969#discussion_r4164767735) ok, i´m fixing it
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-02 10:23 UTC · original · reviewed

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

🟠 Major · Reject freq == 0 before opening an output port. · audio.cpp:53

src/libs/audio.cpp:53
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Reject freq == 0 before opening an output port.

The vibration-port divide-by-zero path already existed at the merge base. This PR adds another path: blocking PADSPK output can compute block_us by dividing by port.freq. Since AudioOutOpen accepts and stores zero, validate freq before creating the port and return an error.

🧹 Nitpick comments (1)
tests/AudioOutTimingTests.cpp (1)

364-365: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add a just-above-target USB pacing case.

The 80 ms queue can produce the same one-audio-block wait through the fallback sample clock when USB-specific pacing is skipped. Add a queue duration slightly above AUDIO_OUT_TARGET_LATENCY_US and assert that the wait is shorter than one audio block. This adds coverage for currently correct pacing rather than fixing a current functional failure.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: ed504435-3111-406b-a7be-9504aae31d9c

📥 Commits

Reviewing files that changed from the base of the PR and between 0ad4080dea and 78762bb48b.

📒 Files selected for processing (6)
  • CMakeLists.txt
  • src/libs/audio.cpp
  • src/libs/dualSenseBluetooth.cpp
  • tests/AudioOutTimingTests.cpp
  • tests/MemoryTrackerTests.cpp
  • tests/PadHapticsTests.cpp
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/libs/dualSenseBluetooth.cpp
  • tests/PadHapticsTests.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-02 10:23 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/969#pullrequestreview-5390740445) · **reviewed** > [!CAUTION] > Some comments are outside the diff and can’t be posted inline due to GitHub limitations. > > **⚠️ Outside diff range comments (1)** > > <details> > <summary><em>🟠 Major</em> · Reject <code>freq == 0</code> before opening an output port. · <code>audio.cpp:53</code></summary><blockquote> > > `src/libs/audio.cpp:53` > _🩺 Stability & Availability_ | _🟠 Major_ | _⚡ Quick win_ > > **Reject `freq == 0` before opening an output port.** > > The vibration-port divide-by-zero path already existed at the merge base. This PR adds another path: blocking PADSPK output can compute `block_us` by dividing by `port.freq`. Since `AudioOutOpen` accepts and stores zero, validate `freq` before creating the port and return an error. > > <!-- cr-comment:v1:051006ba5bef183470493b3b --> > > </blockquote></details> <details> <summary>🧹 Nitpick comments (1)</summary><blockquote> <details> <summary>tests/AudioOutTimingTests.cpp (1)</summary><blockquote> `364-365`: _🎯 Functional Correctness_ | _🔵 Trivial_ | _⚡ Quick win_ **Add a just-above-target USB pacing case.** The 80 ms queue can produce the same one-audio-block wait through the fallback sample clock when USB-specific pacing is skipped. Add a queue duration slightly above `AUDIO_OUT_TARGET_LATENCY_US` and assert that the wait is shorter than one audio block. This adds coverage for currently correct pacing rather than fixing a current functional failure. <!-- cr-comment:v1:0bb8573a61d30db07cab3e21 --> </blockquote></details> </blockquote></details> --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml **Review profile**: CHILL **Plan**: Advanced **Run ID**: `ed504435-3111-406b-a7be-9504aae31d9c` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 0ad4080dea45928b7672a07c79ada68d5d553307 and 78762bb48b34e8c043aae6a5721bc9180e1311cb. </details> <details> <summary>📒 Files selected for processing (6)</summary> * `CMakeLists.txt` * `src/libs/audio.cpp` * `src/libs/dualSenseBluetooth.cpp` * `tests/AudioOutTimingTests.cpp` * `tests/MemoryTrackerTests.cpp` * `tests/PadHapticsTests.cpp` </details> <details> <summary>🚧 Files skipped from review as they are similar to previous changes (2)</summary> * src/libs/dualSenseBluetooth.cpp * tests/PadHapticsTests.cpp </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
Author
Owner

@⁠Nmzik on GitHub · 2026-10-02 10:54 UTC · original

Unified USB and Bluetooth paths. Thanks

**@⁠Nmzik** on GitHub · 2026-10-02 10:54 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/969#issuecomment-5950843066) Unified USB and Bluetooth paths. Thanks
Author
Owner

@⁠Rool-IO on GitHub · 2026-10-02 13:24 UTC · original

Small regression resulting from those changes is SpeakerFX are quieter.
Worth considering to offer a couple sliders in Kyty's settings interface to mimic console's options of lowering or upping respective Speaker and Haptics volumes.

**@⁠Rool-IO** on GitHub · 2026-10-02 13:24 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/969#issuecomment-5953343384) Small regression resulting from those changes is SpeakerFX are quieter. Worth considering to offer a couple sliders in Kyty's settings interface to mimic console's options of lowering or upping respective Speaker and Haptics volumes.
Author
Owner

@⁠Pyxellator on GitHub · 2026-10-02 13:29 UTC · original

I think @⁠Cosmo has already done something similar

**@⁠Pyxellator** on GitHub · 2026-10-02 13:29 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/969#issuecomment-5953428739) I think @⁠Cosmo has already done something similar
Author
Owner

@⁠Pyxellator on GitHub · 2026-10-02 13:29 UTC · original

Still, i think i will build a solution with sliders inside the settings of Kyty

**@⁠Pyxellator** on GitHub · 2026-10-02 13:29 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/969#issuecomment-5953440707) Still, i think i will build a solution with sliders inside the settings of Kyty
Author
Owner

@⁠Rool-IO on GitHub · 2026-10-02 13:49 UTC · original

Other issue with this is if you have the DualSense connected over BT, then plug it in over USB (both BT and USB are still active in this scenario), then neither Haptics nor SpeakerFX are sent to the controller and Mic input doesn't work either despite being selected in Kyty's settings.
Unplugging (falling back to BT only) restores functionalities.

**@⁠Rool-IO** on GitHub · 2026-10-02 13:49 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/969#issuecomment-5953834603) Other issue with this is if you have the DualSense connected over BT, then plug it in over USB (both BT and USB are still active in this scenario), then neither Haptics nor SpeakerFX are sent to the controller and Mic input doesn't work either despite being selected in Kyty's settings. Unplugging (falling back to BT only) restores functionalities.
Author
Owner

@⁠Pyxellator on GitHub · 2026-10-02 13:55 UTC · original

True, im gonna fix that later

**@⁠Pyxellator** on GitHub · 2026-10-02 13:55 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/969#issuecomment-5953960607) True, im gonna fix that later
This discussion has been locked. Commenting is limited to contributors.
No description provided.