Update Android support once again.

pull/1/head
Nikita Krapivin 2021-11-08 23:06:28 +05:00
parent 6ef79855ab
commit fa73ce8e3a
16 changed files with 91 additions and 32 deletions

View File

@ -63,6 +63,7 @@ LOCAL_MODULE := FAudioGMS
# Tell ndk-build we rely on these two fellas:
LOCAL_SHARED_LIBRARIES := SDL2 FAudio_static
LOCAL_C_INCLUDES := $(SDL_PATH)/include $(FAUDIO_PATH)/include $(FAUDIOGMS_PATH)/src
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)
LOCAL_SRC_FILES := $(FAUDIOGMS_PATH)/src/FAudioGMS.c $(LOCAL_PATH)/FAudioGMS_JNI.c
include $(BUILD_SHARED_LIBRARY)

View File

@ -27,6 +27,11 @@
/* These are the Native -> JNI conv wrappers, they must only be built for Android */
#ifdef __ANDROID__
/* no mangling please */
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#include <jni.h>
#include <FAudioGMS.h>
@ -103,9 +108,9 @@ Java_org_screwyoyo_faudiogms_FAudioGMSNative_FAudioGMS_1StreamingSound_1LoadOGG
JNIEXPORT jdouble JNICALL
Java_org_screwyoyo_faudiogms_FAudioGMSNative_FAudioGMS_1SoundInstance_1Play
(JNIEnv* jniEnv, jclass jniThis, jdouble _soundInstanceID, jdouble _loop)
(JNIEnv* jniEnv, jclass jniThis, jdouble _soundInstanceID)
{
FAudioGMS_SoundInstance_Play(_soundInstanceID, _loop);
FAudioGMS_SoundInstance_Play(_soundInstanceID);
return NOTHING;
}
@ -125,6 +130,22 @@ Java_org_screwyoyo_faudiogms_FAudioGMSNative_FAudioGMS_1SoundInstance_1Stop
return NOTHING;
}
JNIEXPORT jdouble JNICALL
Java_org_screwyoyo_faudiogms_FAudioGMSNative_FAudioGMS_1SoundInstance_1SetPlayRegion
(JNIEnv* jniEnv, jclass jniThis, jdouble _soundInstanceID, jdouble _startInMilliseconds, jdouble _endInMilliseconds)
{
FAudioGMS_SoundInstance_SetPlayRegion(_soundInstanceID, _startInMilliseconds, _endInMilliseconds);
return NOTHING;
}
JNIEXPORT jdouble JNICALL
Java_org_screwyoyo_faudiogms_FAudioGMSNative_FAudioGMS_1SoundInstance_1SetLoop
(JNIEnv* jniEnv, jclass jniThis, jdouble _soundInstanceID, jdouble _loop)
{
FAudioGMS_SoundInstance_SetLoop(_soundInstanceID, _loop);
return NOTHING;
}
JNIEXPORT jdouble JNICALL
Java_org_screwyoyo_faudiogms_FAudioGMSNative_FAudioGMS_1SoundInstance_1SetPan
(JNIEnv* jniEnv, jclass jniThis, jdouble _soundInstanceID, jdouble _pan)
@ -205,6 +226,14 @@ Java_org_screwyoyo_faudiogms_FAudioGMSNative_FAudioGMS_1SoundInstance_1SetBandPa
return NOTHING;
}
JNIEXPORT jdouble JNICALL
Java_org_screwyoyo_faudiogms_FAudioGMSNative_FAudioGMS_1SoundInstance_1QueueSoundInstance
(JNIEnv* jniEnv, jclass jniThis, jdouble _soundInstanceID, jdouble _queueSoundInstanceID)
{
FAudioGMS_SoundInstance_QueueSoundInstance(_soundInstanceID, _queueSoundInstanceID);
return NOTHING;
}
JNIEXPORT jdouble JNICALL
Java_org_screwyoyo_faudiogms_FAudioGMSNative_FAudioGMS_1SoundInstance_1GetPitch
(JNIEnv* jniEnv, jclass jniThis, jdouble _soundInstanceID)
@ -327,6 +356,22 @@ Java_org_screwyoyo_faudiogms_FAudioGMSNative_FAudioGMS_1SoundInstance_1SetEffect
return NOTHING;
}
JNIEXPORT jdouble JNICALL
Java_org_screwyoyo_faudiogms_FAudioGMSNative_FAudioGMS_1SetMasteringEffectChain
(JNIEnv* jniEnv, jclass jniThis, jdouble _effectChainID, double _effectGain)
{
FAudioGMS_SetMasteringEffectChain(_effectChainID, _effectGain);
return NOTHING;
}
JNIEXPORT jdouble JNICALL
Java_org_screwyoyo_faudiogms_FAudioGMSNative_FAudioGMS_1SetMasteringEffectGain
(JNIEnv* jniEnv, jclass jniThis, jdouble _effectGain)
{
FAudioGMS_SetMasteringEffectGain(_effectGain);
return NOTHING;
}
JNIEXPORT jdouble JNICALL
Java_org_screwyoyo_faudiogms_FAudioGMSNative_FAudioGMS_1SetListenerPosition
(JNIEnv* jniEnv, jclass jniThis, jdouble _x, jdouble _y, jdouble _z)
@ -383,6 +428,10 @@ Java_org_screwyoyo_faudiogms_FAudioGMSNative_FAudioGMS_1Destroy
return NOTHING;
}
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __ANDROID__ */
/* Do nothing for other platforms, because they, thankly, do not require JNI bindings... */

