diff --git a/engine/lib/openal-soft/jME3-openal-soft-natives-android.jar b/engine/lib/openal-soft/jME3-openal-soft-natives-android.jar index fa3796262..02880883c 100644 Binary files a/engine/lib/openal-soft/jME3-openal-soft-natives-android.jar and b/engine/lib/openal-soft/jME3-openal-soft-natives-android.jar differ diff --git a/engine/src/android/com/jme3/app/AndroidHarness.java b/engine/src/android/com/jme3/app/AndroidHarness.java index 9102c16b3..a7a116bb3 100644 --- a/engine/src/android/com/jme3/app/AndroidHarness.java +++ b/engine/src/android/com/jme3/app/AndroidHarness.java @@ -15,6 +15,7 @@ import android.widget.ImageView; import android.widget.TextView; import com.jme3.audio.AudioRenderer; import com.jme3.audio.android.AndroidAudioRenderer; +import com.jme3.audio.android.AndroidOpenALSoftAudioRenderer; import com.jme3.input.JoyInput; import com.jme3.input.TouchInput; import com.jme3.input.android.AndroidSensorJoyInput; @@ -486,6 +487,10 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt AndroidAudioRenderer renderer = (AndroidAudioRenderer) result; renderer.resumeAll(); } + if (result instanceof AndroidOpenALSoftAudioRenderer) { + AndroidOpenALSoftAudioRenderer renderer = (AndroidOpenALSoftAudioRenderer) result; + renderer.resumeAll(); + } } //resume the sensors (aka joysticks) if (app.getContext() != null) { @@ -525,6 +530,10 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt AndroidAudioRenderer renderer = (AndroidAudioRenderer) result; renderer.pauseAll(); } + if (result instanceof AndroidOpenALSoftAudioRenderer) { + AndroidOpenALSoftAudioRenderer renderer = (AndroidOpenALSoftAudioRenderer) result; + renderer.pauseAll(); + } } //pause the sensors (aka joysticks) if (app.getContext() != null) { diff --git a/engine/src/android/com/jme3/audio/android/AndroidOpenALSoftAudioRenderer.java b/engine/src/android/com/jme3/audio/android/AndroidOpenALSoftAudioRenderer.java index 49959af81..6b880a7e9 100644 --- a/engine/src/android/com/jme3/audio/android/AndroidOpenALSoftAudioRenderer.java +++ b/engine/src/android/com/jme3/audio/android/AndroidOpenALSoftAudioRenderer.java @@ -1299,6 +1299,69 @@ public class AndroidOpenALSoftAudioRenderer implements AudioRenderer, Runnable { } } + public void pauseAll() { + checkDead(); + synchronized (threadLock) { + while (!threadLock.get()) { + try { + threadLock.wait(); + } catch (InterruptedException ex) { + } + } + if (audioDisabled) { + return; + } + + for (int i = 0; i < channels.length; i++) { + AudioSource src = chanSrcs[i]; + if (src == null) { + continue; + } + + if (src.getStatus() == Status.Playing) { + assert src.getChannel() != -1; + + logger.log(Level.FINE, "Pausing Source: {0}", src.getChannel()); + alSourcePause(channels[src.getChannel()]); + checkError(true); + src.setStatus(Status.Paused); + } + } + + } + } + + public void resumeAll() { + checkDead(); + synchronized (threadLock) { + while (!threadLock.get()) { + try { + threadLock.wait(); + } catch (InterruptedException ex) { + } + } + if (audioDisabled) { + return; + } + + for (int i = 0; i < channels.length; i++) { + AudioSource src = chanSrcs[i]; + if (src == null) { + continue; + } + + if (src.getStatus() == Status.Paused) { + assert src.getChannel() != -1; + + logger.log(Level.FINE, "Playing/Resuming Source: {0}", src.getChannel()); + alSourcePlay(channels[src.getChannel()]); + checkError(true); + src.setStatus(Status.Playing); + } + } + } + } + private int checkError(boolean stopOnError) { int errorCode = alGetError(); String errorText = AL.GetALErrorMsg(errorCode);