Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Midi: Properly shutdown and reinitialize #3092

Merged
merged 2 commits into from
Oct 23, 2023

Conversation

Ghabry
Copy link
Member

@Ghabry Ghabry commented Sep 22, 2023

First commit fixes an oversight in the shutdown logic of the Player: Most audio stuff was not deleted because they were static variables...

This fixes the fluidsynth crashes on shutdown.

Should also fix the libretro crash when playing a second game but I havn't tested this (yet).


Second commit is less serious: Fluidsynth and WildMidi are now reinitialized when loading a second game. This saves RAM (unloaded when not used by the game) and allows per-game soundfonts. Before only the first was loaded.

This way they are destroyed when the DisplayUi is destroyed instead of when the process terminates.

Fixes a use-after-free in the Fluidsynth Decoder.

Fix EasyRPG#3015
Fix EasyRPG#3035
Fix EasyRPG#3079
@Ghabry Ghabry added the Audio label Sep 22, 2023
@Ghabry Ghabry added this to the 0.8.1 milestone Sep 22, 2023
@@ -22,31 +22,20 @@
#include <memory>
#include "audio_decoder_midi.h"
#include "audio_generic.h"
#include "audio_generic_midiout.h"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

7269d32 breaks compilation with for platforms libretro, psvita, sdl and switch when compiling audio.o because they include audio_generic.h. Since this commit, said header includes audio_generic_midiout.h which does not provide a definition for AudioDecoderMidi itself.
This used to be no problem because audio_generic_midiout.h was only included from audio_generic.cpp which also includes the missing header.

The fix is to include audio_decoder_midi.h either in audio_generic.h or in audio_generic_midiout.h.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C++ Header mess :/. Thanks for testing this!

@@ -22,31 +22,20 @@
#include <memory>
#include "audio_decoder_midi.h"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line can be deleted if you move audio_generic_midiout.h (see next comment).

Now custom soundfonts are always loaded when switching the game instead of only the first time.

Fix EasyRPG#2916
@Ghabry Ghabry merged commit 7741d74 into EasyRPG:master Oct 23, 2023
12 checks passed
@Ghabry Ghabry deleted the audio/midi-reset branch September 2, 2024 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

3 participants