* Increased buffering for streaming audio from ~250 ms to 1000 ms.

* Reduced audio thread update from 100 fps to 20 fps (why was it 100 anyway??)

Result: Music stuttering dramatically reduced.

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7226 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
sha..rd 14 years ago
parent 2979a26984
commit 7f7fc50ab5
  1. 2
      engine/src/core/com/jme3/scene/Mesh.java
  2. 8
      engine/src/lwjgl-oal/com/jme3/audio/lwjgl/LwjglAudioRenderer.java
  3. 5
      engine/src/test/jme3test/audio/TestMusicPlayer.java
  4. 1
      engine/src/test/jme3test/audio/TestOgg.java

@ -468,7 +468,7 @@ public class Mesh implements Savable, Cloneable {
// accepted format for buffers // accepted format for buffers
ShortBuffer sib = (ShortBuffer) ib.getData(); ShortBuffer sib = (ShortBuffer) ib.getData();
// aquire triangle's vertex indices // acquire triangle's vertex indices
int vertIndex = index * 3; int vertIndex = index * 3;
indices[0] = sib.get(vertIndex); indices[0] = sib.get(vertIndex);
indices[1] = sib.get(vertIndex+1); indices[1] = sib.get(vertIndex+1);

@ -69,7 +69,9 @@ public class LwjglAudioRenderer implements AudioRenderer, Runnable {
private static final Logger logger = Logger.getLogger(LwjglAudioRenderer.class.getName()); private static final Logger logger = Logger.getLogger(LwjglAudioRenderer.class.getName());
private static final int BUFFER_SIZE = 8192; // When multiplied by STREAMING_BUFFER_COUNT, will equal 44100 * 2 * 2
// which is exactly 1 second of audio.
private static final int BUFFER_SIZE = 35280;
private static final int STREAMING_BUFFER_COUNT = 5; private static final int STREAMING_BUFFER_COUNT = 5;
private final static int MAX_NUM_CHANNELS = 64; private final static int MAX_NUM_CHANNELS = 64;
@ -91,7 +93,9 @@ public class LwjglAudioRenderer implements AudioRenderer, Runnable {
private int reverbFx = -1; private int reverbFx = -1;
private int reverbFxSlot = -1; private int reverbFxSlot = -1;
private static final float UPDATE_RATE = 0.01f; // Update audio 20 times per second
private static final float UPDATE_RATE = 0.05f;
private final Thread audioThread = new Thread(this, "jME3 Audio Thread"); private final Thread audioThread = new Thread(this, "jME3 Audio Thread");
private final AtomicBoolean threadLock = new AtomicBoolean(false); private final AtomicBoolean threadLock = new AtomicBoolean(false);

@ -39,7 +39,6 @@ import com.jme3.audio.AudioRenderer;
import com.jme3.audio.AudioNode; import com.jme3.audio.AudioNode;
import com.jme3.audio.AudioNode.Status; import com.jme3.audio.AudioNode.Status;
import com.jme3.audio.Listener; import com.jme3.audio.Listener;
import com.jme3.audio.QueuedAudioRenderer;
import com.jme3.audio.plugins.OGGLoader; import com.jme3.audio.plugins.OGGLoader;
import com.jme3.system.AppSettings; import com.jme3.system.AppSettings;
import com.jme3.system.JmeSystem; import com.jme3.system.JmeSystem;
@ -67,7 +66,7 @@ public class TestMusicPlayer extends javax.swing.JFrame {
private void initAudioPlayer(){ private void initAudioPlayer(){
AppSettings settings = new AppSettings(true); AppSettings settings = new AppSettings(true);
settings.setRenderer(null); // force dummy renderer (?) settings.setRenderer(null); // disable rendering
settings.setAudioRenderer("LWJGL"); settings.setAudioRenderer("LWJGL");
ar = JmeSystem.newAudioRenderer(settings); ar = JmeSystem.newAudioRenderer(settings);
ar.initialize(); ar.initialize();
@ -189,11 +188,13 @@ public class TestMusicPlayer extends javax.swing.JFrame {
try{ try{
return new FileInputStream(selected); return new FileInputStream(selected);
}catch (FileNotFoundException ex){ }catch (FileNotFoundException ex){
ex.printStackTrace();
} }
return null; return null;
} }
}); });
}catch (IOException ex){ }catch (IOException ex){
ex.printStackTrace();
} }
musicSource = new AudioNode(musicData, key); musicSource = new AudioNode(musicData, key);

@ -32,7 +32,6 @@
package jme3test.audio; package jme3test.audio;
import com.jme3.asset.plugins.UrlLocator;
import com.jme3.audio.AudioNode; import com.jme3.audio.AudioNode;
import com.jme3.audio.LowPassFilter; import com.jme3.audio.LowPassFilter;

Loading…
Cancel
Save