SHA256
1
0
forked from pool/SDL2

Accepting request 930160 from home:tiwai:branches:games

- Support "pulse" as an alias for pulseaudio (bsc#1191868,
  bsc#1189778):
  audio-Support-pulse-as-an-alias-for-pulseaudio.patch

OBS-URL: https://build.opensuse.org/request/show/930160
OBS-URL: https://build.opensuse.org/package/show/games/SDL2?expand=0&rev=112
This commit is contained in:
Jan Engelhardt 2021-11-08 12:10:15 +00:00 committed by Git OBS Bridge
parent 3e7aae7db6
commit d844206ec2
3 changed files with 56 additions and 0 deletions

View File

@ -1,3 +1,10 @@
-------------------------------------------------------------------
Mon Nov 8 12:52:16 CET 2021 - tiwai@suse.de
- Support "pulse" as an alias for pulseaudio (bsc#1191868,
bsc#1189778):
audio-Support-pulse-as-an-alias-for-pulseaudio.patch
-------------------------------------------------------------------
Wed Aug 11 15:31:36 UTC 2021 - kh Lai <dlshcbmuipmam@hotmail.com>

View File

@ -34,6 +34,7 @@ Patch1: sdl2-symvers.patch
Patch2: SDL2-endian.patch
Patch3: sdl2-khronos.patch
Patch4: sdl2-fix-wayland-fullscreen.patch
Patch5: audio-Support-pulse-as-an-alias-for-pulseaudio.patch
BuildRequires: cmake
BuildRequires: gcc-c++
BuildRequires: nasm

View File

@ -0,0 +1,48 @@
From 3261f7f6ceaaa435a3aca0252b2f7126eeae1bb2 Mon Sep 17 00:00:00 2001
From: David Gow <david@ingeniumdigital.com>
Date: Thu, 26 Aug 2021 16:15:30 +0800
Subject: [PATCH] audio: Support "pulse" as an alias for "pulseaudio"
Originally, SDL 1.2 used "pulse" as the name for its PulseAudio driver.
While it now supports "pulseaudio" as well for compatibility with SDL
2.0 [1], there are still scripts and distro packages which set
SDL_AUDIODRIVER=pulse [2]. While it's possible to remove this in most
circumstances or replace it with "pulseaudio" or a comma-separated list,
this may still conflict if the environment variable is set globally and
old binary builds of SDL 1.2 (e.g. packaged with older games) are being
used.
To fix this on SDL 2.0, add a hardcoded check for "pulse" as an audio
driver name, and replace it with "pulseaudio". This mimics what SDL 1.2
does (but in reverse). Note that setting driver_attempt{,_len} is safe
here as they're reset correctly based on driver_attempt_end on the next
loop.
[1] https://github.com/libsdl-org/SDL-1.2/commit/d9514097846381cd30fe08df65dbdd48de92a058
[2] https://bugzilla.opensuse.org/show_bug.cgi?id=1189778
---
src/audio/SDL_audio.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c
index 69cddd535369..972207d366f4 100644
--- a/src/audio/SDL_audio.c
+++ b/src/audio/SDL_audio.c
@@ -978,6 +978,14 @@ SDL_AudioInit(const char *driver_name)
const char *driver_attempt_end = SDL_strchr(driver_attempt, ',');
size_t driver_attempt_len = (driver_attempt_end != NULL) ? (driver_attempt_end - driver_attempt)
: SDL_strlen(driver_attempt);
+#if SDL_AUDIO_DRIVER_PULSEAUDIO
+ /* SDL 1.2 uses the name "pulse", so we'll support both. */
+ if (driver_attempt_len == SDL_strlen("pulse") &&
+ (SDL_strncasecmp(driver_attempt, "pulse", driver_attempt_len) == 0)) {
+ driver_attempt = "pulseaudio";
+ driver_attempt_len = SDL_strlen("pulseaudio");
+ }
+#endif
for (i = 0; bootstrap[i]; ++i) {
if ((driver_attempt_len == SDL_strlen(bootstrap[i]->name)) &&
--
2.26.2