Play snd0.at9 when selecting a title in the launcher #1545

Manually merged
github merged 1 commit from gh-pr/1545/head into gh-pr/1545/base 2026-11-26 09:59:19 +00:00
Owner

@⁠Pipe530 on GitHub · 2026-10-16 02:31 UTC · original
Pipe530:pipe530-splash-snd0-at9 → main · +154 −2 · 4 files · 1 commits · merged 2026-10-16 13:59 UTC

Plays the selected title's sce_sys/snd0.at9 in the launcher using LibAtrac9 and SDL3. Switching or clearing the selection, launching a game, and closing the launcher stop playback.

Validated with a launcher build, mono/dual-mono and gapless audio fixtures, archive playback, cancellation and cleanup checks, and ASan/UBSan.

**@⁠Pipe530** on GitHub · 2026-10-16 02:31 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1545) `Pipe530:pipe530-splash-snd0-at9` → `main` · +154 −2 · 4 files · 1 commits · merged 2026-10-16 13:59 UTC Plays the selected title's sce_sys/snd0.at9 in the launcher using LibAtrac9 and SDL3. Switching or clearing the selection, launching a game, and closing the launcher stop playback. Validated with a launcher build, mono/dual-mono and gapless audio fixtures, archive playback, cancellation and cleanup checks, and ASan/UBSan.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:59:17 +00:00
github manually merged commit af580fd7b2 into gh-pr/1545/base 2026-11-26 09:59:19 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-16 02:37 UTC · original · edited 2026-10-16 14:01 UTC

Review in Change Stack →

📝 Walkthrough

The change adds ATRAC9 decoding and SDL playback for splash audio. The system overlay starts snd0.at9 when both splash images exist. It stops playback when the overlay shuts down or the splash finishes.

Priority: ⬇️ Low

Change: Feature

Merge Risk: 🟡 Moderate · up to ebc06

Playing the splash sound decodes the game's snd0.at9 at startup. A malformed file with an unsupported channel configuration can trigger an out-of-bounds read in the decoder before validation runs, which can crash startup when the splash screen is enabled. Reject invalid channel configurations before initializing the decoder, then this is otherwise ready to merge.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 18.18% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
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.
Description check Passed The description clearly explains that the pull request plays the selected title's snd0.at9 file through LibAtrac9 and SDL3, including when playback stops and how the change was validated.
Title check Passed The title clearly and concisely describes the main change: playing snd0.at9 when a title is selected in the launcher.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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-16 02:37 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1545#issuecomment-6206782627) · edited 2026-10-16 14:01 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/1545?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=3"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3" alt="Review in Change Stack →" height="32"></picture></a> <!-- review_stack_entry_end --> <!-- walkthrough_start --> <details> <summary><strong>📝 Walkthrough</strong></summary> <dl> <dd> The change adds ATRAC9 decoding and SDL playback for splash audio. The system overlay starts snd0.at9 when both splash images exist. It stops playback when the overlay shuts down or the splash finishes. </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ⬇️ Low <!-- change_assessment_commit:"ebc067077701cd7c828651e46bea4254f0739c4b" --> **Change:** Feature <!-- change_assessment_end --> <details> <summary><strong>Merge Risk:</strong> <strong>🟡 Moderate</strong> · up to <code>ebc06</code></summary> <dl> <dd> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **🟡 Moderate** · up to `ebc06` --> <!-- final_review_risk_coverage:{"sourceCommitId":"ebc067077701cd7c828651e46bea4254f0739c4b","coveredCommitId":"ebc067077701cd7c828651e46bea4254f0739c4b","kind":"reviewed"} --> Playing the splash sound decodes the game's snd0.at9 at startup. A malformed file with an unsupported channel configuration can trigger an out-of-bounds read in the decoder before validation runs, which can crash startup when the splash screen is enabled. Reject invalid channel configurations before initializing the decoder, then this is otherwise ready to merge. <!-- final_review_risk_end --> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_start --> <details> <summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 4 · <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> 1</strong></summary> <dl> <dd> <strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> Failed checks: 1 warning</strong> | Check name | Status | Explanation | Resolution | | :---------------- | :----------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :--------------------------------------------------------------------------------- | | Docstring Coverage | ![Warning](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-warning.svg) | Docstring coverage is 18.18% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 3 files. | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary><strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> Passed checks: 4 passed</strong></summary> <dl> <dd> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | Linked Issues check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description clearly explains that the pull request plays the selected title's snd0.at9 file through LibAtrac9 and SDL3, including when playback stops and how the change was validated. | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title clearly and concisely describes the main change: playing snd0.at9 when a title is selected in the launcher. | </dd> </dl> </details> </dd> </dl> </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">Autofix</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts <!-- autopilot:end --> <!-- tips_start --> Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=1545)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary><strong>❤️ Share</strong></summary> <dl> <dd> - [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) </dd> </dl> </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-16 02:37 UTC · original
On src/graphics/presentation/splashSound.cpp line 79 (outdated):

