Splitted Java sources to many small files, fixed tabulation, splitted input source file from video in libSDL.

This commit is contained in:
pelya
2010-05-18 11:14:30 +03:00
parent 3ea94d2ba2
commit b973f29b35
11 changed files with 961 additions and 865 deletions

View File

@@ -0,0 +1,95 @@
// This string is autogenerated by ChangeAppSettings.sh, do not change spaces amount
package de.schwardtnet.alienblaster;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.KeyEvent;
import android.view.Window;
import android.view.WindowManager;
import android.media.AudioTrack;
import android.media.AudioManager;
import android.media.AudioFormat;
import java.io.*;
import java.nio.ByteBuffer;
class AudioThread extends Thread {
private Activity mParent;
private AudioTrack mAudio;
private byte[] mAudioBuffer;
private ByteBuffer mAudioBufferNative;
public AudioThread(Activity parent)
{
mParent = parent;
mAudio = null;
mAudioBuffer = null;
this.setPriority(Thread.MAX_PRIORITY);
this.start();
}
@Override
public void run()
{
while( !isInterrupted() )
{
if( mAudio == null )
{
int[] initParams = nativeAudioInit();
if( initParams == null )
{
try {
sleep(200);
} catch( java.lang.InterruptedException e ) { };
}
else
{
int rate = initParams[0];
int channels = initParams[1];
channels = ( channels == 1 ) ? AudioFormat.CHANNEL_CONFIGURATION_MONO :
AudioFormat.CHANNEL_CONFIGURATION_STEREO;
int encoding = initParams[2];
encoding = ( encoding == 1 ) ? AudioFormat.ENCODING_PCM_16BIT :
AudioFormat.ENCODING_PCM_8BIT;
int bufSize = AudioTrack.getMinBufferSize( rate, channels, encoding );
if( initParams[3] > bufSize )
bufSize = initParams[3];
mAudioBuffer = new byte[bufSize];
nativeAudioInit2(mAudioBuffer);
mAudio = new AudioTrack(AudioManager.STREAM_MUSIC,
rate,
channels,
encoding,
bufSize,
AudioTrack.MODE_STREAM );
mAudio.play();
}
}
else
{
int len = nativeAudioBufferLock();
if( len > 0 )
mAudio.write( mAudioBuffer, 0, len );
if( len < 0 )
break;
nativeAudioBufferUnlock();
}
}
if( mAudio != null )
{
mAudio.stop();
mAudio.release();
mAudio = null;
}
}
private native int[] nativeAudioInit();
private native int nativeAudioInit2(byte[] buf);
private native int nativeAudioBufferLock();
private native int nativeAudioBufferUnlock();
}