Hey there, I'm sorry to bother you again, but unfortunately this random crash (which i mentioned earlier) has become quiet annoying.
Just as a reminder I'm talking about this one:
[17:36:04] [Thread-11/INFO]: [STDERR]: java.lang.NullPointerException
[17:36:04] [Thread-11/INFO]: [STDERR]: at com.jcraft.jogg.StreamState.packetout(StreamState.java:186)
[17:36:04] [Thread-11/INFO]: [STDERR]: at paulscode.sound.codecs.CodecJOrbis.readBytes(CodecJOrbis.java:575)
[17:36:04] [Thread-11/INFO]: [STDERR]: at paulscode.sound.codecs.CodecJOrbis.read(CodecJOrbis.java:354)
[17:36:04] [Thread-11/INFO]: [STDERR]: at paulscode.sound.Source.stream(Source.java:953)
[17:36:04] [Thread-11/INFO]: [STDERR]: at paulscode.sound.StreamThread.run(StreamThread.java:129)
It causes the sound engine to crash from time to time, so all sounds will be stopped. The sound engine has to be restarted in order to make it working again.
Other mod authors are aware of this issue too, but none of us knows how to fix it. My guess is, that this is a weird thread issue, which is rather unlikely to occur, but will eventually happen if you play the game long enough. Of course the more streaming sounds will be played the more likely it is to happen.
Maybe you can help us out here? Do you have an idea what could cause this crash and how to fix it?
If not, I'm searching for a proper way to catch the exception and try to end the stream properly without causing the engine to crash as well, but unfortunately it does not work out, at least as far as i can tell, since it's rather difficult to reproduce this crash:
private byte[] readBytes()
{
if( !initialized( GET, XXX ) )
return null;
if( endOfStream( GET, XXX ) )
return null;
if( convertedBuffer == null )
convertedBuffer = new byte[ convertedBufferSize ];
byte[] returnBuffer = null;
float[][] pcmf;
int samples, bout, ptr, mono, val, i, j;
switch( joggSyncState.pageout( joggPage ) )
{
case( 0 ):
case( -1 ):
break;
default:
{
joggStreamState.pagein( joggPage );
if( joggPage.granulepos() == 0 )
{
endOfStream( SET, true );
return null;
}
try{
processPackets: while( true )
{
switch( joggStreamState.packetout( joggPacket ) )
{
case( 0 ):
break processPackets;
case( -1 ):
break;
default:
{
if( jorbisBlock.synthesis( joggPacket ) == 0 )
jorbisDspState.synthesis_blockin( jorbisBlock );
while( ( samples=jorbisDspState.synthesis_pcmout(
pcmInfo, pcmIndex ) ) > 0 )
{
pcmf = pcmInfo[0];
bout = ( samples < convertedBufferSize ?
samples : convertedBufferSize );
for( i = 0; i < jorbisInfo.channels; i++ )
{
ptr = i * 2;
mono = pcmIndex[i];
for( j = 0; j < bout; j++ )
{
val = (int) ( pcmf[i][mono + j] *
32767. );
if( val > 32767 )
val = 32767;
if( val < -32768 )
val = -32768;
if( val < 0 )
val = val | 0x8000;
convertedBuffer[ptr] = (byte) (val);
convertedBuffer[ptr+1] =
(byte) (val>>>8);
ptr += 2 * (jorbisInfo.channels);
}
}
jorbisDspState.synthesis_read( bout );
returnBuffer = appendByteArrays( returnBuffer,
convertedBuffer,
2 * jorbisInfo.channels * bout );
}
}
}
}
}catch(Exception e){
e.printStackTrace();
endOfStream( SET, true );
return null;
}
if( joggPage.eos() != 0 )
endOfStream( SET, true );
}
}
Is "endOfStream( SET, true );" a proper way of stopping the sound or will it cause future issues?