Ports: Play GLTron audio at 1x speed

Because of sample rate issues, the audio used to be played at 2x speed.
This commit is contained in:
Jelle Raaijmakers 2022-05-09 01:03:48 +02:00 committed by Linus Groh
parent fa77e6b289
commit b5a39f5edb
8 changed files with 44 additions and 6 deletions

View file

@ -1,7 +1,7 @@
From 94e90c97566a73cb03c4837d53a4cddf452e42bf Mon Sep 17 00:00:00 2001
From: Jelle Raaijmakers <jelle@gmta.nl>
Date: Mon, 9 May 2022 00:29:43 +0200
Subject: [PATCH 1/6] Build: Allow `CFLAGS` env var to be set
Subject: [PATCH 1/7] Build: Allow `CFLAGS` env var to be set
---
configure | 2 +-

View file

@ -1,7 +1,7 @@
From dd42cfe84e75619676a06b05f8ebe1c1c2e658c9 Mon Sep 17 00:00:00 2001
From: Jelle Raaijmakers <jelle@gmta.nl>
Date: Mon, 9 May 2022 00:30:04 +0200
Subject: [PATCH 2/6] Build: Replace `-lGL` with `-lgl` to reference our LibGL
Subject: [PATCH 2/7] Build: Replace `-lGL` with `-lgl` to reference our LibGL
---
configure | 4 ++--

View file

@ -1,7 +1,7 @@
From b01d5c00dd0dbe9512857e32ffd0822bdfb8a9e3 Mon Sep 17 00:00:00 2001
From: Jelle Raaijmakers <jelle@gmta.nl>
Date: Mon, 9 May 2022 00:30:54 +0200
Subject: [PATCH 3/6] Build: Remove `-ansi` build argument
Subject: [PATCH 3/7] Build: Remove `-ansi` build argument
---
lua/src/Makefile.in | 2 +-

View file

@ -1,7 +1,7 @@
From 0ec20dfd57ae517d18f06c4c580d346fddd2f926 Mon Sep 17 00:00:00 2001
From: Jelle Raaijmakers <jelle@gmta.nl>
Date: Mon, 9 May 2022 00:32:04 +0200
Subject: [PATCH 4/6] Build: Fix `char*` vs. `const char*` arguments
Subject: [PATCH 4/7] Build: Fix `char*` vs. `const char*` arguments
These arguments are of the wrong constness, which will trip our
compiler.

View file

@ -1,7 +1,7 @@
From d2a56ba682814f2d2451fc0729ada79290de2939 Mon Sep 17 00:00:00 2001
From: Jelle Raaijmakers <jelle@gmta.nl>
Date: Mon, 9 May 2022 00:36:08 +0200
Subject: [PATCH 5/6] Scripting: Fix default keybindings
Subject: [PATCH 5/7] Scripting: Fix default keybindings
These constants referred to the wrong keys.
---

View file

@ -1,7 +1,7 @@
From bcaa941ae5b682862aacff18e44a8a33294ba716 Mon Sep 17 00:00:00 2001
From: Jelle Raaijmakers <jelle@gmta.nl>
Date: Mon, 9 May 2022 00:53:48 +0200
Subject: [PATCH 6/6] SDL: Convert SDL1 to SDL2
Subject: [PATCH 6/7] SDL: Convert SDL1 to SDL2
---
nebu/input/input_system.c | 7 ++++---

View file

@ -0,0 +1,29 @@
From ad6b92ee167f1241de38da428a01c27f410f3d49 Mon Sep 17 00:00:00 2001
From: Jelle Raaijmakers <jelle@gmta.nl>
Date: Mon, 9 May 2022 01:01:47 +0200
Subject: [PATCH 7/7] SDL: Fix 2x audio rate issue
By not passing in an `obtained` struct into `SDL_OpenAudio`, we ask SDL
to perform any sample rate and/or format conversion for us. Previously
GLTron would simply ignore the result in `obtained`, causing the audio
to be played back at 2x speed.
---
src/audio/sound_glue.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/audio/sound_glue.cpp b/src/audio/sound_glue.cpp
index 9753f09..e08b1b3 100644
--- a/src/audio/sound_glue.cpp
+++ b/src/audio/sound_glue.cpp
@@ -170,7 +170,7 @@ extern "C" {
SDL_AudioSpec obtained;
- if(SDL_OpenAudio( spec, &obtained ) != 0) {
+ if(SDL_OpenAudio( spec, nullptr ) != 0) {
fprintf(stderr, "[error] %s\n", SDL_GetError());
sound->SetStatus(Sound::eUninitialized);
} else {
--
2.34.1

View file

@ -33,3 +33,12 @@ These constants referred to the wrong keys.
SDL: Convert SDL1 to SDL2
## `0007-SDL-Fix-2x-audio-rate-issue.patch`
SDL: Fix 2x audio rate issue
By not passing in an `obtained` struct into `SDL_OpenAudio`, we ask SDL
to perform any sample rate and/or format conversion for us. Previously
GLTron would simply ignore the result in `obtained`, causing the audio
to be played back at 2x speed.