Skip to content

Commit

Permalink
Merge pull request #49480 from madmiraal/fix-27725
Browse files Browse the repository at this point in the history
Remove unused AudioDriverAndroid from Android
  • Loading branch information
akien-mga authored Jun 10, 2021
2 parents 9539e4e + 4ba2ed3 commit dfc88bc
Show file tree
Hide file tree
Showing 8 changed files with 0 additions and 368 deletions.
1 change: 0 additions & 1 deletion platform/android/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ android_files = [
"dir_access_jandroid.cpp",
"thread_jandroid.cpp",
"net_socket_android.cpp",
"audio_driver_jandroid.cpp",
"java_godot_lib_jni.cpp",
"java_class_wrapper.cpp",
"java_godot_wrapper.cpp",
Expand Down
185 changes: 0 additions & 185 deletions platform/android/audio_driver_jandroid.cpp

This file was deleted.

78 changes: 0 additions & 78 deletions platform/android/audio_driver_jandroid.h

This file was deleted.

89 changes: 0 additions & 89 deletions platform/android/java/lib/src/org/godotengine/godot/GodotIO.java
Original file line number Diff line number Diff line change
Expand Up @@ -327,95 +327,6 @@ public void dir_close(int id) {
dirs = new SparseArray<AssetDir>();
}

/////////////////////////
// AUDIO
/////////////////////////

private Object buf;
private Thread mAudioThread;
private AudioTrack mAudioTrack;

public Object audioInit(int sampleRate, int desiredFrames) {
int channelConfig = AudioFormat.CHANNEL_OUT_STEREO;
int audioFormat = AudioFormat.ENCODING_PCM_16BIT;
int frameSize = 4;

System.out.printf("audioInit: initializing audio:\n");

//Log.v("Godot", "Godot audio: wanted " + (isStereo ? "stereo" : "mono") + " " + (is16Bit ? "16-bit" : "8-bit") + " " + ((float)sampleRate / 1000f) + "kHz, " + desiredFrames + " frames buffer");

// Let the user pick a larger buffer if they really want -- but ye
// gods they probably shouldn't, the minimums are horrifyingly high
// latency already
desiredFrames = Math.max(desiredFrames, (AudioTrack.getMinBufferSize(sampleRate, channelConfig, audioFormat) + frameSize - 1) / frameSize);

mAudioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, sampleRate,
channelConfig, audioFormat, desiredFrames * frameSize, AudioTrack.MODE_STREAM);

audioStartThread();

//Log.v("Godot", "Godot audio: got " + ((mAudioTrack.getChannelCount() >= 2) ? "stereo" : "mono") + " " + ((mAudioTrack.getAudioFormat() == AudioFormat.ENCODING_PCM_16BIT) ? "16-bit" : "8-bit") + " " + ((float)mAudioTrack.getSampleRate() / 1000f) + "kHz, " + desiredFrames + " frames buffer");

buf = new short[desiredFrames * 2];
return buf;
}

public void audioStartThread() {
mAudioThread = new Thread(new Runnable() {
public void run() {
mAudioTrack.play();
GodotLib.audio();
}
});

// I'd take REALTIME if I could get it!
mAudioThread.setPriority(Thread.MAX_PRIORITY);
mAudioThread.start();
}

public void audioWriteShortBuffer(short[] buffer) {
for (int i = 0; i < buffer.length;) {
int result = mAudioTrack.write(buffer, i, buffer.length - i);
if (result > 0) {
i += result;
} else if (result == 0) {
try {
Thread.sleep(1);
} catch (InterruptedException e) {
// Nom nom
}
} else {
Log.w("Godot", "Godot audio: error return from write(short)");
return;
}
}
}

public void audioQuit() {
if (mAudioThread != null) {
try {
mAudioThread.join();
} catch (Exception e) {
Log.v("Godot", "Problem stopping audio thread: " + e);
}
mAudioThread = null;

//Log.v("Godot", "Finished waiting for audio thread");
}

if (mAudioTrack != null) {
mAudioTrack.stop();
mAudioTrack = null;
}
}

public void audioPause(boolean p_pause) {
if (p_pause)
mAudioTrack.pause();
else
mAudioTrack.play();
}

/////////////////////////
// MISCELLANEOUS OS IO
/////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,6 @@ public class GodotLib {
*/
public static native void focusout();

/**
* Invoked when the audio thread is started.
*/
public static native void audio();

/**
* Used to access Godot global properties.
* @param p_key Property key
Expand Down
Loading

0 comments on commit dfc88bc

Please sign in to comment.