From f0459128836d1ae173413933896e2eeb5d31ff99 Mon Sep 17 00:00:00 2001 From: AShiningRay Date: Sun, 20 Oct 2024 14:24:44 -0300 Subject: [PATCH] PlatformPlayer: realize() again after deallocate(), conditionally deallocate() can be called between the transition from UNREALIZED to REALIZED, which is the only situation where the player can return to UNREALIZED. That case was already covered. What was not covered, was realizing the player again after deallocate() if it was on the REALIZED state or higher. And since close() has no need for a realize() call (which WILL be done in the superclass unless UNREALIZED), close() will call the actual player's deallocate() method directly before setting state to CLOSED. Fixes a bunch of gameloft games (mainly k800i versions with their more robust audio system) that were already fixed with the big PlatformPlayer rewrite, but regressed temporarily as the players' state handling was tightened. --- src/org/recompile/mobile/PlatformPlayer.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/org/recompile/mobile/PlatformPlayer.java b/src/org/recompile/mobile/PlatformPlayer.java index 6bb400f8..ec8175ca 100644 --- a/src/org/recompile/mobile/PlatformPlayer.java +++ b/src/org/recompile/mobile/PlatformPlayer.java @@ -150,7 +150,7 @@ public void close() try { player.stop(); - deallocate(); + player.deallocate(); /* Call player's deallocate directly, otherwise we'll realize() again */ state = Player.CLOSED; player = null; notifyListeners(PlayerListener.CLOSED, null); @@ -220,7 +220,11 @@ public void deallocate() * as deallocate can be called during the transition from UNREALIZED to REALIZED, and if that happens, * we can't actually set it as REALIZED, it must be kept as UNREALIZED. */ - if(state > Player.UNREALIZED) {state = Player.REALIZED;} + if(state > Player.UNREALIZED) + { + player.realize(); + state = Player.REALIZED; + } } public String getContentType()