Update for SDL3
This commit is contained in:
parent
2533f7ac05
commit
19308135c3
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* audio_sdl.cpp - Audio support, SDL implementation
|
||||
* audio_sdl3.cpp - Audio support, SDL implementation
|
||||
*
|
||||
* Basilisk II (C) 1997-2008 Christian Bauer
|
||||
*
|
||||
|
@ -33,6 +33,7 @@
|
|||
|
||||
#if SDL_VERSION_ATLEAST(3, 0, 0)
|
||||
#include <SDL_init.h>
|
||||
#include <queue>
|
||||
|
||||
#define DEBUG 0
|
||||
#include "debug.h"
|
||||
|
@ -57,10 +58,11 @@ static int speaker_volume = MAC_MAX_VOLUME;
|
|||
static bool main_mute = false;
|
||||
static bool speaker_mute = false;
|
||||
|
||||
volatile static bool playing_startup, exit_startup;
|
||||
SDL_AudioSpec audio_spec;
|
||||
|
||||
// Prototypes
|
||||
static void SDLCALL stream_func(void *arg, SDL_AudioStream *stream, int stream_len);
|
||||
static void SDLCALL stream_func(void *arg, SDL_AudioStream *stream, int additional_amount, int total_amount);
|
||||
static int get_audio_volume();
|
||||
|
||||
|
||||
|
@ -161,6 +163,10 @@ void AudioInit(void)
|
|||
|
||||
static void close_audio(void)
|
||||
{
|
||||
exit_startup = true;
|
||||
while (playing_startup)
|
||||
SDL_Delay(10);
|
||||
exit_startup = false;
|
||||
// Close audio device
|
||||
SDL_QuitSubSystem(SDL_INIT_AUDIO);
|
||||
audio_open = false;
|
||||
|
@ -198,8 +204,8 @@ void audio_exit_stream()
|
|||
/*
|
||||
* Streaming function
|
||||
*/
|
||||
#include <queue>
|
||||
static void SDLCALL stream_func(void *, SDL_AudioStream *stream, int stream_len)
|
||||
|
||||
static void SDLCALL stream_func(void *, SDL_AudioStream *stream, int stream_len, int /*total_amount*/)
|
||||
{
|
||||
static std::queue<uint8> q;
|
||||
if (AudioStatus.num_sources) {
|
||||
|
@ -358,23 +364,25 @@ static int play_startup(void *arg) {
|
|||
SDL_AudioSpec wav_spec;
|
||||
Uint8 *wav_buffer;
|
||||
Uint32 wav_length;
|
||||
if (!SDL_LoadWAV("startup.wav", &wav_spec, &wav_buffer, &wav_length)) {
|
||||
if (!playing_startup && !SDL_LoadWAV("startup.wav", &wav_spec, &wav_buffer, &wav_length)) {
|
||||
SDL_AudioStream *stream = SDL_OpenAudioDeviceStream(SDL_AUDIO_DEVICE_DEFAULT_OUTPUT, &wav_spec, NULL, NULL);
|
||||
if (stream) {
|
||||
SDL_ResumeAudioDevice(SDL_GetAudioStreamDevice(stream));
|
||||
SDL_PutAudioStreamData(stream, wav_buffer, wav_length);
|
||||
while (SDL_GetAudioStreamAvailable(stream)) SDL_Delay(10);
|
||||
SDL_Delay(500);
|
||||
playing_startup = true;
|
||||
while (!exit_startup && SDL_GetAudioStreamAvailable(stream)) SDL_Delay(10);
|
||||
if (!exit_startup) SDL_Delay(500);
|
||||
SDL_DestroyAudioStream(stream);
|
||||
}
|
||||
else printf("play_startup: Audio driver failed to initialize\n");
|
||||
SDL_free(wav_buffer);
|
||||
playing_startup = false;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void PlayStartupSound() {
|
||||
SDL_CreateThread(play_startup, "", NULL);
|
||||
SDL_CreateThread(play_startup, "play_startup", NULL);
|
||||
}
|
||||
|
||||
#endif // SDL_VERSION_ATLEAST
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* video_sdl2.cpp - Video/graphics emulation, SDL 2.x specific stuff
|
||||
* video_sdl3.cpp - Video/graphics emulation, SDL 3.x specific stuff
|
||||
*
|
||||
* Basilisk II (C) 1997-2008 Christian Bauer
|
||||
*
|
||||
|
@ -50,7 +50,7 @@
|
|||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#ifdef __MACOSX__
|
||||
#ifdef __MACOS__
|
||||
#include "utils_macosx.h"
|
||||
#endif
|
||||
|
||||
|
@ -96,7 +96,7 @@ static int display_type = DISPLAY_WINDOW; // See enum above
|
|||
#endif
|
||||
|
||||
// Constants
|
||||
#if defined(__MACOSX__) || defined(WIN32)
|
||||
#if defined(__MACOS__) || defined(WIN32)
|
||||
const char KEYCODE_FILE_NAME[] = "keycodes";
|
||||
const char KEYCODE_FILE_NAME2[] = "BasiliskII_keycodes";
|
||||
#else
|
||||
|
@ -742,7 +742,7 @@ static SDL_Surface * init_sdl_video(int width, int height, int depth, Uint32 fla
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef __MACOSX__
|
||||
#ifdef __MACOS__
|
||||
if (MetalIsAvailable()) window_flags |= SDL_WINDOW_METAL;
|
||||
#endif
|
||||
|
||||
|
@ -777,7 +777,7 @@ static SDL_Surface * init_sdl_video(int width, int height, int depth, Uint32 fla
|
|||
else {
|
||||
#ifdef WIN32
|
||||
SDL_SetHint(SDL_HINT_RENDER_DRIVER, "software");
|
||||
#elif defined(__MACOSX__)
|
||||
#elif defined(__MACOS__)
|
||||
SDL_SetHint(SDL_HINT_RENDER_DRIVER, window_flags & SDL_WINDOW_METAL ? "metal" : "opengl");
|
||||
#else
|
||||
SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl");
|
||||
|
@ -1672,14 +1672,14 @@ static void do_toggle_fullscreen(void)
|
|||
int m = get_mag_rate();
|
||||
SDL_SetWindowSize(sdl_window, m * VIDEO_MODE_X, m * VIDEO_MODE_Y);
|
||||
//SDL_SetWindowGrab(sdl_window, SDL_FALSE);
|
||||
#ifndef __MACOSX__
|
||||
#ifndef __MACOS__
|
||||
SDL_SetWindowPosition(sdl_window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
|
||||
#endif
|
||||
} else {
|
||||
display_type = DISPLAY_SCREEN;
|
||||
SDL_SetWindowFullscreen(sdl_window, SDL_TRUE);
|
||||
//SDL_SetWindowGrab(sdl_window, SDL_TRUE);
|
||||
#ifdef __MACOSX__
|
||||
#ifdef __MACOS__
|
||||
set_menu_bar_visible_osx(false);
|
||||
#endif
|
||||
}
|
||||
|
@ -1718,7 +1718,7 @@ static void do_toggle_fullscreen(void)
|
|||
|
||||
static bool is_fullscreen(SDL_Window * window)
|
||||
{
|
||||
#ifdef __MACOSX__
|
||||
#ifdef __MACOS__
|
||||
// On OSX, SDL, at least as of 2.0.5 (and possibly beyond), does not always
|
||||
// report changes to fullscreen via the SDL_WINDOW_FULLSCREEN flag.
|
||||
// (Example: https://bugzilla.libsdl.org/show_bug.cgi?id=3766 , which
|
||||
|
|
|
@ -333,7 +333,7 @@ if [[ "x$WANT_SDL" = "xyes" ]]; then
|
|||
if [[ "x$TEMP_WANT_SDL_VERSION_MAJOR" = "x3" ]]; then
|
||||
PKG_CHECK_MODULES([sdl3], [sdl3 >= 3.0], [
|
||||
CXXFLAGS="$CXXFLAGS $sdl3_CFLAGS"
|
||||
CXXFLAGS+=`echo $sdl3_CFLAGS | sed -e 's/\(-I.*include\)/\1\/SDL3/'`
|
||||
CXXFLAGS+=`echo " $sdl3_CFLAGS" | sed -e 's/\(-I.*include\)/\1\/SDL3/'`
|
||||
LIBS="$LIBS $sdl3_LIBS"
|
||||
WANT_SDL_VERSION_MAJOR=3
|
||||
], [
|
||||
|
|
|
@ -29,6 +29,9 @@
|
|||
#ifdef USE_SDL
|
||||
# include <SDL.h>
|
||||
# include <SDL_main.h>
|
||||
#if !SDL_VERSION_ATLEAST(3, 0, 0)
|
||||
#define __MACOS__ __MACOSX__
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef USE_SDL_VIDEO
|
||||
|
@ -43,7 +46,7 @@
|
|||
# include <sys/mman.h>
|
||||
#endif
|
||||
|
||||
#if __MACOSX__
|
||||
#if __MACOS__
|
||||
# include "utils_macosx.h"
|
||||
#endif
|
||||
|
||||
|
@ -568,7 +571,7 @@ int main(int argc, char **argv)
|
|||
}
|
||||
atexit(SDL_Quit);
|
||||
|
||||
#if __MACOSX__ && SDL_VERSION_ATLEAST(2,0,0)
|
||||
#if __MACOS__ && SDL_VERSION_ATLEAST(2,0,0)
|
||||
// On Mac OS X hosts, SDL2 will create its own menu bar. This is mostly OK,
|
||||
// except that it will also install keyboard shortcuts, such as Command + Q,
|
||||
// which can interfere with keyboard shortcuts in the guest OS.
|
||||
|
@ -692,7 +695,7 @@ int main(int argc, char **argv)
|
|||
ROMBaseMac = Host2MacAddr(ROMBaseHost);
|
||||
#endif
|
||||
|
||||
#if __MACOSX__
|
||||
#if __MACOS__
|
||||
extern void set_current_directory();
|
||||
set_current_directory();
|
||||
#endif
|
||||
|
|
|
@ -549,6 +549,7 @@ CPUSRCS="../uae_cpu/basilisk_glue.cpp ../uae_cpu/memory.cpp ../uae_cpu/newcpu.cp
|
|||
dnl We really want SDL for now
|
||||
if [[ "x$WANT_SDL_VERSION_MAJOR" = "x3" ]]; then
|
||||
SDL_CFLAGS=`pkg-config sdl3 --cflags`
|
||||
SDL_CFLAGS+=`echo " $SDL_CFLAGS" | sed -e 's/\(-I.*include\)/\1\/SDL3/'`
|
||||
SDL_LIBS=`pkg-config sdl3 --libs | sed -e 's/-lSDL3/-lSDL3.dll/'`
|
||||
else
|
||||
SDL_CFLAGS=`sdl2-config --cflags`
|
||||
|
|
|
@ -522,8 +522,11 @@ void close_bincue(void *fh)
|
|||
if (cs && player) {
|
||||
free(cs);
|
||||
#ifdef USE_SDL_AUDIO
|
||||
#if !SDL_VERSION_ATLEAST(3, 0, 0)
|
||||
#define SDL_DestroyAudioStream SDL_FreeAudioStream
|
||||
#endif
|
||||
if (player->stream) // if audiostream has been opened, free it as well
|
||||
free(player->stream);
|
||||
SDL_DestroyAudioStream(player->stream);
|
||||
#endif
|
||||
free(player);
|
||||
}
|
||||
|
|
|
@ -222,7 +222,7 @@ if [[ "x$WANT_SDL" = "xyes" ]]; then
|
|||
if [[ "x$TEMP_WANT_SDL_VERSION_MAJOR" = "x3" ]]; then
|
||||
PKG_CHECK_MODULES([sdl3], [sdl3 >= 3.0], [
|
||||
CXXFLAGS="$CXXFLAGS $sdl3_CFLAGS"
|
||||
CXXFLAGS+=`echo $sdl3_CFLAGS | sed -e 's/\(-I.*include\)/\1\/SDL3/'`
|
||||
CXXFLAGS+=`echo " $sdl3_CFLAGS" | sed -e 's/\(-I.*include\)/\1\/SDL3/'`
|
||||
LIBS="$LIBS $sdl3_LIBS"
|
||||
WANT_SDL_VERSION_MAJOR=3
|
||||
], [
|
||||
|
|
|
@ -278,6 +278,7 @@ CPUSRCS="$CPUSRCS ../dummy/prefs_dummy.cpp"
|
|||
dnl We really want SDL for now
|
||||
if [[ "x$WANT_SDL_VERSION_MAJOR" = "x3" ]]; then
|
||||
SDL_CFLAGS=`pkg-config sdl3 --cflags`
|
||||
SDL_CFLAGS+=`echo " $SDL_CFLAGS" | sed -e 's/\(-I.*include\)/\1\/SDL3/'`
|
||||
SDL_LIBS=`pkg-config sdl3 --libs | sed -e 's/-lSDL3/-lSDL3.dll/'`
|
||||
else
|
||||
SDL_CFLAGS=`sdl2-config --cflags`
|
||||
|
|
Loading…
Reference in New Issue