Skip to content

Commit

Permalink
Nokia: Sound: Add null pointer checks on get/setGain.
Browse files Browse the repository at this point in the history
Some games seem to try using those with players they have just
closed, like Saboteur.
  • Loading branch information
AShiningRay committed Dec 16, 2024
1 parent 9738a28 commit 31194ea
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/com/nokia/mid/sound/Sound.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,13 @@ public void resume()
public void setGain(int gain)
{
// Gain goes from 0 to 255, while setLevel works from 0 to 100
((PlatformPlayer.volumeControl)player.getControl("VolumeControl")).setLevel((int) (gain / 255 * 100));
if(player != null) { ((PlatformPlayer.volumeControl)player.getControl("VolumeControl")).setLevel((int) (gain / 255 * 100)); }
}

public int getGain()
{
return (int) ((((PlatformPlayer.volumeControl)player.getControl("VolumeControl")).getLevel() / 100) * 255);
if(player != null) { return (int) ((((PlatformPlayer.volumeControl)player.getControl("VolumeControl")).getLevel() / 100) * 255); }
return 0;
}

public void setSoundListener(SoundListener soundListener) { ((PlatformPlayer) player).setSoundListener(this, soundListener); }
Expand Down

0 comments on commit 31194ea

Please sign in to comment.