From 31194eab22dcccbec78036fc1c898b0d89efcd41 Mon Sep 17 00:00:00 2001 From: AShiningRay Date: Mon, 16 Dec 2024 13:18:27 -0300 Subject: [PATCH] Nokia: Sound: Add null pointer checks on get/setGain. Some games seem to try using those with players they have just closed, like Saboteur. --- src/com/nokia/mid/sound/Sound.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/com/nokia/mid/sound/Sound.java b/src/com/nokia/mid/sound/Sound.java index 94705ec..71d00f5 100644 --- a/src/com/nokia/mid/sound/Sound.java +++ b/src/com/nokia/mid/sound/Sound.java @@ -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); }