mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-08-25 00:03:44 +02:00
Fix Audio.bgm_stop
in libretro builds
Now it actually stops the audio instead of doing nothing. Also, calling `Audio.bgm_stop` was causing a crash in Emscripten due to an exception being thrown internally in OpenAL Soft and C++ exceptions being disabled when targeting Emscripten. Shouldn't happen anymore.
This commit is contained in:
parent
4e05a3cc99
commit
f4659619b0
9 changed files with 68 additions and 37 deletions
11
.github/workflows/autobuild.yml
vendored
11
.github/workflows/autobuild.yml
vendored
|
@ -593,8 +593,10 @@ jobs:
|
||||||
- name: Configure core
|
- name: Configure core
|
||||||
run: |
|
run: |
|
||||||
echo "[binaries]" | tee -a ${{ runner.temp }}/cross.ini
|
echo "[binaries]" | tee -a ${{ runner.temp }}/cross.ini
|
||||||
echo "c = ['clang', '--target=${{ matrix.arch_llvm }}', '-fuse-ld=lld', '--sysroot=${{ steps.sysroot.outputs.root-path }}']" | tee -a ${{ runner.temp }}/cross.ini
|
echo "c = ['clang', '--target=${{ matrix.arch_llvm }}', '--sysroot=${{ steps.sysroot.outputs.root-path }}']" | tee -a ${{ runner.temp }}/cross.ini
|
||||||
echo "cpp = ['clang++', '--target=${{ matrix.arch_llvm }}', '-fuse-ld=lld', '--sysroot=${{ steps.sysroot.outputs.root-path }}']" | tee -a ${{ runner.temp }}/cross.ini
|
echo "c_ld = 'lld'" | tee -a ${{ runner.temp }}/cross.ini
|
||||||
|
echo "cpp = ['clang++', '--target=${{ matrix.arch_llvm }}', '--sysroot=${{ steps.sysroot.outputs.root-path }}']" | tee -a ${{ runner.temp }}/cross.ini
|
||||||
|
echo "cpp_ld = 'lld'" | tee -a ${{ runner.temp }}/cross.ini
|
||||||
echo "ar = 'llvm-ar'" | tee -a ${{ runner.temp }}/cross.ini
|
echo "ar = 'llvm-ar'" | tee -a ${{ runner.temp }}/cross.ini
|
||||||
echo "strip = 'llvm-strip'" | tee -a ${{ runner.temp }}/cross.ini
|
echo "strip = 'llvm-strip'" | tee -a ${{ runner.temp }}/cross.ini
|
||||||
echo "[host_machine]" | tee -a ${{ runner.temp }}/cross.ini
|
echo "[host_machine]" | tee -a ${{ runner.temp }}/cross.ini
|
||||||
|
@ -604,6 +606,11 @@ jobs:
|
||||||
echo "endian = '${{ matrix.endian }}'" | tee -a ${{ runner.temp }}/cross.ini
|
echo "endian = '${{ matrix.endian }}'" | tee -a ${{ runner.temp }}/cross.ini
|
||||||
echo "[properties]" | tee -a ${{ runner.temp }}/cross.ini
|
echo "[properties]" | tee -a ${{ runner.temp }}/cross.ini
|
||||||
echo "sys_root = '${{ steps.sysroot.outputs.root-path }}'" | tee -a ${{ runner.temp }}/cross.ini
|
echo "sys_root = '${{ steps.sysroot.outputs.root-path }}'" | tee -a ${{ runner.temp }}/cross.ini
|
||||||
|
echo "[cmake]" | tee -a ${{ runner.temp }}/cross.ini
|
||||||
|
echo "CMAKE_EXE_LINKER_FLAGS_INIT = '-fuse-ld=lld'" | tee -a ${{ runner.temp }}/cross.ini
|
||||||
|
echo "CMAKE_MODULE_LINKER_FLAGS_INIT = '-fuse-ld=lld'" | tee -a ${{ runner.temp }}/cross.ini
|
||||||
|
echo "CMAKE_SHARED_LINKER_FLAGS_INIT = '-fuse-ld=lld'" | tee -a ${{ runner.temp }}/cross.ini
|
||||||
|
echo "CMAKE_STATIC_LINKER_FLAGS_INIT = '-fuse-ld=lld'" | tee -a ${{ runner.temp }}/cross.ini
|
||||||
echo '--------------------------------------------------------------------------------'
|
echo '--------------------------------------------------------------------------------'
|
||||||
CLICOLOR_FORCE=1 meson setup build --cross-file ${{ runner.temp }}/cross.ini --buildtype release -Db_lto=true -Dretro=true -Dretro_phase1_path=retro/build/retro-phase1
|
CLICOLOR_FORCE=1 meson setup build --cross-file ${{ runner.temp }}/cross.ini --buildtype release -Db_lto=true -Dretro=true -Dretro_phase1_path=retro/build/retro-phase1
|
||||||
|
|
||||||
|
|
13
meson.build
13
meson.build
|
@ -152,8 +152,13 @@ if get_option('retro') == true
|
||||||
'-DSHARED_FLUID',
|
'-DSHARED_FLUID',
|
||||||
]
|
]
|
||||||
if host_endian == 'big'
|
if host_endian == 'big'
|
||||||
|
retro_defines += '-DMKXPZ_BIG_ENDIAN'
|
||||||
retro_defines += '-DWABT_BIG_ENDIAN=1'
|
retro_defines += '-DWABT_BIG_ENDIAN=1'
|
||||||
endif
|
endif
|
||||||
|
if host_system == 'emscripten' or not compilers['cpp'].compiles('struct E {}; int main() { throw E(); }', name: 'check if C++ exceptions are enabled')
|
||||||
|
retro_defines += '-DMKXPZ_NO_EXCEPTIONS'
|
||||||
|
retro_defines += '-DBOOST_NO_EXCEPTIONS'
|
||||||
|
endif
|
||||||
|
|
||||||
retro_link_args = []
|
retro_link_args = []
|
||||||
retro_cppflags = []
|
retro_cppflags = []
|
||||||
|
@ -290,6 +295,14 @@ if get_option('retro') == true
|
||||||
else
|
else
|
||||||
|
|
||||||
global_sources += vcs_tag(command: ['git', 'rev-parse', '--short', 'HEAD'], fallback: 'unknown', input: 'src/git-hash.h.in', output: 'git-hash.h', replace_string: '@MKXPZ_GIT_HASH@')
|
global_sources += vcs_tag(command: ['git', 'rev-parse', '--short', 'HEAD'], fallback: 'unknown', input: 'src/git-hash.h.in', output: 'git-hash.h', replace_string: '@MKXPZ_GIT_HASH@')
|
||||||
|
if host_endian == 'big'
|
||||||
|
global_args += '-DMKXPZ_BIG_ENDIAN'
|
||||||
|
global_args += '-DWABT_BIG_ENDIAN=1'
|
||||||
|
endif
|
||||||
|
if host_system == 'emscripten' or not compilers['cpp'].compiles('struct E {}; int main() { throw E(); }', name: 'check if C++ exceptions are enabled')
|
||||||
|
retro_defines += '-DMKXPZ_NO_EXCEPTIONS'
|
||||||
|
retro_defines += '-DBOOST_NO_EXCEPTIONS'
|
||||||
|
endif
|
||||||
|
|
||||||
xxd = find_program('xxd', native: true)
|
xxd = find_program('xxd', native: true)
|
||||||
|
|
||||||
|
|
|
@ -22,8 +22,8 @@
|
||||||
#ifndef ALUTIL_H
|
#ifndef ALUTIL_H
|
||||||
#define ALUTIL_H
|
#define ALUTIL_H
|
||||||
|
|
||||||
#include <AL/al.h>
|
#include <al.h>
|
||||||
#include <AL/alext.h>
|
#include <alext.h>
|
||||||
|
|
||||||
#ifdef MKXPZ_RETRO
|
#ifdef MKXPZ_RETRO
|
||||||
# include <memory>
|
# include <memory>
|
||||||
|
|
|
@ -31,9 +31,11 @@
|
||||||
#include "sdl-util.h"
|
#include "sdl-util.h"
|
||||||
#include "debugwriter.h"
|
#include "debugwriter.h"
|
||||||
|
|
||||||
#include <SDL_mutex.h>
|
#ifndef MKXPZ_RETRO
|
||||||
#include <SDL_thread.h>
|
# include <SDL_mutex.h>
|
||||||
#include <SDL_timer.h>
|
# include <SDL_thread.h>
|
||||||
|
# include <SDL_timer.h>
|
||||||
|
#endif // MKXPZ_RETRO
|
||||||
|
|
||||||
ALStream::ALStream(LoopMode loopMode,
|
ALStream::ALStream(LoopMode loopMode,
|
||||||
const std::string &threadId)
|
const std::string &threadId)
|
||||||
|
@ -41,7 +43,10 @@ ALStream::ALStream(LoopMode loopMode,
|
||||||
state(Closed),
|
state(Closed),
|
||||||
source(0),
|
source(0),
|
||||||
#ifdef MKXPZ_RETRO
|
#ifdef MKXPZ_RETRO
|
||||||
|
streamInited(false),
|
||||||
sourceExhausted(false),
|
sourceExhausted(false),
|
||||||
|
threadTermReq(false),
|
||||||
|
needsRewind(false),
|
||||||
#else
|
#else
|
||||||
thread(0),
|
thread(0),
|
||||||
#endif // MKXPZ_RETRO
|
#endif // MKXPZ_RETRO
|
||||||
|
@ -308,7 +313,9 @@ void ALStream::openSource(const std::string &filename)
|
||||||
|
|
||||||
void ALStream::stopStream()
|
void ALStream::stopStream()
|
||||||
{
|
{
|
||||||
#ifndef MKXPZ_RETRO
|
#ifdef MKXPZ_RETRO
|
||||||
|
threadTermReq = true;
|
||||||
|
#else
|
||||||
threadTermReq.set();
|
threadTermReq.set();
|
||||||
|
|
||||||
if (thread)
|
if (thread)
|
||||||
|
@ -331,8 +338,12 @@ void ALStream::startStream(double offset)
|
||||||
{
|
{
|
||||||
AL::Source::clearQueue(alSrc);
|
AL::Source::clearQueue(alSrc);
|
||||||
|
|
||||||
#ifndef MKXPZ_RETRO
|
|
||||||
preemptPause = false;
|
preemptPause = false;
|
||||||
|
#ifdef MKXPZ_RETRO
|
||||||
|
streamInited = false;
|
||||||
|
sourceExhausted = false;
|
||||||
|
threadTermReq = false;
|
||||||
|
#else
|
||||||
streamInited.clear();
|
streamInited.clear();
|
||||||
sourceExhausted.clear();
|
sourceExhausted.clear();
|
||||||
threadTermReq.clear();
|
threadTermReq.clear();
|
||||||
|
@ -389,13 +400,11 @@ void ALStream::checkStopped()
|
||||||
if (state != Playing)
|
if (state != Playing)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#ifndef MKXPZ_RETRO
|
|
||||||
/* If streaming thread hasn't queued up
|
/* If streaming thread hasn't queued up
|
||||||
* buffers yet there's not point in querying
|
* buffers yet there's not point in querying
|
||||||
* the AL source */
|
* the AL source */
|
||||||
if (!streamInited)
|
if (!streamInited)
|
||||||
return;
|
return;
|
||||||
#endif // MKXPZ_RETRO
|
|
||||||
|
|
||||||
/* If alSrc isn't playing, but we haven't
|
/* If alSrc isn't playing, but we haven't
|
||||||
* exhausted the data source yet, we're just
|
* exhausted the data source yet, we're just
|
||||||
|
@ -414,15 +423,13 @@ void ALStream::renderInit() {
|
||||||
bool firstBuffer = true;
|
bool firstBuffer = true;
|
||||||
ALDataSource::Status status;
|
ALDataSource::Status status;
|
||||||
|
|
||||||
//if (needsRewind)
|
if (needsRewind)
|
||||||
source->seekToOffset(startOffset);
|
source->seekToOffset(startOffset);
|
||||||
|
|
||||||
for (int i = 0; i < STREAM_BUFS; ++i)
|
for (int i = 0; i < STREAM_BUFS; ++i)
|
||||||
{
|
{
|
||||||
#ifndef MKXPZ_RETRO
|
|
||||||
if (threadTermReq)
|
if (threadTermReq)
|
||||||
return;
|
return;
|
||||||
#endif
|
|
||||||
|
|
||||||
AL::Buffer::ID buf = alBuf[i];
|
AL::Buffer::ID buf = alBuf[i];
|
||||||
|
|
||||||
|
@ -438,15 +445,15 @@ void ALStream::renderInit() {
|
||||||
resumeStream();
|
resumeStream();
|
||||||
|
|
||||||
firstBuffer = false;
|
firstBuffer = false;
|
||||||
#ifndef MKXPZ_RETRO
|
#ifdef MKXPZ_RETRO
|
||||||
|
streamInited = true;
|
||||||
|
#else
|
||||||
streamInited.set();
|
streamInited.set();
|
||||||
#endif
|
#endif // MKXPZ_RETRO
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef MKXPZ_RETRO
|
|
||||||
if (threadTermReq)
|
if (threadTermReq)
|
||||||
return;
|
return;
|
||||||
#endif
|
|
||||||
|
|
||||||
if (status == ALDataSource::EndOfStream)
|
if (status == ALDataSource::EndOfStream)
|
||||||
{
|
{
|
||||||
|
@ -454,7 +461,7 @@ void ALStream::renderInit() {
|
||||||
sourceExhausted = true;
|
sourceExhausted = true;
|
||||||
#else
|
#else
|
||||||
sourceExhausted.set();
|
sourceExhausted.set();
|
||||||
#endif
|
#endif // MKXPZ_RETRO
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -465,16 +472,24 @@ void ALStream::render() {
|
||||||
|
|
||||||
while (procBufs--)
|
while (procBufs--)
|
||||||
{
|
{
|
||||||
#ifndef MKXPZ_RETRO
|
|
||||||
if (threadTermReq)
|
if (threadTermReq)
|
||||||
break;
|
break;
|
||||||
#endif
|
|
||||||
|
|
||||||
AL::Buffer::ID buf = AL::Source::unqueueBuffer(alSrc);
|
AL::Buffer::ID buf = AL::Source::unqueueBuffer(alSrc);
|
||||||
|
|
||||||
|
#ifndef MKXPZ_NO_EXCEPTIONS // `unqueueBuffer` will abort on error if C++ exceptions are disabled so we only need to check if `buf == AL::Buffer::ID(0)` if C++ exceptions are enabled
|
||||||
|
# ifdef MKXPZ_RETRO
|
||||||
|
if (buf == AL::Buffer::ID(0))
|
||||||
|
{
|
||||||
|
mkxp_retro::log_printf(RETRO_LOG_ERROR, "Error unqueueing OpenAL buffer\n");
|
||||||
|
std::abort();
|
||||||
|
}
|
||||||
|
# else
|
||||||
/* If something went wrong, try again later */
|
/* If something went wrong, try again later */
|
||||||
if (buf == AL::Buffer::ID(0))
|
if (buf == AL::Buffer::ID(0))
|
||||||
break;
|
break;
|
||||||
|
# endif // MKXPZ_RETRO
|
||||||
|
#endif // MKXPZ_NO_EXCEPTIONS
|
||||||
|
|
||||||
if (buf == lastBuf)
|
if (buf == lastBuf)
|
||||||
{
|
{
|
||||||
|
@ -506,7 +521,7 @@ void ALStream::render() {
|
||||||
sourceExhausted = true;
|
sourceExhausted = true;
|
||||||
#else
|
#else
|
||||||
sourceExhausted.set();
|
sourceExhausted.set();
|
||||||
#endif
|
#endif // MKXPZ_RETRO
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -529,7 +544,7 @@ void ALStream::render() {
|
||||||
sourceExhausted = true;
|
sourceExhausted = true;
|
||||||
#else
|
#else
|
||||||
sourceExhausted.set();
|
sourceExhausted.set();
|
||||||
#endif
|
#endif // MKXPZ_RETRO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,10 @@ struct ALStream
|
||||||
ALDataSource *source;
|
ALDataSource *source;
|
||||||
|
|
||||||
#ifdef MKXPZ_RETRO
|
#ifdef MKXPZ_RETRO
|
||||||
|
bool streamInited;
|
||||||
bool sourceExhausted;
|
bool sourceExhausted;
|
||||||
|
bool threadTermReq;
|
||||||
|
bool needsRewind;
|
||||||
#else
|
#else
|
||||||
SDL_Thread *thread;
|
SDL_Thread *thread;
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,8 @@
|
||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
#include <AL/alc.h>
|
#include <alc.h>
|
||||||
#include <AL/alext.h>
|
#include <alext.h>
|
||||||
#include <fluidlite.h>
|
#include <fluidlite.h>
|
||||||
#include <fluidsynth_priv.h>
|
#include <fluidsynth_priv.h>
|
||||||
#include "git-hash.h"
|
#include "git-hash.h"
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
#include "keybindings.h"
|
#include "keybindings.h"
|
||||||
|
|
||||||
#ifdef MKXPZ_RETRO
|
#ifdef MKXPZ_RETRO
|
||||||
# include <AL/alc.h>
|
# include <alc.h>
|
||||||
#else
|
#else
|
||||||
typedef struct MKXPZ_ALCDEVICE ALCdevice;
|
typedef struct MKXPZ_ALCDEVICE ALCdevice;
|
||||||
#endif // MKXPZ_RETRO
|
#endif // MKXPZ_RETRO
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#include "icon.png.xxd"
|
#include "icon.png.xxd"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <AL/alc.h>
|
#include <alc.h>
|
||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <SDL_image.h>
|
#include <SDL_image.h>
|
||||||
|
|
|
@ -25,16 +25,9 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#ifdef MKXPZ_RETRO
|
#ifdef MKXPZ_BIG_ENDIAN
|
||||||
# if WABT_BIG_ENDIAN
|
# error "Non little endian systems not supported"
|
||||||
# error "Non little endian systems not supported"
|
#endif // MKXPZ_BIG_ENDIAN
|
||||||
# endif
|
|
||||||
#else
|
|
||||||
# include <SDL_endian.h>
|
|
||||||
# if SDL_BYTEORDER != SDL_LIL_ENDIAN
|
|
||||||
# error "Non little endian systems not supported"
|
|
||||||
# endif
|
|
||||||
#endif // MKXPZ_RETRO
|
|
||||||
|
|
||||||
static inline int32_t
|
static inline int32_t
|
||||||
readInt32(const char **dataP)
|
readInt32(const char **dataP)
|
||||||
|
|
Loading…
Add table
Reference in a new issue