summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta-oe/recipes-support/libcanberra/files/0001-Determine-audio-buffer-size-for-a-time-of-500ms.patch42
-rw-r--r--meta-oe/recipes-support/libcanberra/libcanberra_0.30.bb1
2 files changed, 43 insertions, 0 deletions
diff --git a/meta-oe/recipes-support/libcanberra/files/0001-Determine-audio-buffer-size-for-a-time-of-500ms.patch b/meta-oe/recipes-support/libcanberra/files/0001-Determine-audio-buffer-size-for-a-time-of-500ms.patch
new file mode 100644
index 0000000000..b8ad041850
--- /dev/null
+++ b/meta-oe/recipes-support/libcanberra/files/0001-Determine-audio-buffer-size-for-a-time-of-500ms.patch
@@ -0,0 +1,42 @@
1From 86488a7fc209ac08dd92c9d50a77e3330e7aedd9 Mon Sep 17 00:00:00 2001
2From: Patrick Zacharias <1475802+Fighter19@users.noreply.github.com>
3Date: Thu, 7 Nov 2024 14:03:29 +0100
4Subject: [PATCH] Determine audio buffer size for a time of 500ms
5
6On some hardware like the SGTL5000, not specifying a buffer size
7results to EINVAL being returned.
8
9This code sets the buffer time to 500ms and the period time to a fourth of that,
10or whatever is nearest to that.
11
12Upstream-Status: Pending
13---
14 src/alsa.c | 15 +++++++++++++++
15 1 file changed, 15 insertions(+)
16
17diff --git a/src/alsa.c b/src/alsa.c
18index bebcc4a..ac26578 100644
19--- a/src/alsa.c
20+++ b/src/alsa.c
21@@ -258,6 +258,21 @@ static int open_alsa(ca_context *c, struct outstanding *out) {
22 if ((ret = snd_pcm_hw_params_set_channels(out->pcm, hwparams, ca_sound_file_get_nchannels(out->file))) < 0)
23 goto finish;
24
25+ unsigned int buffer_time = 0;
26+ if ((ret = snd_pcm_hw_params_get_buffer_time_max(hwparams, &buffer_time, 0)) < 0)
27+ goto finish;
28+
29+ // Cap the buffer time to 500ms
30+ if (buffer_time > 500000)
31+ buffer_time = 500000;
32+
33+ unsigned int period_time = buffer_time / 4;
34+ if ((ret = snd_pcm_hw_params_set_period_time_near(out->pcm, hwparams, &period_time, 0)) < 0)
35+ goto finish;
36+
37+ if ((ret = snd_pcm_hw_params_set_buffer_time_near(out->pcm, hwparams, &buffer_time, 0)) < 0)
38+ goto finish;
39+
40 if ((ret = snd_pcm_hw_params(out->pcm, hwparams)) < 0)
41 goto finish;
42
diff --git a/meta-oe/recipes-support/libcanberra/libcanberra_0.30.bb b/meta-oe/recipes-support/libcanberra/libcanberra_0.30.bb
index b6165c4fc5..7eac53ae90 100644
--- a/meta-oe/recipes-support/libcanberra/libcanberra_0.30.bb
+++ b/meta-oe/recipes-support/libcanberra/libcanberra_0.30.bb
@@ -13,6 +13,7 @@ SRC_URI = " \
13 file://0001-build-gtk-and-gtk3-version-for-canberra_gtk_play.patch \ 13 file://0001-build-gtk-and-gtk3-version-for-canberra_gtk_play.patch \
14 file://0001-gtk-Don-t-assume-all-GdkDisplays-are-GdkX11Displays-.patch \ 14 file://0001-gtk-Don-t-assume-all-GdkDisplays-are-GdkX11Displays-.patch \
15 file://0001-remove-dropped-templates.patch \ 15 file://0001-remove-dropped-templates.patch \
16 file://0001-Determine-audio-buffer-size-for-a-time-of-500ms.patch \
16" 17"
17SRC_URI[sha256sum] = "c2b671e67e0c288a69fc33dc1b6f1b534d07882c2aceed37004bf48c601afa72" 18SRC_URI[sha256sum] = "c2b671e67e0c288a69fc33dc1b6f1b534d07882c2aceed37004bf48c601afa72"
18 19