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 c6300c7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 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,12 @@ 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); }
}

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

0 comments on commit c6300c7

Please sign in to comment.