Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libcanberra: Fix sound not playing on Colibri iMX8X #894

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
From 86488a7fc209ac08dd92c9d50a77e3330e7aedd9 Mon Sep 17 00:00:00 2001
From: Patrick Zacharias <[email protected]>
Date: Thu, 7 Nov 2024 14:03:29 +0100
Subject: [PATCH] Determine audio buffer size for a time of 500ms

On some hardware like the SGTL5000, not specifying a buffer size
results to EINVAL being returned.

This code sets the buffer time to 500ms and the period time to a fourth of that,
or whatever is nearest to that.
---
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add Upstream-Status field to patch. This is a required field these days.

stdio: ERROR: libcanberra-0.30-r0 do_patch: QA Issue: Missing Upstream-Status in patch
stdio: ERROR: libcanberra-0.30-r0 do_patch: Fatal QA errors were found, failing task.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would Upstream-Status: Pending be appropriate?
The mailing list archive is defunct and no updates to the project have been made on Upstream in 12 years.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

src/alsa.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)

diff --git a/src/alsa.c b/src/alsa.c
index bebcc4a..ac26578 100644
--- a/src/alsa.c
+++ b/src/alsa.c
@@ -258,6 +258,21 @@ static int open_alsa(ca_context *c, struct outstanding *out) {
if ((ret = snd_pcm_hw_params_set_channels(out->pcm, hwparams, ca_sound_file_get_nchannels(out->file))) < 0)
goto finish;

+ unsigned int buffer_time = 0;
+ if ((ret = snd_pcm_hw_params_get_buffer_time_max(hwparams, &buffer_time, 0)) < 0)
+ goto finish;
+
+ // Cap the buffer time to 500ms
+ if (buffer_time > 500000)
+ buffer_time = 500000;
+
+ unsigned int period_time = buffer_time / 4;
+ if ((ret = snd_pcm_hw_params_set_period_time_near(out->pcm, hwparams, &period_time, 0)) < 0)
+ goto finish;
+
+ if ((ret = snd_pcm_hw_params_set_buffer_time_near(out->pcm, hwparams, &buffer_time, 0)) < 0)
+ goto finish;
+
if ((ret = snd_pcm_hw_params(out->pcm, hwparams)) < 0)
goto finish;

1 change: 1 addition & 0 deletions meta-oe/recipes-support/libcanberra/libcanberra_0.30.bb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ SRC_URI = " \
file://0001-build-gtk-and-gtk3-version-for-canberra_gtk_play.patch \
file://0001-gtk-Don-t-assume-all-GdkDisplays-are-GdkX11Displays-.patch \
file://0001-remove-dropped-templates.patch \
file://0001-Determine-audio-buffer-size-for-a-time-of-500ms.patch \
"
SRC_URI[md5sum] = "34cb7e4430afaf6f447c4ebdb9b42072"
SRC_URI[sha256sum] = "c2b671e67e0c288a69fc33dc1b6f1b534d07882c2aceed37004bf48c601afa72"
Expand Down