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. 10
      engine/src/android/com/jme3/audio/android/AndroidAudioData.java
  2. 19
      engine/src/android/com/jme3/audio/android/AndroidAudioRenderer.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;
}

@ -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
@ -257,8 +259,17 @@ public class AndroidAudioRenderer implements AudioRenderer, SoundPool.OnLoadComp
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);
}
}
}
}

Loading…
Cancel
Save