Skip to content

Commit 1ae5a4f

Browse files
committed
[TMP] Destroy old Music object before creating new one
TODO: Will become unnecessary once pspdev/pspsdk#330 is merged. This ensures that any de-initialization of the old Music object (e.g. de-registering callbacks) happens before initializing the new Music object. This is helpful for the upcoming PSP driver. TODO: Does this break other drivers? Use the blocking API instead if that's the case This will complicate the driver.
1 parent af5d02f commit 1ae5a4f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

source/Core/Game.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ namespace SuperHaxagon {
9696
}
9797

9898
void Game::playTitleMusic() {
99+
// Destroy the current Music object before the new one is constructed.
100+
_bgm.reset();
101+
99102
// First, try to load from the SD card if the player wants something custom
100103
_bgm = _platform.loadMusic("/title", Location::USER);
101104

@@ -113,7 +116,9 @@ namespace SuperHaxagon {
113116
if (loadMetadata) {
114117
_bgmMetadata = std::make_unique<Metadata>(_platform.openFile(base + ".txt", location));
115118
}
116-
119+
120+
// Destroy the current Music object before the new one is constructed.
121+
_bgm.reset();
117122
_bgm = _platform.loadMusic(base, location);
118123

119124
if (_bgm) {

0 commit comments

Comments
 (0)