|
@@ -2,6 +2,8 @@ package com.jme3.audio.lwjgl;
|
|
|
|
|
|
import com.jme3.audio.openal.ALC;
|
|
import com.jme3.audio.openal.ALC;
|
|
import java.nio.IntBuffer;
|
|
import java.nio.IntBuffer;
|
|
|
|
+import java.util.logging.Level;
|
|
|
|
+import java.util.logging.Logger;
|
|
import org.lwjgl.LWJGLException;
|
|
import org.lwjgl.LWJGLException;
|
|
import org.lwjgl.openal.AL;
|
|
import org.lwjgl.openal.AL;
|
|
import org.lwjgl.openal.ALC10;
|
|
import org.lwjgl.openal.ALC10;
|
|
@@ -9,13 +11,43 @@ import org.lwjgl.openal.ALCcontext;
|
|
import org.lwjgl.openal.ALCdevice;
|
|
import org.lwjgl.openal.ALCdevice;
|
|
|
|
|
|
public class LwjglALC implements ALC {
|
|
public class LwjglALC implements ALC {
|
|
|
|
+ /**
|
|
|
|
+ * message logger for this class
|
|
|
|
+ */
|
|
|
|
+ private static final Logger logger
|
|
|
|
+ = Logger.getLogger(LwjglALC.class.getName());
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void createALC() {
|
|
public void createALC() {
|
|
- try {
|
|
|
|
- AL.create();
|
|
|
|
- } catch (LWJGLException ex) {
|
|
|
|
- throw new RuntimeException(ex);
|
|
|
|
|
|
+ int numRetriesRemaining = 4;
|
|
|
|
+ int retryDelayMsec = 100; // 0.1-second delay between retries
|
|
|
|
+
|
|
|
|
+ while (true) {
|
|
|
|
+ try {
|
|
|
|
+ AL.create();
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ } catch (LWJGLException exception1) {
|
|
|
|
+ if (numRetriesRemaining < 1) {
|
|
|
|
+ throw new RuntimeException(exception1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Retry to mitigate JME Issue 1383.
|
|
|
|
+ --numRetriesRemaining;
|
|
|
|
+ String message = String.format(
|
|
|
|
+ "Caught an LWJGLException from AL.create(). "
|
|
|
|
+ + "Will retry after %d msec, "
|
|
|
|
+ + "with %d more retr%s remaining.%n",
|
|
|
|
+ retryDelayMsec,
|
|
|
|
+ numRetriesRemaining,
|
|
|
|
+ (numRetriesRemaining == 1) ? "y" : "ies");
|
|
|
|
+ logger.log(Level.WARNING, message);
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ Thread.sleep(retryDelayMsec);
|
|
|
|
+ } catch (InterruptedException exception2) {
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|