Files
haikuports/media-libs/libsdl/patches/libsdl-1.2.15.patchset
François Revol 46a1381866 sdl: add patch to fetch application signature from resources
This avoids warnings like:
Signature in rsrc doesn't match constructor arg.
(application/x-SDL-executable, application/x-vnd.oricutron)

It also avoid roster messing around with applications it things are the same.
2016-07-11 17:40:38 +02:00

556 lines
18 KiB
Plaintext

From 5a1a0f841aaffdd2d50dd61b9b77f79038293977 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Fri, 22 Nov 2013 23:38:56 +0100
Subject: [PATCH 01/10] Remove Alsa and ESD detection
These will fail on Haiku, and we don't need them anyway.
---
configure.in | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/configure.in b/configure.in
index 08c8e1e..84d9a55 100644
--- a/configure.in
+++ b/configure.in
@@ -361,7 +361,7 @@ CheckALSA()
AC_HELP_STRING([--enable-alsa], [support the ALSA audio API [[default=yes]]]),
, enable_alsa=yes)
if test x$enable_audio = xyes -a x$enable_alsa = xyes; then
- AM_PATH_ALSA(0.9.0, have_alsa=yes, have_alsa=no)
+ have_alsa=no
# Restore all flags from before the ALSA detection runs
CFLAGS="$alsa_save_CFLAGS"
LDFLAGS="$alsa_save_LDFLAGS"
@@ -460,7 +460,7 @@ CheckESD()
AC_HELP_STRING([--enable-esd], [support the Enlightened Sound Daemon [[default=yes]]]),
, enable_esd=yes)
if test x$enable_audio = xyes -a x$enable_esd = xyes; then
- AM_PATH_ESD(0.2.8, have_esd=yes, have_esd=no)
+ have_esd=no
if test x$have_esd = xyes; then
AC_ARG_ENABLE(esd-shared,
AC_HELP_STRING([--enable-esd-shared], [dynamically load ESD audio support [[default=yes]]]),
@@ -2963,3 +2963,4 @@ AC_OUTPUT([
: >build-deps
if test x"$MAKE" = x; then MAKE=make; fi; $MAKE depend
])
+AC_CONFIG_MACRO_DIR([acinclude])
--
2.2.2
From cd6e938bfdbe60b75fb483ae185437e7dabeb440 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Fri, 22 Nov 2013 23:39:26 +0100
Subject: [PATCH 02/10] Fix samples vs bytes issues
This was particularly noticeable in Milkytracker (SDL version) and
Hivelytracker, where all the audio timing relies on the buffer being
played during the right time.
---
src/audio/baudio/SDL_beaudio.cc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/audio/baudio/SDL_beaudio.cc b/src/audio/baudio/SDL_beaudio.cc
index de635f8..7faf571 100644
--- a/src/audio/baudio/SDL_beaudio.cc
+++ b/src/audio/baudio/SDL_beaudio.cc
@@ -199,11 +199,11 @@ int BE_OpenAudio(_THIS, SDL_AudioSpec *spec)
return (-1);
}
- format.buffer_size = spec->samples;
-
/* Calculate the final parameters for this audio specification */
SDL_CalculateAudioSpec(spec);
+ format.buffer_size = spec->samples;
+
/* Subscribe to the audio stream (creates a new thread) */
{ sigset_t omask;
SDL_MaskSignals(&omask);
--
2.2.2
From 9f21694189fca33ec9c63dd647275100bbe77a4b Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Fri, 22 Nov 2013 23:40:12 +0100
Subject: [PATCH 03/10] Various fixes to the video code
* Do not center the window each time it is resized
* Do not reset video mode if we didn't enter fullscreen
* remove annoying debug print
---
src/video/bwindow/SDL_sysvideo.cc | 26 +++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)
diff --git a/src/video/bwindow/SDL_sysvideo.cc b/src/video/bwindow/SDL_sysvideo.cc
index c32b661..a26f18b 100644
--- a/src/video/bwindow/SDL_sysvideo.cc
+++ b/src/video/bwindow/SDL_sysvideo.cc
@@ -406,6 +406,7 @@ static int BE_SetFullScreen(_THIS, SDL_Surface *screen, int fullscreen)
{
// printf("SetFullScreen(%d)\n", fullscreen);
BScreen bscreen;
+ static bool firstTime = true;
// SetFullSscreen() does not work as expected if called in a window
// that was never shown. This is probably a bug in the Haiku Game Kit that needs
@@ -425,6 +426,8 @@ static int BE_SetFullScreen(_THIS, SDL_Surface *screen, int fullscreen)
int width = screen->w;
int height = screen->h;
+ bool wasFullScreen = SDL_Win->IsFullScreen();
+
if (fullscreen) {
// Set resolution to the closest available one that matches the
// current SDL resolution.
@@ -444,7 +447,8 @@ static int BE_SetFullScreen(_THIS, SDL_Surface *screen, int fullscreen)
} else {
// Reset to the previous known resolution as we are now in window
// mode.
- bscreen.SetMode(&saved_mode);
+ if(wasFullScreen)
+ bscreen.SetMode(&saved_mode);
}
// Effectivelly set/reset full screen mode. If we are already in
@@ -456,14 +460,6 @@ static int BE_SetFullScreen(_THIS, SDL_Surface *screen, int fullscreen)
// printf("Going windowed\n");
SDL_Win->SetFullScreen(fullscreen);
- // Calculate offsets for centering the window (in window mode) and for
- // dentering the bitmap (in full screen mode).
- BRect bounds = bscreen.Frame();
- bounds.PrintToStream();
- int32 cx = (bounds.IntegerWidth() - width)/2;
- int32 cy = (bounds.IntegerHeight() - height)/2;
-
- // printf ("cx = %d, cy = %d\n", cx, cy);
if (!SDL_Win->IsFullScreen()) {
// printf("Doing not fullscreen stuff.\n");
// We are not in full screen mode, so we want to change the window
@@ -471,10 +467,18 @@ static int BE_SetFullScreen(_THIS, SDL_Surface *screen, int fullscreen)
SDL_Win->ResizeTo(width, height);
// And also center the window and reset the drawing offset.
- SDL_Win->MoveTo(cx, cy);
+ if(firstTime || wasFullScreen) {
+ SDL_Win->CenterOnScreen();
+ firstTime = false;
+ }
SDL_Win->SetXYOffset(0, 0);
} else {
- // printf("Doing fullscreen stuff.");
+ // Calculate offsets for centering the bitmap.
+
+ BRect bounds = bscreen.Frame();
+ int cx = (bounds.Width() - width) / 2;
+ int cy = (bounds.Height() - height) / 2;
+
// Center the bitmap whenever we are in full screen mode.
SDL_Win->SetXYOffset(cx, cy);
}
--
2.2.2
From 16b05a5bb44c626afabe4802637e74eb046968d0 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Sat, 23 Nov 2013 11:59:00 +0100
Subject: [PATCH 04/10] Actually fix the sample vs bytes problem in audio
driver.
---
src/audio/baudio/SDL_beaudio.cc | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/audio/baudio/SDL_beaudio.cc b/src/audio/baudio/SDL_beaudio.cc
index 7faf571..300bf03 100644
--- a/src/audio/baudio/SDL_beaudio.cc
+++ b/src/audio/baudio/SDL_beaudio.cc
@@ -161,25 +161,30 @@ int BE_OpenAudio(_THIS, SDL_AudioSpec *spec)
format.byte_order = B_MEDIA_LITTLE_ENDIAN;
format.frame_rate = (float) spec->freq;
format.channel_count = spec->channels; /* !!! FIXME: support > 2? */
+ int samplesize = 1;
while ((!valid_datatype) && (test_format)) {
valid_datatype = 1;
spec->format = test_format;
switch (test_format) {
case AUDIO_S8:
format.format = media_raw_audio_format::B_AUDIO_CHAR;
+ samplesize = 1;
break;
case AUDIO_U8:
format.format = media_raw_audio_format::B_AUDIO_UCHAR;
+ samplesize = 1;
break;
case AUDIO_S16LSB:
format.format = media_raw_audio_format::B_AUDIO_SHORT;
+ samplesize = 2;
break;
case AUDIO_S16MSB:
format.format = media_raw_audio_format::B_AUDIO_SHORT;
format.byte_order = B_MEDIA_BIG_ENDIAN;
+ samplesize = 2;
break;
default:
@@ -202,7 +207,7 @@ int BE_OpenAudio(_THIS, SDL_AudioSpec *spec)
/* Calculate the final parameters for this audio specification */
SDL_CalculateAudioSpec(spec);
- format.buffer_size = spec->samples;
+ format.buffer_size = spec->samples * spec->channels * samplesize;
/* Subscribe to the audio stream (creates a new thread) */
{ sigset_t omask;
--
2.2.2
From 7707d4eb70a7caf8b6ca6114ea2a0b191c04fd60 Mon Sep 17 00:00:00 2001
From: Chris Roberts <cpr420@gmail.com>
Date: Sun, 22 Dec 2013 18:37:30 -0700
Subject: [PATCH 05/10] Remove Haiku from specialized DECLSPEC definition
---
include/begin_code.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/begin_code.h b/include/begin_code.h
index 27e2f7b..d5e2f1f 100644
--- a/include/begin_code.h
+++ b/include/begin_code.h
@@ -41,7 +41,7 @@
* Some compilers use a special export keyword
*/
#ifndef DECLSPEC
-# if defined(__BEOS__) || defined(__HAIKU__)
+# if defined(__BEOS__)
# if defined(__GNUC__)
# define DECLSPEC
# else
--
2.2.2
From d1f9c6c01ef5bea92c15e4255deede177aba0508 Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@pulkomandy.tk>
Date: Sun, 5 Jan 2014 17:22:10 +0100
Subject: [PATCH 06/10] Change prefix from "be" to "os" for OpenGL includes
Accomodate the new OpenGL kit that doesn't have the "be" symlink.
---
src/video/bwindow/SDL_BWin.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/video/bwindow/SDL_BWin.h b/src/video/bwindow/SDL_BWin.h
index f2b19a2..2cb94ee 100644
--- a/src/video/bwindow/SDL_BWin.h
+++ b/src/video/bwindow/SDL_BWin.h
@@ -31,7 +31,7 @@
#include <be/game/DirectWindow.h>
#if SDL_VIDEO_OPENGL
#include "SDL_opengl.h"
-#include <be/opengl/GLView.h>
+#include <os/opengl/GLView.h>
#endif
#include <support/UTF8.h>
--
2.2.2
From 0023dd96fedd8f29f83578cc6916f1ba31bbb062 Mon Sep 17 00:00:00 2001
From: Jonathan Schleifer <js@webkeks.org>
Date: Fri, 28 Mar 2014 18:04:12 +0100
Subject: [PATCH 07/10] Fix compilation on x86_64
Also cleans up and fixes warnings.
---
src/video/SDL_sysvideo.h | 8 ++++++++
src/video/SDL_video.c | 2 +-
src/video/bwindow/SDL_sysvideo.cc | 22 +++++++++-------------
src/video/bwindow/SDL_sysyuv.cc | 3 ++-
4 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h
index 436450e..b45a8a9 100644
--- a/src/video/SDL_sysvideo.h
+++ b/src/video/SDL_sysvideo.h
@@ -24,6 +24,10 @@
#ifndef _SDL_sysvideo_h
#define _SDL_sysvideo_h
+#if defined(__BEOS__) || defined(__HAIKU__)
+#include <os/kernel/image.h>
+#endif
+
#include "SDL_mouse.h"
#define SDL_PROTOTYPES_ONLY
#include "SDL_syswm.h"
@@ -296,7 +300,11 @@ struct SDL_VideoDevice {
int swap_control;
int driver_loaded;
char driver_path[256];
+#if defined(__BEOS__) || defined(__HAIKU__)
+ image_id dll_handle;
+#else
void* dll_handle;
+#endif
} gl_config;
/* * * */
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index 46285c9..255cafb 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -222,7 +222,7 @@ int SDL_VideoInit (const char *driver_name, Uint32 flags)
/* Set some very sane GL defaults */
video->gl_config.driver_loaded = 0;
- video->gl_config.dll_handle = NULL;
+ video->gl_config.dll_handle = 0;
video->gl_config.red_size = 3;
video->gl_config.green_size = 3;
video->gl_config.blue_size = 2;
diff --git a/src/video/bwindow/SDL_sysvideo.cc b/src/video/bwindow/SDL_sysvideo.cc
index a26f18b..5d4077f 100644
--- a/src/video/bwindow/SDL_sysvideo.cc
+++ b/src/video/bwindow/SDL_sysvideo.cc
@@ -644,17 +644,13 @@ static void BE_NormalUpdate(_THIS, int numrects, SDL_Rect *rects)
int BE_GL_LoadLibrary(_THIS, const char *path)
{
if (path == NULL) {
- if (_this->gl_config.dll_handle == NULL) {
+ if (_this->gl_config.dll_handle == 0) {
image_info info;
int32 cookie = 0;
while (get_next_image_info(0,&cookie,&info) == B_OK) {
void *location = NULL;
-#ifdef __HAIKU__
if (get_image_symbol(info.id,"glBegin",B_SYMBOL_TYPE_ANY,&location) == B_OK) { // This is how it actually works in Haiku
-#else
- if (get_image_symbol((image_id)cookie,"glBegin",B_SYMBOL_TYPE_ANY,&location) == B_OK) { // I don't know if that *did* work in BeOS
-#endif
- _this->gl_config.dll_handle = (void*)info.id;
+ _this->gl_config.dll_handle = info.id;
_this->gl_config.driver_loaded = 1;
SDL_strlcpy(_this->gl_config.driver_path, "libGL.so", SDL_arraysize(_this->gl_config.driver_path));
}
@@ -666,7 +662,7 @@ int BE_GL_LoadLibrary(_THIS, const char *path)
to load BGLView, which should be reloaded from new lib.
So for now just "load" linked libGL.so :(
*/
- if (_this->gl_config.dll_handle == NULL) {
+ if (_this->gl_config.dll_handle == 0) {
return BE_GL_LoadLibrary(_this, NULL);
}
@@ -688,10 +684,10 @@ int BE_GL_LoadLibrary(_THIS, const char *path)
}*/
}
- if (_this->gl_config.dll_handle != NULL) {
+ if (_this->gl_config.dll_handle != 0) {
return 0;
} else {
- _this->gl_config.dll_handle = NULL;
+ _this->gl_config.dll_handle = 0;
_this->gl_config.driver_loaded = 0;
*_this->gl_config.driver_path = '\0';
return -1;
@@ -700,10 +696,10 @@ int BE_GL_LoadLibrary(_THIS, const char *path)
void* BE_GL_GetProcAddress(_THIS, const char *proc)
{
- if (_this->gl_config.dll_handle != NULL) {
+ if (_this->gl_config.dll_handle != 0) {
void *location = NULL;
status_t err;
- if ((err = get_image_symbol((image_id)_this->gl_config.dll_handle, proc, B_SYMBOL_TYPE_ANY, &location)) == B_OK) {
+ if ((err = get_image_symbol(_this->gl_config.dll_handle, proc, B_SYMBOL_TYPE_ANY, &location)) == B_OK) {
return location;
} else {
SDL_SetError("Couldn't find OpenGL symbol");
@@ -835,8 +831,8 @@ void BE_VideoQuit(_THIS)
}
#if SDL_VIDEO_OPENGL
- if (_this->gl_config.dll_handle != NULL)
- unload_add_on((image_id)_this->gl_config.dll_handle);
+ if (_this->gl_config.dll_handle != 0)
+ unload_add_on(_this->gl_config.dll_handle);
#endif
SDL_QuitBeApp();
diff --git a/src/video/bwindow/SDL_sysyuv.cc b/src/video/bwindow/SDL_sysyuv.cc
index 7c71b00..f2fef10 100644
--- a/src/video/bwindow/SDL_sysyuv.cc
+++ b/src/video/bwindow/SDL_sysyuv.cc
@@ -66,7 +66,8 @@ BBitmap * BE_GetOverlayBitmap(BRect bounds, color_space cs) {
uint32 aligned_height = r.source.height_alignment + 1;
if (height % aligned_height > 0) {
fprintf(stderr,"GetOverlayBitmap failed height alignment\n");
- fprintf(stderr,"- height = %lu, aligned_height = %lu\n",height,aligned_height);
+ fprintf(stderr,"- height = %" B_PRIu32 ", "
+ "aligned_height = %" B_PRIu32 "\n", height, aligned_height);
delete bbitmap;
return 0;
}
--
2.2.2
From 67fa278e22614bc0e74c0b94af802272a0604c6f Mon Sep 17 00:00:00 2001
From: Adrien Destugues <pulkomandy@gmail.com>
Date: Mon, 20 Oct 2014 13:33:55 +0200
Subject: [PATCH 08/10] Fix problem with GL viewport
Make sure the window has the correct size before the GL view is created.
Otherwise the view doesn't use the resized window size and things render
in an awfully small area in the corner of the window.
Fixes Dragon Memory, for example (also seen in other games using SDL+GL).
---
src/video/bwindow/SDL_sysvideo.cc | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/video/bwindow/SDL_sysvideo.cc b/src/video/bwindow/SDL_sysvideo.cc
index 5d4077f..7e1bd38 100644
--- a/src/video/bwindow/SDL_sysvideo.cc
+++ b/src/video/bwindow/SDL_sysvideo.cc
@@ -507,6 +507,8 @@ SDL_Surface *BE_SetVideoMode(_THIS, SDL_Surface *current,
BRect bounds;
Uint32 gl_flags = 0;
+ SDL_Win->ResizeTo(width, height);
+
/* Only RGB works on r5 currently */
gl_flags = BGL_RGB;
if (_this->gl_config.double_buffer)
--
2.2.2
From 87943f6278adeb8c2a76995c03ea84d1269b7257 Mon Sep 17 00:00:00 2001
From: Michael Lotz <mmlr@mlotz.ch>
Date: Tue, 27 Oct 2015 21:39:24 +0000
Subject: [PATCH 09/10] Avoid crashing on quit when SDL_Win was never
initialized.
This can happen when an unknown screen mode is detected and video init
fails because of it.
---
src/video/bwindow/SDL_sysvideo.cc | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/video/bwindow/SDL_sysvideo.cc b/src/video/bwindow/SDL_sysvideo.cc
index 7e1bd38..818d1a0 100644
--- a/src/video/bwindow/SDL_sysvideo.cc
+++ b/src/video/bwindow/SDL_sysvideo.cc
@@ -807,8 +807,10 @@ void BE_VideoQuit(_THIS)
{
int i, j;
- SDL_Win->Quit();
- SDL_Win = NULL;
+ if ( SDL_Win != NULL ) {
+ SDL_Win->Quit();
+ SDL_Win = NULL;
+ }
if ( SDL_BlankCursor != NULL ) {
BE_FreeWMCursor(_this, SDL_BlankCursor);
--
2.2.2
From 612dcf5da6b7bb799edc7a3f66255791bca465ff Mon Sep 17 00:00:00 2001
From: Michael Lotz <mmlr@mlotz.ch>
Date: Tue, 27 Oct 2015 21:40:36 +0000
Subject: [PATCH 10/10] Add 24 bit color spaces to ColorSpaceToBitsPerPixel().
This allows initializing the native video mode when running with a 24
bit screen color depth.
---
src/video/bwindow/SDL_sysvideo.cc | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/video/bwindow/SDL_sysvideo.cc b/src/video/bwindow/SDL_sysvideo.cc
index 818d1a0..0100f3b 100644
--- a/src/video/bwindow/SDL_sysvideo.cc
+++ b/src/video/bwindow/SDL_sysvideo.cc
@@ -179,6 +179,10 @@ static inline int ColorSpaceToBitsPerPixel(uint32 colorspace)
case B_RGB16_BIG:
bitsperpixel = 16;
break;
+ case B_RGB24:
+ case B_RGB24_BIG:
+ bitsperpixel = 24;
+ break;
case B_RGB32:
case B_RGBA32:
case B_RGB32_BIG:
--
2.2.2
From d7ef3da5dc491445e50eb4f915d00d7d4b722fe4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= <revol@free.fr>
Date: Mon, 11 Jul 2016 15:08:06 +0200
Subject: Try to find correct application signature from app resources
Instead of always hardcoding application/x-SDL-executable.
diff --git a/src/main/beos/SDL_BeApp.cc b/src/main/beos/SDL_BeApp.cc
index 8b79377..65a6dbf 100644
--- a/src/main/beos/SDL_BeApp.cc
+++ b/src/main/beos/SDL_BeApp.cc
@@ -24,8 +24,10 @@
/* Handle the BeApp specific portions of the application */
#include <AppKit.h>
+#include <storage/AppFileInfo.h>
#include <storage/Path.h>
#include <storage/Entry.h>
+#include <storage/File.h>
#include <unistd.h>
#include "SDL_BeApp.h"
@@ -42,7 +44,24 @@ static int StartBeApp(void *unused)
if(!be_app) {
BApplication *App;
- App = new BApplication("application/x-SDL-executable");
+ // default application signature
+ const char *signature = "application/x-SDL-executable";
+ // dig resources for correct signature
+ image_info info;
+ int32 cookie = 0;
+ if (get_next_image_info(B_CURRENT_TEAM, &cookie, &info) == B_OK) {
+ BFile f(info.name, O_RDONLY);
+ if (f.InitCheck() == B_OK) {
+ BAppFileInfo app_info(&f);
+ if (app_info.InitCheck() == B_OK) {
+ char sig[B_MIME_TYPE_LENGTH];
+ if (app_info.GetSignature(sig) == B_OK)
+ signature = strndup(sig, B_MIME_TYPE_LENGTH);
+ }
+ }
+ }
+
+ App = new BApplication(signature);
App->Run();
delete App;
--
2.8.0