• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Main repository of MikuMikuStudio


コミットメタ情報

リビジョンfebc90c68ebfdc48e4336ec8f0bb8f20c2407f91 (tree)
日時2013-05-14 00:56:29
作者iwgeric@gmail.com <iwgeric@gmai...>
コミッターiwgeric@gmail.com

ログメッセージ

Android: Added methods for OpenAL Soft Audio Renderer to pause and resume audio when app is placed in the background

git-svn-id: http://jmonkeyengine.googlecode.com/svn/trunk@10613 75d07b2b-3a1a-0410-a2c5-0572b91ccdca

変更サマリ

差分

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
--- 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;
1515 import android.widget.TextView;
1616 import com.jme3.audio.AudioRenderer;
1717 import com.jme3.audio.android.AndroidAudioRenderer;
18+import com.jme3.audio.android.AndroidOpenALSoftAudioRenderer;
1819 import com.jme3.input.JoyInput;
1920 import com.jme3.input.TouchInput;
2021 import com.jme3.input.android.AndroidSensorJoyInput;
@@ -486,6 +487,10 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt
486487 AndroidAudioRenderer renderer = (AndroidAudioRenderer) result;
487488 renderer.resumeAll();
488489 }
490+ if (result instanceof AndroidOpenALSoftAudioRenderer) {
491+ AndroidOpenALSoftAudioRenderer renderer = (AndroidOpenALSoftAudioRenderer) result;
492+ renderer.resumeAll();
493+ }
489494 }
490495 //resume the sensors (aka joysticks)
491496 if (app.getContext() != null) {
@@ -525,6 +530,10 @@ public class AndroidHarness extends Activity implements TouchListener, DialogInt
525530 AndroidAudioRenderer renderer = (AndroidAudioRenderer) result;
526531 renderer.pauseAll();
527532 }
533+ if (result instanceof AndroidOpenALSoftAudioRenderer) {
534+ AndroidOpenALSoftAudioRenderer renderer = (AndroidOpenALSoftAudioRenderer) result;
535+ renderer.pauseAll();
536+ }
528537 }
529538 //pause the sensors (aka joysticks)
530539 if (app.getContext() != null) {
--- 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 {
12991299 }
13001300 }
13011301
1302+ public void pauseAll() {
1303+ checkDead();
1304+ synchronized (threadLock) {
1305+ while (!threadLock.get()) {
1306+ try {
1307+ threadLock.wait();
1308+ } catch (InterruptedException ex) {
1309+ }
1310+ }
1311+ if (audioDisabled) {
1312+ return;
1313+ }
1314+
1315+ for (int i = 0; i < channels.length; i++) {
1316+ AudioSource src = chanSrcs[i];
1317+ if (src == null) {
1318+ continue;
1319+ }
1320+
1321+ if (src.getStatus() == Status.Playing) {
1322+ assert src.getChannel() != -1;
1323+
1324+ logger.log(Level.FINE, "Pausing Source: {0}", src.getChannel());
1325+ alSourcePause(channels[src.getChannel()]);
1326+ checkError(true);
1327+ src.setStatus(Status.Paused);
1328+ }
1329+ }
1330+
1331+ }
1332+ }
1333+
1334+ public void resumeAll() {
1335+ checkDead();
1336+ synchronized (threadLock) {
1337+ while (!threadLock.get()) {
1338+ try {
1339+ threadLock.wait();
1340+ } catch (InterruptedException ex) {
1341+ }
1342+ }
1343+ if (audioDisabled) {
1344+ return;
1345+ }
1346+
1347+ for (int i = 0; i < channels.length; i++) {
1348+ AudioSource src = chanSrcs[i];
1349+ if (src == null) {
1350+ continue;
1351+ }
1352+
1353+ if (src.getStatus() == Status.Paused) {
1354+ assert src.getChannel() != -1;
1355+
1356+ logger.log(Level.FINE, "Playing/Resuming Source: {0}", src.getChannel());
1357+ alSourcePlay(channels[src.getChannel()]);
1358+ checkError(true);
1359+ src.setStatus(Status.Playing);
1360+ }
1361+ }
1362+ }
1363+ }
1364+
13021365 private int checkError(boolean stopOnError) {
13031366 int errorCode = alGetError();
13041367 String errorText = AL.GetALErrorMsg(errorCode);