View File

@ -22,12 +22,14 @@ import android.content.res.AssetManager;
public class FAudioGMSBridge extends FAudioGMSNative implements IExtensionBase
{
public SDLActivity sdl;
public boolean paused;
public boolean handlenativepause; /* automatically pause all sounds on onPause or not? */
public boolean paused; /* are we currently paused */
public FAudioGMSBridge()
{
super();
paused = false;
handlenativepause = true; /* set this to false if you wish to handle pauses manually */
paused = false; /* this one must be false at initialization */
SDL.setContext(RunnerJNILib.GetApplicationContext());
sdl = new SDLActivity();
}
@ -62,7 +64,7 @@ public class FAudioGMSBridge extends FAudioGMSNative implements IExtensionBase
public void onPause()
{
sdl.onPause();
if (!paused)
if (handlenativepause && !paused)
{
paused = true;
FAudioGMS_PauseAll();
@ -72,7 +74,7 @@ public class FAudioGMSBridge extends FAudioGMSNative implements IExtensionBase
public void onResume()
{
sdl.onResume();
if (paused)
if (handlenativepause && paused)
{
paused = false;
FAudioGMS_ResumeAll();

View File

@ -18,10 +18,12 @@ public class FAudioGMSNative
public native double FAudioGMS_StreamingSound_LoadOGG(String filepath);
public native double FAudioGMS_SoundInstance_Play(double soundInstanceID, double loop);
public native double FAudioGMS_SoundInstance_Play(double soundInstanceID);
public native double FAudioGMS_SoundInstance_Pause(double soundInstanceID);
public native double FAudioGMS_SoundInstance_Stop(double soundInstanceID);
public native double FAudioGMS_SoundInstance_SetPlayRegion(double soundInstanceID, double startInMilliseconds, double endInMilliseconds);
public native double FAudioGMS_SoundInstance_SetLoop(double soundInstanceID, double loop);
public native double FAudioGMS_SoundInstance_SetPan(double soundInstanceID, double pan);
public native double FAudioGMS_SoundInstance_SetPitch(double soundInstanceID, double pitch);
public native double FAudioGMS_SoundInstance_SetVolume(double soundInstanceID, double volume);
@ -33,6 +35,8 @@ public class FAudioGMSNative
public native double FAudioGMS_SoundInstance_SetHighPassFilter(double soundInstanceID, double highPassFilter, double Q);
public native double FAudioGMS_SoundInstance_SetBandPassFilter(double soundInstanceID, double bandPassFilter, double Q);
public native double FAudioGMS_SoundInstance_QueueSoundInstance(double soundInstanceID, double queueSoundInstanceID);
public native double FAudioGMS_SoundInstance_GetPitch(double soundInstanceID);
public native double FAudioGMS_SoundInstance_GetVolume(double soundInstanceID);
public native double FAudioGMS_SoundInstance_GetTrackLengthInSeconds(double soundInstanceID);
@ -69,6 +73,9 @@ public class FAudioGMSNative
public native double FAudioGMS_SoundInstance_SetEffectChain(double soundInstanceID, double effectChainID, double effectGain);
public native double FAudioGMS_SoundInstance_SetEffectGain(double soundInstanceID, double effectGain);
public native double FAudioGMS_SetMasteringEffectChain(double effectChainID, double effectGain);
public native double FAudioGMS_SetMasteringEffectGain(double effectGain);
public native double FAudioGMS_SetListenerPosition(double x, double y, double z);
public native double FAudioGMS_SetListenerVelocity(double xVelocity, double yVelocity, double zVelocity);

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.