From 7d08828fa7369416f9111bc21bc96326f2c3466b Mon Sep 17 00:00:00 2001 From: "kim..ng" Date: Sat, 16 Jul 2011 15:18:32 +0000 Subject: [PATCH] Android: fixed excessive logging in audio renderer git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7864 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../jme3/audio/android/AndroidAudioData.java | 12 +++++++++-- .../audio/android/AndroidAudioRenderer.java | 21 ++++++++++++++----- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/engine/src/android/com/jme3/audio/android/AndroidAudioData.java b/engine/src/android/com/jme3/audio/android/AndroidAudioData.java index 39f729154..15335d646 100644 --- a/engine/src/android/com/jme3/audio/android/AndroidAudioData.java +++ b/engine/src/android/com/jme3/audio/android/AndroidAudioData.java @@ -8,6 +8,7 @@ public class AndroidAudioData extends AudioData { protected AssetKey assetKey; protected int soundId = 0; + protected float currentVolume = 0f; public AssetKey getAssetKey() { return assetKey; @@ -45,8 +46,15 @@ public class AndroidAudioData extends AudioData @Override public void deleteObject(AudioRenderer r) { - // TODO Auto-generated method stub - + r.deleteAudioData(this); + } + + public float getCurrentVolume() { + return currentVolume; + } + + public void setCurrentVolume(float currentVolume) { + this.currentVolume = currentVolume; } diff --git a/engine/src/android/com/jme3/audio/android/AndroidAudioRenderer.java b/engine/src/android/com/jme3/audio/android/AndroidAudioRenderer.java index 2156e836d..0426b68e0 100644 --- a/engine/src/android/com/jme3/audio/android/AndroidAudioRenderer.java +++ b/engine/src/android/com/jme3/audio/android/AndroidAudioRenderer.java @@ -115,7 +115,8 @@ public class AndroidAudioRenderer implements AudioRenderer, SoundPool.OnLoadComp @Override public void updateSourceParam(AudioNode src, AudioParam param) { - logger.log(Level.INFO, "updateSourceParam " + param); + //logger.log(Level.INFO, "updateSourceParam " + param); + if (audioDisabled) return; @@ -210,7 +211,7 @@ public class AndroidAudioRenderer implements AudioRenderer, SoundPool.OnLoadComp @Override public void updateListenerParam(Listener listener, ListenerParam param) { - logger.log(Level.INFO, "updateListenerParam " + param); + //logger.log(Level.INFO, "updateListenerParam " + param); if (audioDisabled) return; @@ -244,6 +245,7 @@ public class AndroidAudioRenderer implements AudioRenderer, SoundPool.OnLoadComp // Loop over all mediaplayers for (AudioNode src : musicPlaying.keySet()) { + MediaPlayer mp = musicPlaying.get(src); { // Calc the distance to the listener @@ -254,11 +256,20 @@ public class AndroidAudioRenderer implements AudioRenderer, SoundPool.OnLoadComp if (distance < src.getRefDistance()) distance = src.getRefDistance(); if (distance > src.getMaxDistance()) - distance = src.getMaxDistance(); + distance = src.getMaxDistance(); volume = src.getRefDistance() / distance; - // Left / Right channel get the same volume by now, only positional - mp.setVolume(volume, volume); + AndroidAudioData audioData = (AndroidAudioData)src.getAudioData(); + + if (FastMath.abs(audioData.getCurrentVolume() - volume) > FastMath.FLT_EPSILON) + { + // Left / Right channel get the same volume by now, only positional + mp.setVolume(volume, volume); + + audioData.setCurrentVolume(volume); + } + + } } }