@@ -0,0 +1,172 @@
+#include "graphics/presentation/splashSound.h"
+
+#include <SDL3/SDL.h>
+
+#include "common/file.h"
+#include "common/logging/log.h"
+
+#include "libatrac9.h"
+
+#include <algorithm>
+#include <array>
+#include <cstdint>
+#include <cstring>
+#include <memory>
+#include <mutex>
+#include <vector>
+
+namespace Libs::Graphics {
+
+namespace {
+
+constexpr uint8_t ATRAC9_GUID[16] = {0xd2, 0x42, 0xe1, 0x47, 0xba, 0x36, 0x8d, 0x4d,
+                                     0x88, 0xfc, 0x61, 0x65, 0x4f, 0x8c, 0x83, 0x6c};
+
+std::mutex       g_mutex;
+SDL_AudioStream* g_stream     = nullptr;
+bool             g_sdl_inited = false;
+
+uint32_t ReadLe32(const uint8_t* p) {
+	return p[0] | (uint32_t {p[1]} << 8u) | (uint32_t {p[2]} << 16u) | (uint32_t {p[3]} << 24u);
+}
+
+uint16_t ReadLe16(const uint8_t* p) {
+	return static_cast<uint16_t>(p[0] | (p[1] << 8u));
+}
+
+struct DecodedSound {
+	std::vector<int16_t> pcm;
+	int                  channels = 0;
+	int                  rate     = 0;
+};
+
+bool DecodeAt9(const std::vector<uint8_t>& file, DecodedSound& out) {
+	if (file.size() < 12 || std::memcmp(file.data(), "RIFF", 4) != 0 ||
+	    std::memcmp(file.data() + 8, "WAVE", 4) != 0) {
+		return false;
+	}
+
+	const uint8_t* fmt       = nullptr;
+	const uint8_t* fact      = nullptr;
+	size_t         data_pos  = 0;
+	size_t         data_size = 0;
+	for (size_t pos = 12; pos + 8 <= file.size();) {
+		const uint8_t* chunk = file.data() + pos;
+		const size_t   size  = ReadLe32(chunk + 4);
+		const size_t   body  = pos + 8;
+		if (std::memcmp(chunk, "fmt ", 4) == 0 && size >= 52 && body + size <= file.size()) {
+			fmt = file.data() + body;
+		} else if (std::memcmp(chunk, "fact", 4) == 0 && size >= 12 &&
+		           body + size <= file.size()) {
+			fact = file.data() + body;
+		} else if (std::memcmp(chunk, "data", 4) == 0) {
+			data_pos  = body;
+			data_size = std::min(size, file.size() - body);
+			break;
+		}
+		pos = body + size + (size & 1u);
+	}
+	if (fmt == nullptr || data_pos == 0 || ReadLe16(fmt) != 0xfffe ||
+	    std::memcmp(fmt + 24, ATRAC9_GUID, sizeof(ATRAC9_GUID)) != 0) {
+		return false;
+	}
+
+	std::unique_ptr<void, decltype(&Atrac9ReleaseHandle)> handle(Atrac9GetHandle(),
+	                                                              Atrac9ReleaseHandle);
+	Atrac9CodecInfo                                       info {};
+	std::array<uint8_t, ATRAC9_CONFIG_DATA_SIZE>          config {};
+	std::memcpy(config.data(), fmt + 44, config.size());
+	if (handle == nullptr || Atrac9InitDecoder(handle.get(), config.data()) != 0 ||

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

set -eu
printf '%s\n' '--- changed file at reviewed head ---'
git show ebc067077701cd7c828651e46bea4254f0739c4b:src/graphics/presentation/splashSound.cpp | nl -ba | sed -n '1,180p'
printf '%s\n' '--- diff from merge base ---'
git diff --no-ext-diff --unified=40 3ff6606fcb6c1cae3aa46ef619f14b28efd3705d ebc067077701cd7c828651e46bea4254f0739c4b -- src/graphics/presentation/splashSound.cpp
printf '%s\n' '--- LibAtrac9 references and dependency declarations ---'
rg -n -F --glob '!build/**' --glob '!dist/**' -e 'Atrac9InitDecoder' -e 'LibAtrac9' -e 'libatrac9' -e 'atrac9' . || test "$?" -eq 1
printf '%s\n' '--- repository file candidates ---'
git ls-tree -r --name-only ebc067077701cd7c828651e46bea4254f0739c4b | rg -i 'atrac|submodule|cmake|meson|conan|vcpkg|premake|third.party|dependencies' || true

Repository: KytyPS5/KytyPS5

Length of output: 15949


🏁 Script executed:

set -eu
printf '%s\n' '--- changed file at reviewed head ---'
git show ebc067077701cd7c828651e46bea4254f0739c4b:src/graphics/presentation/splashSound.cpp | nl -ba | sed -n '1,180p'
printf '%s\n' '--- diff from merge base ---'
git diff --no-ext-diff --unified=40 3ff6606fcb6c1cae3aa46ef619f14b28efd3705d ebc067077701cd7c828651e46bea4254f0739c4b -- src/graphics/presentation/splashSound.cpp
printf '%s\n' '--- LibAtrac9 references and dependency declarations ---'
rg -n -F --glob '!build/**' --glob '!dist/**' --glob '!node_modules/**' -e 'Atrac9InitDecoder' -e 'LibAtrac9' -e 'libatrac9' -e 'atrac9' . || test "$?" -eq 1
printf '%s\n' '--- repository file candidates ---'
git ls-tree -r --name-only ebc067077701cd7c828651e46bea4254f0739c4b | rg -i 'atrac|submodule|cmake|meson|conan|vcpkg|premake|third.party|dependencies' || true

Repository: KytyPS5/KytyPS5

Length of output: 15949


🏁 Script executed:

set -eu
printf '%s\n' '--- decoder initialization and channel configuration ---'
rg -n -F --glob '3rdparty/LibAtrac9/C/src/*' -e 'ChannelConfigs' -e 'Atrac9InitDecoder' -e 'channel_config' -e 'channelConfig' -e 'CHANNEL_CONFIG' .
printf '%s\n' '--- relevant source files ---'
for f in $(rg -l --glob '3rdparty/LibAtrac9/C/src/*' -e 'ChannelConfigs' -e 'Atrac9InitDecoder' .); do
  printf '\n--- %s ---\n' "$f"
  nl -ba "$f" | sed -n '1,260p'
done
printf '%s\n' '--- build binding ---'
nl -ba 3rdparty/CMakeLists.txt | sed -n '175,190p'

Repository: KytyPS5/KytyPS5

Length of output: 210


🏁 Script executed:

set -eu
printf '%s\n' '--- vendored LibAtrac9 files ---'
find 3rdparty/LibAtrac9 -maxdepth 4 -type f -print | sort
printf '%s\n' '--- matching decoder sources ---'
rg -n -F --hidden --glob '!**/.git/**' -e 'ChannelConfigs' -e 'Atrac9InitDecoder' -e 'channel_config' -e 'channelConfig' -e 'CHANNEL_CONFIG' 3rdparty/LibAtrac9 || test "$?" -eq 1
printf '%s\n' '--- build binding ---'
nl -ba 3rdparty/CMakeLists.txt | sed -n '180,187p'

Repository: KytyPS5/KytyPS5

Length of output: 565


🏁 Script executed:

set -eu
printf '%s\n' '--- submodule metadata ---'
if test -f .gitmodules; then nl -ba .gitmodules; else echo '.gitmodules: absent'; fi
printf '%s\n' '--- LibAtrac9 tree entry ---'
git ls-tree ebc067077701cd7c828651e46bea4254f0739c4b 3rdparty/LibAtrac9
printf '%s\n' '--- submodule status ---'
git submodule status -- 3rdparty/LibAtrac9 || true
printf '%s\n' '--- parent tree entries ---'
git ls-tree ebc067077701cd7c828651e46bea4254f0739c4b 3rdparty | sed -n '1,80p'

Repository: KytyPS5/KytyPS5

Length of output: 2371


🌐 Web query:

github shadps4-emu ext-LibAtrac9 ec8899dadf393f655f2871a94e0fe4b3d6220c9a Atrac9InitDecoder ChannelConfigs

💡 Result:

I can’t confirm what you’re asking from the search results: they don’t expose the source at commit `ec8899dadf393f655f2871a94e0fe4b3d6220c9a` or establish how `Atrac9InitDecoder` handles `ChannelConfigs`.

The closest relevant source shows a separate ATRAC9 integration calling `Atrac9InitDecoder` with a pointer to a 32-bit config value, but it is **not** the specified repository or commit, so it can’t verify that commit’s behavior. ([github.com](https://github.com/Vita3K/Vita3K/blob/master/vita3k/codec/src/atrac9.cpp?utm_source=openai))

If you share the file or code snippet from that commit, I can explain how `ChannelConfigs` relates to decoder initialization.

Citations:

- 1: https://github.com/Vita3K/Vita3K/blob/master/vita3k/codec/src/atrac9.cpp?utm_source=openai

🏁 Script executed:

set -eu
sha=ec8899dadf393f655f2871a94e0fe4b3d6220c9a
api="https://api.github.com/repos/shadps4-emu/ext-LibAtrac9/git/trees/${sha}?recursive=1"
tree=$(curl -fsSL "$api")
printf '%s\n' '--- pinned tree paths ---'
printf '%s\n' "$tree" | python3 -c 'import json,sys; d=json.load(sys.stdin); print("\n".join(x["path"] for x in d.get("tree",[]) if any(k.lower() in x["path"].lower() for k in ("decinit","atrac9","libatrac")))'
printf '%s\n' '--- candidate source excerpts ---'
for path in $(printf '%s\n' "$tree" | python3 -c 'import json,sys; d=json.load(sys.stdin); print("\n".join(x["path"] for x in d.get("tree",[]) if x["path"].endswith("decinit.c") or x["path"].endswith("libatrac9.c") or x["path"].endswith("libatrac9.h"))); do
  printf '\n--- %s ---\n' "$path"
  curl -fsSL "https://raw.githubusercontent.com/shadps4-emu/ext-LibAtrac9/${sha}/${path}" | nl -ba | sed -n '1,280p'
done

Repository: KytyPS5/KytyPS5

Length of output: 604


🏁 Script executed:

set -eu
sha=ec8899dadf393f655f2871a94e0fe4b3d6220c9a
tree=$(curl -fsSL "https://api.github.com/repos/shadps4-emu/ext-LibAtrac9/git/trees/${sha}?recursive=1")
printf '%s\n' '--- pinned tree paths ---'
printf '%s\n' "$tree" | python3 -c 'import json,sys; d=json.load(sys.stdin); print("\n".join(x["path"] for x in d.get("tree",[]) if any(k.lower() in x["path"].lower() for k in ("decinit","atrac9","libatrac"))))'
printf '%s\n' '--- candidate source excerpts ---'
for path in $(printf '%s\n' "$tree" | python3 -c 'import json,sys; d=json.load(sys.stdin); print("\n".join(x["path"] for x in d.get("tree",[]) if x["path"].endswith("decinit.c") or x["path"].endswith("libatrac9.c") or x["path"].endswith("libatrac9.h")))'); do
  printf '\n--- %s ---\n' "$path"
  curl -fsSL "https://raw.githubusercontent.com/shadps4-emu/ext-LibAtrac9/${sha}/${path}" | nl -ba | sed -n '1,280p'
done

Repository: KytyPS5/KytyPS5

Length of output: 11139


🏁 Script executed:

set -eu
sha=ec8899dadf393f655f2871a94e0fe4b3d6220c9a
for path in C/src/tables.h C/src/bit_reader.c C/src/bit_reader.h C/src/structures.h; do
  printf '\n--- %s ---\n' "$path"
  curl -fsSL "https://raw.githubusercontent.com/shadps4-emu/ext-LibAtrac9/${sha}/${path}" | nl -ba | sed -n '1,260p'
done

Repository: KytyPS5/KytyPS5

Length of output: 9226


Validate the channel configuration before Atrac9InitDecoder.

The WAVE config can contain channel indexes 6 or 7. The pinned LibAtrac9 decoder uses this 3-bit value to index its six-entry ChannelConfigs table before this code checks info.channels. Reject indexes above 5 before calling Atrac9InitDecoder.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-16 02:37 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1545#discussion_r4290310424) On `src/graphics/presentation/splashSound.cpp` line 79 (outdated): ```diff @@ -0,0 +1,172 @@ +#include "graphics/presentation/splashSound.h" + +#include <SDL3/SDL.h> + +#include "common/file.h" +#include "common/logging/log.h" + +#include "libatrac9.h" + +#include <algorithm> +#include <array> +#include <cstdint> +#include <cstring> +#include <memory> +#include <mutex> +#include <vector> + +namespace Libs::Graphics { + +namespace { + +constexpr uint8_t ATRAC9_GUID[16] = {0xd2, 0x42, 0xe1, 0x47, 0xba, 0x36, 0x8d, 0x4d, + 0x88, 0xfc, 0x61, 0x65, 0x4f, 0x8c, 0x83, 0x6c}; + +std::mutex g_mutex; +SDL_AudioStream* g_stream = nullptr; +bool g_sdl_inited = false; + +uint32_t ReadLe32(const uint8_t* p) { + return p[0] | (uint32_t {p[1]} << 8u) | (uint32_t {p[2]} << 16u) | (uint32_t {p[3]} << 24u); +} + +uint16_t ReadLe16(const uint8_t* p) { + return static_cast<uint16_t>(p[0] | (p[1] << 8u)); +} + +struct DecodedSound { + std::vector<int16_t> pcm; + int channels = 0; + int rate = 0; +}; + +bool DecodeAt9(const std::vector<uint8_t>& file, DecodedSound& out) { + if (file.size() < 12 || std::memcmp(file.data(), "RIFF", 4) != 0 || + std::memcmp(file.data() + 8, "WAVE", 4) != 0) { + return false; + } + + const uint8_t* fmt = nullptr; + const uint8_t* fact = nullptr; + size_t data_pos = 0; + size_t data_size = 0; + for (size_t pos = 12; pos + 8 <= file.size();) { + const uint8_t* chunk = file.data() + pos; + const size_t size = ReadLe32(chunk + 4); + const size_t body = pos + 8; + if (std::memcmp(chunk, "fmt ", 4) == 0 && size >= 52 && body + size <= file.size()) { + fmt = file.data() + body; + } else if (std::memcmp(chunk, "fact", 4) == 0 && size >= 12 && + body + size <= file.size()) { + fact = file.data() + body; + } else if (std::memcmp(chunk, "data", 4) == 0) { + data_pos = body; + data_size = std::min(size, file.size() - body); + break; + } + pos = body + size + (size & 1u); + } + if (fmt == nullptr || data_pos == 0 || ReadLe16(fmt) != 0xfffe || + std::memcmp(fmt + 24, ATRAC9_GUID, sizeof(ATRAC9_GUID)) != 0) { + return false; + } + + std::unique_ptr<void, decltype(&Atrac9ReleaseHandle)> handle(Atrac9GetHandle(), + Atrac9ReleaseHandle); + Atrac9CodecInfo info {}; + std::array<uint8_t, ATRAC9_CONFIG_DATA_SIZE> config {}; + std::memcpy(config.data(), fmt + 44, config.size()); + if (handle == nullptr || Atrac9InitDecoder(handle.get(), config.data()) != 0 || ``` **🩺 Stability & Availability** | **🟠 Major** | **⚡ Quick win** <details> <summary>🔎 Supported by static analysis</summary> 🏁 Script executed: ```bash set -eu printf '%s\n' '--- changed file at reviewed head ---' git show ebc067077701cd7c828651e46bea4254f0739c4b:src/graphics/presentation/splashSound.cpp | nl -ba | sed -n '1,180p' printf '%s\n' '--- diff from merge base ---' git diff --no-ext-diff --unified=40 3ff6606fcb6c1cae3aa46ef619f14b28efd3705d ebc067077701cd7c828651e46bea4254f0739c4b -- src/graphics/presentation/splashSound.cpp printf '%s\n' '--- LibAtrac9 references and dependency declarations ---' rg -n -F --glob '!build/**' --glob '!dist/**' -e 'Atrac9InitDecoder' -e 'LibAtrac9' -e 'libatrac9' -e 'atrac9' . || test "$?" -eq 1 printf '%s\n' '--- repository file candidates ---' git ls-tree -r --name-only ebc067077701cd7c828651e46bea4254f0739c4b | rg -i 'atrac|submodule|cmake|meson|conan|vcpkg|premake|third.party|dependencies' || true ``` Repository: KytyPS5/KytyPS5 Length of output: 15949 --- 🏁 Script executed: ```bash set -eu printf '%s\n' '--- changed file at reviewed head ---' git show ebc067077701cd7c828651e46bea4254f0739c4b:src/graphics/presentation/splashSound.cpp | nl -ba | sed -n '1,180p' printf '%s\n' '--- diff from merge base ---' git diff --no-ext-diff --unified=40 3ff6606fcb6c1cae3aa46ef619f14b28efd3705d ebc067077701cd7c828651e46bea4254f0739c4b -- src/graphics/presentation/splashSound.cpp printf '%s\n' '--- LibAtrac9 references and dependency declarations ---' rg -n -F --glob '!build/**' --glob '!dist/**' --glob '!node_modules/**' -e 'Atrac9InitDecoder' -e 'LibAtrac9' -e 'libatrac9' -e 'atrac9' . || test "$?" -eq 1 printf '%s\n' '--- repository file candidates ---' git ls-tree -r --name-only ebc067077701cd7c828651e46bea4254f0739c4b | rg -i 'atrac|submodule|cmake|meson|conan|vcpkg|premake|third.party|dependencies' || true ``` Repository: KytyPS5/KytyPS5 Length of output: 15949 --- 🏁 Script executed: ```bash set -eu printf '%s\n' '--- decoder initialization and channel configuration ---' rg -n -F --glob '3rdparty/LibAtrac9/C/src/*' -e 'ChannelConfigs' -e 'Atrac9InitDecoder' -e 'channel_config' -e 'channelConfig' -e 'CHANNEL_CONFIG' . printf '%s\n' '--- relevant source files ---' for f in $(rg -l --glob '3rdparty/LibAtrac9/C/src/*' -e 'ChannelConfigs' -e 'Atrac9InitDecoder' .); do printf '\n--- %s ---\n' "$f" nl -ba "$f" | sed -n '1,260p' done printf '%s\n' '--- build binding ---' nl -ba 3rdparty/CMakeLists.txt | sed -n '175,190p' ``` Repository: KytyPS5/KytyPS5 Length of output: 210 --- 🏁 Script executed: ```bash set -eu printf '%s\n' '--- vendored LibAtrac9 files ---' find 3rdparty/LibAtrac9 -maxdepth 4 -type f -print | sort printf '%s\n' '--- matching decoder sources ---' rg -n -F --hidden --glob '!**/.git/**' -e 'ChannelConfigs' -e 'Atrac9InitDecoder' -e 'channel_config' -e 'channelConfig' -e 'CHANNEL_CONFIG' 3rdparty/LibAtrac9 || test "$?" -eq 1 printf '%s\n' '--- build binding ---' nl -ba 3rdparty/CMakeLists.txt | sed -n '180,187p' ``` Repository: KytyPS5/KytyPS5 Length of output: 565 --- 🏁 Script executed: ```bash set -eu printf '%s\n' '--- submodule metadata ---' if test -f .gitmodules; then nl -ba .gitmodules; else echo '.gitmodules: absent'; fi printf '%s\n' '--- LibAtrac9 tree entry ---' git ls-tree ebc067077701cd7c828651e46bea4254f0739c4b 3rdparty/LibAtrac9 printf '%s\n' '--- submodule status ---' git submodule status -- 3rdparty/LibAtrac9 || true printf '%s\n' '--- parent tree entries ---' git ls-tree ebc067077701cd7c828651e46bea4254f0739c4b 3rdparty | sed -n '1,80p' ``` Repository: KytyPS5/KytyPS5 Length of output: 2371 --- 🌐 Web query: `github shadps4-emu ext-LibAtrac9 ec8899dadf393f655f2871a94e0fe4b3d6220c9a Atrac9InitDecoder ChannelConfigs` 💡 Result: ``` I can’t confirm what you’re asking from the search results: they don’t expose the source at commit `ec8899dadf393f655f2871a94e0fe4b3d6220c9a` or establish how `Atrac9InitDecoder` handles `ChannelConfigs`. The closest relevant source shows a separate ATRAC9 integration calling `Atrac9InitDecoder` with a pointer to a 32-bit config value, but it is **not** the specified repository or commit, so it can’t verify that commit’s behavior. ([github.com](https://github.com/Vita3K/Vita3K/blob/master/vita3k/codec/src/atrac9.cpp?utm_source=openai)) If you share the file or code snippet from that commit, I can explain how `ChannelConfigs` relates to decoder initialization. Citations: - 1: https://github.com/Vita3K/Vita3K/blob/master/vita3k/codec/src/atrac9.cpp?utm_source=openai ``` --- 🏁 Script executed: ```bash set -eu sha=ec8899dadf393f655f2871a94e0fe4b3d6220c9a api="https://api.github.com/repos/shadps4-emu/ext-LibAtrac9/git/trees/${sha}?recursive=1" tree=$(curl -fsSL "$api") printf '%s\n' '--- pinned tree paths ---' printf '%s\n' "$tree" | python3 -c 'import json,sys; d=json.load(sys.stdin); print("\n".join(x["path"] for x in d.get("tree",[]) if any(k.lower() in x["path"].lower() for k in ("decinit","atrac9","libatrac")))' printf '%s\n' '--- candidate source excerpts ---' for path in $(printf '%s\n' "$tree" | python3 -c 'import json,sys; d=json.load(sys.stdin); print("\n".join(x["path"] for x in d.get("tree",[]) if x["path"].endswith("decinit.c") or x["path"].endswith("libatrac9.c") or x["path"].endswith("libatrac9.h"))); do printf '\n--- %s ---\n' "$path" curl -fsSL "https://raw.githubusercontent.com/shadps4-emu/ext-LibAtrac9/${sha}/${path}" | nl -ba | sed -n '1,280p' done ``` Repository: KytyPS5/KytyPS5 Length of output: 604 --- 🏁 Script executed: ```bash set -eu sha=ec8899dadf393f655f2871a94e0fe4b3d6220c9a tree=$(curl -fsSL "https://api.github.com/repos/shadps4-emu/ext-LibAtrac9/git/trees/${sha}?recursive=1") printf '%s\n' '--- pinned tree paths ---' printf '%s\n' "$tree" | python3 -c 'import json,sys; d=json.load(sys.stdin); print("\n".join(x["path"] for x in d.get("tree",[]) if any(k.lower() in x["path"].lower() for k in ("decinit","atrac9","libatrac"))))' printf '%s\n' '--- candidate source excerpts ---' for path in $(printf '%s\n' "$tree" | python3 -c 'import json,sys; d=json.load(sys.stdin); print("\n".join(x["path"] for x in d.get("tree",[]) if x["path"].endswith("decinit.c") or x["path"].endswith("libatrac9.c") or x["path"].endswith("libatrac9.h")))'); do printf '\n--- %s ---\n' "$path" curl -fsSL "https://raw.githubusercontent.com/shadps4-emu/ext-LibAtrac9/${sha}/${path}" | nl -ba | sed -n '1,280p' done ``` Repository: KytyPS5/KytyPS5 Length of output: 11139 --- 🏁 Script executed: ```bash set -eu sha=ec8899dadf393f655f2871a94e0fe4b3d6220c9a for path in C/src/tables.h C/src/bit_reader.c C/src/bit_reader.h C/src/structures.h; do printf '\n--- %s ---\n' "$path" curl -fsSL "https://raw.githubusercontent.com/shadps4-emu/ext-LibAtrac9/${sha}/${path}" | nl -ba | sed -n '1,260p' done ``` Repository: KytyPS5/KytyPS5 Length of output: 9226 --- </details> **Validate the channel configuration before `Atrac9InitDecoder`.** The WAVE config can contain channel indexes 6 or 7. The pinned LibAtrac9 decoder uses this 3-bit value to index its six-entry `ChannelConfigs` table before this code checks `info.channels`. Reject indexes above 5 before calling `Atrac9InitDecoder`. <!-- fingerprinting:phantom:poseidon:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:31608f9d197aefb5a14a0e0f --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-16 02:37 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: 4105d4b8-27fe-4d59-b74c-43a49b6aa913
📥 Commits

Reviewing files that changed from the base of the PR and between 3ff6606fcb and ebc067077701cd7c828651e46bea4254f0739c4b.

📒 Files selected for processing: 3
  • src/graphics/presentation/splashSound.cpp
  • src/graphics/presentation/splashSound.h
  • src/graphics/presentation/systemOverlay.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-16 02:37 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1545#pullrequestreview-5542366085) · **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**: `4105d4b8-27fe-4d59-b74c-43a49b6aa913` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 3ff6606fcb6c1cae3aa46ef619f14b28efd3705d and ebc067077701cd7c828651e46bea4254f0739c4b. </details> <details> <summary>📒 Files selected for processing: 3</summary> * `src/graphics/presentation/splashSound.cpp` * `src/graphics/presentation/splashSound.h` * `src/graphics/presentation/systemOverlay.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 --> <!-- coderabbit-review-publication v1 publication=95261a0c-c371-499e-8862-7409b7645ea2 attempt=a745dc24-326c-49f3-b215-845054f64cc9 batch=1/1 -->
Author
Owner

@⁠Nmzik on GitHub · 2026-10-16 13:58 UTC · original

@⁠Pipe530 I ran a few tests and it sounds a bit weird on the splash screen since its only displayed for 1/2 seconds causing the audio to cut off. So I moved it to the launcher where it plays when the user selects a title

**@⁠Nmzik** on GitHub · 2026-10-16 13:58 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1545#issuecomment-6217118986) @⁠Pipe530 I ran a few tests and it sounds a bit weird on the splash screen since its only displayed for 1/2 seconds causing the audio to cut off. So I moved it to the launcher where it plays when the user selects a title
Author
Owner

@⁠Pipe530 on GitHub · 2026-10-16 14:29 UTC · original · edited 2026-10-16 16:54 UTC

@⁠Pipe530 I ran a few tests and it sounds a bit weird on the splash screen since its only displayed for 1/2 seconds causing the audio to cut off. So I moved it to the launcher where it plays when the user selects a title

@⁠Nmzik
Can you consider then adding a minimum splash screen time so the sound has the time to play fully when you run the game? In my test the splash screens are displayed for like 7 seconds when running the game,maybe because of my specs.

**@⁠Pipe530** on GitHub · 2026-10-16 14:29 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1545#issuecomment-6217701395) · edited 2026-10-16 16:54 UTC > @⁠Pipe530 I ran a few tests and it sounds a bit weird on the splash screen since its only displayed for 1/2 seconds causing the audio to cut off. So I moved it to the launcher where it plays when the user selects a title @⁠Nmzik Can you consider then adding a minimum splash screen time so the sound has the time to play fully when you run the game? In my test the splash screens are displayed for like 7 seconds when running the game,maybe because of my specs.
Author
Owner

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

@⁠Pipe530 splash screen is closed by the game itself, not Kyty, so adding a timer would be kinda "hacky". Each game decides when to close its splash screen, not us :)

**@⁠Nmzik** on GitHub · 2026-10-17 02:47 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1545#issuecomment-6228679206) @⁠Pipe530 splash screen is closed by the game itself, not Kyty, so adding a timer would be kinda "hacky". Each game decides when to close its splash screen, not us :)
This discussion has been locked. Commenting is limited to contributors.
No description provided.