Changed some methods in OpenALStreamPlayer to synchornized methods.

Seems to work with ogg now too.

Hopefully this fixes it, but I don't 
actually know much about concurrency.

However it stills throws "Could not clear SoundStore sources, err"
and so it remains removed.
This commit is contained in:
fd
2015-02-09 21:33:37 -05:00
parent 6883e2ab44
commit 08406ac038
3 changed files with 25 additions and 15 deletions

View File

@@ -79,15 +79,15 @@ public class MusicController {
switch (OsuParser.getExtension(osu.audioFilename.getName())) {
case "ogg":
//trackLoader = new Thread() {
// @Override
// public void run() {
trackLoader = new Thread() {
@Override
public void run() {
//Loading ogg async seems to screw up
//So does mp3, but much less
loadTrack(osu.audioFilename, osu.previewTime, loop);
// }
//};
//trackLoader.start();
}
};
trackLoader.start();
break;
case "mp3":
trackLoader = new Thread() {
@@ -95,7 +95,7 @@ public class MusicController {
public void run() {
loadTrack(osu.audioFilename, osu.previewTime, loop);
//convertMp3(osu.audioFilename);
// if (!Thread.currentThread().isInterrupted())
//if (!Thread.currentThread().isInterrupted())
// loadTrack(wavFile, osu.previewTime, loop);
}
};
@@ -133,13 +133,14 @@ public class MusicController {
public static void playAt(final int position, final boolean loop) {
if (trackExists()) {
setVolume(Options.getMusicVolume() * Options.getMasterVolume());
player.setPosition(position / 1000f);
trackEnded = false;
pauseTime = 0f;
if (loop)
player.loop();
else
player.play();
player.setPosition(position / 1000f);
}
}
@@ -339,8 +340,14 @@ public class MusicController {
// TODO: properly interrupt instead of using deprecated Thread.stop();
// interrupt the conversion/track loading
if (isTrackLoading())
try {
trackLoader.join();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// trackLoader.interrupt();
trackLoader.stop();
//trackLoader.stop();
trackLoader = null;
// delete temporary WAV file