mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-08-24 15:53:45 +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
|
||||
run: |
|
||||
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 "cpp = ['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 "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 "strip = 'llvm-strip'" | 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 "[properties]" | 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 '--------------------------------------------------------------------------------'
|
||||
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',
|
||||
]
|
||||
if host_endian == 'big'
|
||||
retro_defines += '-DMKXPZ_BIG_ENDIAN'
|
||||
retro_defines += '-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
|
||||
|
||||
retro_link_args = []
|
||||
retro_cppflags = []
|
||||
|
@ -290,6 +295,14 @@ if get_option('retro') == true
|
|||
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@')
|
||||
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)
|
||||
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
#ifndef ALUTIL_H
|
||||
#define ALUTIL_H
|
||||
|
||||
#include <AL/al.h>
|
||||
#include <AL/alext.h>
|
||||
#include <al.h>
|
||||
#include <alext.h>
|
||||
|
||||
#ifdef MKXPZ_RETRO
|
||||
# include <memory>
|
||||
|
|
|
@ -31,9 +31,11 @@
|
|||
#include "sdl-util.h"
|
||||
#include "debugwriter.h"
|
||||
|
||||
#ifndef MKXPZ_RETRO
|
||||
# include <SDL_mutex.h>
|
||||
# include <SDL_thread.h>
|
||||
# include <SDL_timer.h>
|
||||
#endif // MKXPZ_RETRO
|
||||
|
||||
ALStream::ALStream(LoopMode loopMode,
|
||||
const std::string &threadId)
|
||||
|
@ -41,7 +43,10 @@ ALStream::ALStream(LoopMode loopMode,
|
|||
state(Closed),
|
||||
source(0),
|
||||
#ifdef MKXPZ_RETRO
|
||||
streamInited(false),
|
||||
sourceExhausted(false),
|
||||
threadTermReq(false),
|
||||
needsRewind(false),
|
||||
#else
|
||||
thread(0),
|
||||
#endif // MKXPZ_RETRO
|
||||
|
@ -308,7 +313,9 @@ void ALStream::openSource(const std::string &filename)
|
|||
|
||||
void ALStream::stopStream()
|
||||
{
|
||||
#ifndef MKXPZ_RETRO
|
||||
#ifdef MKXPZ_RETRO
|
||||
threadTermReq = true;
|
||||
#else
|
||||
threadTermReq.set();
|
||||
|
||||
if (thread)
|
||||
|
@ -331,8 +338,12 @@ void ALStream::startStream(double offset)
|
|||
{
|
||||
AL::Source::clearQueue(alSrc);
|
||||
|
||||
#ifndef MKXPZ_RETRO
|
||||
preemptPause = false;
|
||||
#ifdef MKXPZ_RETRO
|
||||
streamInited = false;
|
||||
sourceExhausted = false;
|
||||
threadTermReq = false;
|
||||
#else
|
||||
streamInited.clear();
|
||||
sourceExhausted.clear();
|
||||
threadTermReq.clear();
|
||||
|
@ -389,13 +400,11 @@ void ALStream::checkStopped()
|
|||
if (state != Playing)
|
||||
return;
|
||||
|
||||
#ifndef MKXPZ_RETRO
|
||||
/* If streaming thread hasn't queued up
|
||||
* buffers yet there's not point in querying
|
||||
* the AL source */
|
||||
if (!streamInited)
|
||||
return;
|
||||
#endif // MKXPZ_RETRO
|
||||
|
||||
/* If alSrc isn't playing, but we haven't
|
||||
* exhausted the data source yet, we're just
|
||||
|
@ -414,15 +423,13 @@ void ALStream::renderInit() {
|
|||
bool firstBuffer = true;
|
||||
ALDataSource::Status status;
|
||||
|
||||
//if (needsRewind)
|
||||
if (needsRewind)
|
||||
source->seekToOffset(startOffset);
|
||||
|
||||
for (int i = 0; i < STREAM_BUFS; ++i)
|
||||
{
|
||||
#ifndef MKXPZ_RETRO
|
||||
if (threadTermReq)
|
||||
return;
|
||||
#endif
|
||||
|
||||
AL::Buffer::ID buf = alBuf[i];
|
||||
|
||||
|
@ -438,15 +445,15 @@ void ALStream::renderInit() {
|
|||
resumeStream();
|
||||
|
||||
firstBuffer = false;
|
||||
#ifndef MKXPZ_RETRO
|
||||
#ifdef MKXPZ_RETRO
|
||||
streamInited = true;
|
||||
#else
|
||||
streamInited.set();
|
||||
#endif
|
||||
#endif // MKXPZ_RETRO
|
||||
}
|
||||
|
||||
#ifndef MKXPZ_RETRO
|
||||
if (threadTermReq)
|
||||
return;
|
||||
#endif
|
||||
|
||||
if (status == ALDataSource::EndOfStream)
|
||||
{
|
||||
|
@ -454,7 +461,7 @@ void ALStream::renderInit() {
|
|||
sourceExhausted = true;
|
||||
#else
|
||||
sourceExhausted.set();
|
||||
#endif
|
||||
#endif // MKXPZ_RETRO
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -465,16 +472,24 @@ void ALStream::render() {
|
|||
|
||||
while (procBufs--)
|
||||
{
|
||||
#ifndef MKXPZ_RETRO
|
||||
if (threadTermReq)
|
||||
break;
|
||||
#endif
|
||||
|
||||
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 (buf == AL::Buffer::ID(0))
|
||||
break;
|
||||
# endif // MKXPZ_RETRO
|
||||
#endif // MKXPZ_NO_EXCEPTIONS
|
||||
|
||||
if (buf == lastBuf)
|
||||
{
|
||||
|
@ -506,7 +521,7 @@ void ALStream::render() {
|
|||
sourceExhausted = true;
|
||||
#else
|
||||
sourceExhausted.set();
|
||||
#endif
|
||||
#endif // MKXPZ_RETRO
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -529,7 +544,7 @@ void ALStream::render() {
|
|||
sourceExhausted = true;
|
||||
#else
|
||||
sourceExhausted.set();
|
||||
#endif
|
||||
#endif // MKXPZ_RETRO
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,10 @@ struct ALStream
|
|||
ALDataSource *source;
|
||||
|
||||
#ifdef MKXPZ_RETRO
|
||||
bool streamInited;
|
||||
bool sourceExhausted;
|
||||
bool threadTermReq;
|
||||
bool needsRewind;
|
||||
#else
|
||||
SDL_Thread *thread;
|
||||
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
#include <cstdarg>
|
||||
#include <cstring>
|
||||
#include <boost/optional.hpp>
|
||||
#include <AL/alc.h>
|
||||
#include <AL/alext.h>
|
||||
#include <alc.h>
|
||||
#include <alext.h>
|
||||
#include <fluidlite.h>
|
||||
#include <fluidsynth_priv.h>
|
||||
#include "git-hash.h"
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
#include "keybindings.h"
|
||||
|
||||
#ifdef MKXPZ_RETRO
|
||||
# include <AL/alc.h>
|
||||
# include <alc.h>
|
||||
#else
|
||||
typedef struct MKXPZ_ALCDEVICE ALCdevice;
|
||||
#endif // MKXPZ_RETRO
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include "icon.png.xxd"
|
||||
#endif
|
||||
|
||||
#include <AL/alc.h>
|
||||
#include <alc.h>
|
||||
|
||||
#include <SDL.h>
|
||||
#include <SDL_image.h>
|
||||
|
|
|
@ -25,16 +25,9 @@
|
|||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef MKXPZ_RETRO
|
||||
# if WABT_BIG_ENDIAN
|
||||
#ifdef MKXPZ_BIG_ENDIAN
|
||||
# error "Non little endian systems not supported"
|
||||
# endif
|
||||
#else
|
||||
# include <SDL_endian.h>
|
||||
# if SDL_BYTEORDER != SDL_LIL_ENDIAN
|
||||
# error "Non little endian systems not supported"
|
||||
# endif
|
||||
#endif // MKXPZ_RETRO
|
||||
#endif // MKXPZ_BIG_ENDIAN
|
||||
|
||||
static inline int32_t
|
||||
readInt32(const char **dataP)
|
||||
|
|
Loading…
Add table
Reference in a new issue