From 3a5f66ba81891b53e39cc73624fff5981c6022c1 Mon Sep 17 00:00:00 2001 From: fd Date: Fri, 13 Feb 2015 23:17:33 -0500 Subject: [PATCH] close mp3 file handles. --- src/org/newdawn/slick/openal/Mp3InputStream.java | 9 +++++++++ src/org/newdawn/slick/openal/OpenALStreamPlayer.java | 11 +++++++++++ src/org/newdawn/slick/openal/SoundStore.java | 3 +++ 3 files changed, 23 insertions(+) diff --git a/src/org/newdawn/slick/openal/Mp3InputStream.java b/src/org/newdawn/slick/openal/Mp3InputStream.java index a71a9dd7..3ed4a800 100644 --- a/src/org/newdawn/slick/openal/Mp3InputStream.java +++ b/src/org/newdawn/slick/openal/Mp3InputStream.java @@ -199,4 +199,13 @@ public class Mp3InputStream extends InputStream implements AudioInputStream { return skipped; } + + @Override + public void close() throws IOException { + try { + bitstream.close(); + } catch (BitstreamException e) { + e.printStackTrace(); + } + } } diff --git a/src/org/newdawn/slick/openal/OpenALStreamPlayer.java b/src/org/newdawn/slick/openal/OpenALStreamPlayer.java index a4225882..5c2aa803 100644 --- a/src/org/newdawn/slick/openal/OpenALStreamPlayer.java +++ b/src/org/newdawn/slick/openal/OpenALStreamPlayer.java @@ -392,5 +392,16 @@ public class OpenALStreamPlayer { public void resuming() { lastUpdateTime = System.currentTimeMillis() - offsetTime; } + + public void close() { + if(audio != null){ + try { + audio.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + } } diff --git a/src/org/newdawn/slick/openal/SoundStore.java b/src/org/newdawn/slick/openal/SoundStore.java index 6894af5b..936b5095 100644 --- a/src/org/newdawn/slick/openal/SoundStore.java +++ b/src/org/newdawn/slick/openal/SoundStore.java @@ -916,6 +916,9 @@ public class SoundStore { return; } + if(this.stream != null){ + this.stream.close(); + } currentMusic = sources.get(0); this.stream = stream; if (stream != null) {