Android: fixed excessive logging in audio renderer

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7864 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
kim..ng 14 years ago
parent dda8ee2c38
commit 7d08828fa7
  1. 12
      engine/src/android/com/jme3/audio/android/AndroidAudioData.java
  2. 21
      engine/src/android/com/jme3/audio/android/AndroidAudioRenderer.java

@ -8,6 +8,7 @@ public class AndroidAudioData extends AudioData
{ {
protected AssetKey assetKey; protected AssetKey assetKey;
protected int soundId = 0; protected int soundId = 0;
protected float currentVolume = 0f;
public AssetKey getAssetKey() { public AssetKey getAssetKey() {
return assetKey; return assetKey;
@ -45,8 +46,15 @@ public class AndroidAudioData extends AudioData
@Override @Override
public void deleteObject(AudioRenderer r) { 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;
} }

@ -115,7 +115,8 @@ public class AndroidAudioRenderer implements AudioRenderer, SoundPool.OnLoadComp
@Override @Override
public void updateSourceParam(AudioNode src, AudioParam param) public void updateSourceParam(AudioNode src, AudioParam param)
{ {
logger.log(Level.INFO, "updateSourceParam " + param); //logger.log(Level.INFO, "updateSourceParam " + param);
if (audioDisabled) if (audioDisabled)
return; return;
@ -210,7 +211,7 @@ public class AndroidAudioRenderer implements AudioRenderer, SoundPool.OnLoadComp
@Override @Override
public void updateListenerParam(Listener listener, ListenerParam param) public void updateListenerParam(Listener listener, ListenerParam param)
{ {
logger.log(Level.INFO, "updateListenerParam " + param); //logger.log(Level.INFO, "updateListenerParam " + param);
if (audioDisabled) if (audioDisabled)
return; return;
@ -244,6 +245,7 @@ public class AndroidAudioRenderer implements AudioRenderer, SoundPool.OnLoadComp
// Loop over all mediaplayers // Loop over all mediaplayers
for (AudioNode src : musicPlaying.keySet()) for (AudioNode src : musicPlaying.keySet())
{ {
MediaPlayer mp = musicPlaying.get(src); MediaPlayer mp = musicPlaying.get(src);
{ {
// Calc the distance to the listener // Calc the distance to the listener
@ -254,11 +256,20 @@ public class AndroidAudioRenderer implements AudioRenderer, SoundPool.OnLoadComp
if (distance < src.getRefDistance()) if (distance < src.getRefDistance())
distance = src.getRefDistance(); distance = src.getRefDistance();
if (distance > src.getMaxDistance()) if (distance > src.getMaxDistance())
distance = src.getMaxDistance(); distance = src.getMaxDistance();
volume = src.getRefDistance() / distance; volume = src.getRefDistance() / distance;
// Left / Right channel get the same volume by now, only positional AndroidAudioData audioData = (AndroidAudioData)src.getAudioData();
mp.setVolume(volume, volume);
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);
}
} }
} }
} }

Loading…
Cancel
Save