Skip to content

Commit fa8a5a6

Browse files
committed
Fix audio in libretro Nintendo Switch builds by applying libretro/RetroArch#18459
1 parent 8e39ff7 commit fa8a5a6

2 files changed

Lines changed: 75 additions & 1 deletion

File tree

.github/workflows/autobuild.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1949,14 +1949,23 @@ jobs:
19491949
run: |
19501950
mkdir ~/dist
19511951
mv libretro_libnx/libretro_libnx.a ~
1952+
tag_name=$(curl -s https://api.github.com/repos/libretro/RetroArch/releases/latest -H 'Authorization: Bearer ${{ github.token }}' -H 'X-GitHub-Api-Version: 2022-11-28' | jq -r '.tag_name')
1953+
if [ "$tag_name" = 'v1.22.2' ]
1954+
then
1955+
mv libretro/retroarch-pr18459.patch ~
1956+
fi
19521957
if [ '${{ matrix.type }}' = 'bootstrap' ]
19531958
then
19541959
mv libretro/switch-bootstrap ~
19551960
fi
19561961
cd ~
1957-
git clone https://github.com/libretro/RetroArch retroarch --depth 1 -b $(curl -s https://api.github.com/repos/libretro/RetroArch/releases/latest -H 'Authorization: Bearer ${{ github.token }}' -H 'X-GitHub-Api-Version: 2022-11-28' | jq -r '.tag_name')
1962+
git clone https://github.com/libretro/RetroArch retroarch --depth 1 -b $tag_name
19581963
mv libretro_libnx.a retroarch/
19591964
cd retroarch
1965+
if [ "$tag_name" = 'v1.22.2' ]
1966+
then
1967+
git apply ~/retroarch-pr18459.patch
1968+
fi
19601969
if [ '${{ matrix.type }}' = 'bootstrap' ]
19611970
then
19621971
git apply ~/switch-bootstrap/switch-bootstrap.patch

libretro/retroarch-pr18459.patch

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
From 02ca3ec7b8cd68b2c0ef30c3f48029a2908043d1 Mon Sep 17 00:00:00 2001
2+
From: diekleinekuh <[email protected]>
3+
Date: Sat, 29 Nov 2025 14:34:58 +0100
4+
Subject: [PATCH] Switch: Configure audio drivers to be in blocking mode
5+
initially
6+
7+
---
8+
audio/drivers/switch_audio.c | 2 +-
9+
audio/drivers/switch_libnx_audren_audio.c | 2 +-
10+
audio/drivers/switch_libnx_audren_thread_audio.c | 2 +-
11+
audio/drivers/switch_thread_audio.c | 2 +-
12+
4 files changed, 4 insertions(+), 4 deletions(-)
13+
14+
diff --git a/audio/drivers/switch_audio.c b/audio/drivers/switch_audio.c
15+
index 2db183aa82a6..35346d5c3383 100644
16+
--- a/audio/drivers/switch_audio.c
17+
+++ b/audio/drivers/switch_audio.c
18+
@@ -324,7 +324,7 @@ static void *switch_audio_init(const char *device,
19+
swa->latency = latency;
20+
swa->last_append = svcGetSystemTick();
21+
22+
- swa->blocking = block_frames;
23+
+ swa->blocking = true;
24+
swa->is_paused = true;
25+
26+
RARCH_LOG("[Switch audio] Audio initialized.\n");
27+
diff --git a/audio/drivers/switch_libnx_audren_audio.c b/audio/drivers/switch_libnx_audren_audio.c
28+
index 7d9e9a4b34b8..2a712a5a1971 100644
29+
--- a/audio/drivers/switch_libnx_audren_audio.c
30+
+++ b/audio/drivers/switch_libnx_audren_audio.c
31+
@@ -81,7 +81,7 @@ static void *libnx_audren_audio_init(
32+
real_latency = MAX(5, latency);
33+
RARCH_LOG("[Audren] real_latency is %u.\n", real_latency);
34+
35+
- aud->nonblock = !block_frames;
36+
+ aud->nonblock = false;
37+
aud->buffer_size = (real_latency * sample_rate / 1000);
38+
aud->samples = (aud->buffer_size / num_channels / sizeof(int16_t));
39+
aud->current_size = 0;
40+
diff --git a/audio/drivers/switch_libnx_audren_thread_audio.c b/audio/drivers/switch_libnx_audren_thread_audio.c
41+
index f92b32200bc0..969b100518eb 100644
42+
--- a/audio/drivers/switch_libnx_audren_thread_audio.c
43+
+++ b/audio/drivers/switch_libnx_audren_thread_audio.c
44+
@@ -162,7 +162,7 @@ static void *libnx_audren_thread_audio_init(const char *device, unsigned rate, u
45+
46+
aud->running = true;
47+
aud->paused = false;
48+
- aud->nonblock = !block_frames;
49+
+ aud->nonblock = false;
50+
aud->buffer_size = (real_latency * sample_rate / 1000);
51+
aud->samples = (aud->buffer_size / num_channels / sizeof(int16_t));
52+
53+
diff --git a/audio/drivers/switch_thread_audio.c b/audio/drivers/switch_thread_audio.c
54+
index 927a63b63d6a..6e8310e6f396 100644
55+
--- a/audio/drivers/switch_thread_audio.c
56+
+++ b/audio/drivers/switch_thread_audio.c
57+
@@ -153,7 +153,7 @@ static void *switch_thread_audio_init(const char *device, unsigned rate, unsigne
58+
return NULL;
59+
60+
swa->running = true;
61+
- swa->nonblock = true;
62+
+ swa->nonblock = false;
63+
swa->is_paused = true;
64+
swa->latency = MAX(latency, 8);
65+

0 commit comments

Comments
 (0)