@ -41,6 +41,7 @@ import com.jme3.audio.AudioKey;
import com.jme3.util.BufferUtils ;
import com.jme3.util.BufferUtils ;
import com.jme3.util.LittleEndien ;
import com.jme3.util.LittleEndien ;
import java.io.IOException ;
import java.io.IOException ;
import java.io.InputStream ;
import java.nio.ByteBuffer ;
import java.nio.ByteBuffer ;
import java.util.logging.Level ;
import java.util.logging.Level ;
import java.util.logging.Logger ;
import java.util.logging.Logger ;
@ -104,7 +105,6 @@ public class WAVLoader implements AssetLoader {
if ( remaining > 0 ) {
if ( remaining > 0 ) {
in . skipBytes ( remaining ) ;
in . skipBytes ( remaining ) ;
}
}
}
}
private void readDataChunkForBuffer ( int len ) throws IOException {
private void readDataChunkForBuffer ( int len ) throws IOException {
@ -123,8 +123,8 @@ public class WAVLoader implements AssetLoader {
audioStream . updateData ( in , duration ) ;
audioStream . updateData ( in , duration ) ;
}
}
public Object load ( AssetInfo info ) throws IOException {
private AudioData load ( InputStream inputStream , boolean stream ) throws IOException {
this . in = new LittleEndien ( info . openStream ( ) ) ;
this . in = new LittleEndien ( inputStream ) ;
int sig = in . readInt ( ) ;
int sig = in . readInt ( ) ;
if ( sig ! = i_RIFF )
if ( sig ! = i_RIFF )
@ -135,8 +135,7 @@ public class WAVLoader implements AssetLoader {
if ( in . readInt ( ) ! = i_WAVE )
if ( in . readInt ( ) ! = i_WAVE )
throw new IOException ( "WAVE File does not contain audio" ) ;
throw new IOException ( "WAVE File does not contain audio" ) ;
readStream = ( ( AudioKey ) info . getKey ( ) ) . isStream ( ) ;
readStream = stream ;
if ( readStream ) {
if ( readStream ) {
audioStream = new AudioStream ( ) ;
audioStream = new AudioStream ( ) ;
audioData = audioStream ;
audioData = audioStream ;
@ -168,9 +167,25 @@ public class WAVLoader implements AssetLoader {
if ( skipped < = 0 ) {
if ( skipped < = 0 ) {
return null ;
return null ;
}
}
break ;
break ;
}
}
}
}
}
}
public Object load ( AssetInfo info ) throws IOException {
AudioData data ;
InputStream inputStream = null ;
try {
inputStream = info . openStream ( ) ;
data = load ( inputStream , ( ( AudioKey ) info . getKey ( ) ) . isStream ( ) ) ;
if ( data instanceof AudioStream ) {
inputStream = null ;
}
return data ;
} finally {
if ( inputStream ! = null ) {
inputStream . close ( ) ;
}
}
}
}
}