mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-14 10:09:32 +01:00
Merge pull request #78 from unknownbrackets/audio-timing
Return number of samples in NativeApp::audioRender()
This commit is contained in:
commit
edac7c236c
4 files changed
+17
-6
No files matched your search
@@ -4,5 +4,6 @@
|
||||
<classpathentry kind="src" path="gen"/>
|
||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
|
||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
|
||||
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
|
||||
<classpathentry kind="output" path="bin/classes"/>
|
||||
</classpath>
|
||||
+10
-3
@@ -294,7 +294,7 @@ extern "C" void Java_com_henrikrydgard_libnative_NativeRenderer_displayRender(JN
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" void Java_com_henrikrydgard_libnative_NativeApp_audioRender(JNIEnv* env, jclass clazz, jshortArray array) {
|
||||
extern "C" jint Java_com_henrikrydgard_libnative_NativeApp_audioRender(JNIEnv* env, jclass clazz, jshortArray array) {
|
||||
// Too spammy
|
||||
// ILOG("NativeApp.audioRender");
|
||||
|
||||
@@ -305,9 +305,16 @@ extern "C" void Java_com_henrikrydgard_libnative_NativeApp_audioRender(JNIEnv* e
|
||||
if (buf_size) {
|
||||
short *data = env->GetShortArrayElements(array, 0);
|
||||
int samples = buf_size / 2;
|
||||
NativeMix(data, samples);
|
||||
env->ReleaseShortArrayElements(array, data, 0);
|
||||
samples = NativeMix(data, samples);
|
||||
if (samples != 0) {
|
||||
env->ReleaseShortArrayElements(array, data, 0);
|
||||
return samples * 2;
|
||||
} else {
|
||||
env->ReleaseShortArrayElements(array, data, JNI_ABORT);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" void JNICALL Java_com_henrikrydgard_libnative_NativeApp_touch
|
||||
|
||||
@@ -21,7 +21,7 @@ public class NativeApp {
|
||||
public static native void joystickEvent(float x, float y);
|
||||
|
||||
// will only be called between init() and shutdown()
|
||||
public static native void audioRender(short[] buffer);
|
||||
public static native int audioRender(short[] buffer);
|
||||
|
||||
// Sensor/input data. These are asynchronous, beware!
|
||||
public static native void touch(float x, float y, int data, int pointerId);
|
||||
|
||||
@@ -81,8 +81,11 @@ public class NativeAudioPlayer {
|
||||
audioTrack.play();
|
||||
Log.i(TAG, "Playing... minBuffersize = " + buffer_size);
|
||||
while (playing_) {
|
||||
NativeApp.audioRender(buffer);
|
||||
audioTrack.write(buffer, 0, buffer_size);
|
||||
int validShorts = NativeApp.audioRender(buffer);
|
||||
if (validShorts != 0) {
|
||||
audioTrack.write(buffer, 0, validShorts);
|
||||
}
|
||||
Thread.yield();
|
||||
}
|
||||
audioTrack.stop();
|
||||
audioTrack.release();
|
||||
|
||||
Reference in new issue
Block a user