Skip to content

Commit

Permalink
PlatformPlayer: realize() again after deallocate(), conditionally
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
AShiningRay committed Oct 20, 2024
1 parent 11da219 commit f045912
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/org/recompile/mobile/PlatformPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit f045912

Please sign in to comment.