Update Android support once again and add a Windows NDK build script. (#1)

Co-authored-by: Nikita Krapivin <alienoom@yandex.ru>
Reviewed-on: MoonsideGames/FAudioGMS#1
Co-authored-by: Nikita Krapivin <nik@noreply.example.org>
Co-committed-by: Nikita Krapivin <nik@noreply.example.org>
main
Nikita Krapivin 2021-11-08 18:26:46 +00:00 committed by cosmonaut
parent 6ef79855ab
commit 2fd95ea452
17 changed files with 99 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... */

8
android/build.ndk.cmd Normal file
View File

@ -0,0 +1,8 @@
cd /d %~dp0
mkdir buildandroid
call ndk-build NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=Android.mk APP_ABI="armeabi-v7a arm64-v8a x86 x86_64" APP_PLATFORM=android-16 APP_MODULES="SDL2 FAudio_static FAudioGMS" NDK_OUT=buildandroid\obj NDK_LIBS_OUT=buildandroid\lib
xcopy /e /r /y buildandroid\lib ..\gamemaker\extensions\FAudioGMS\AndroidSource\libs
rd /s /q buildandroid

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);
@ -32,7 +34,9 @@ public class FAudioGMSNative
public native double FAudioGMS_SoundInstance_SetLowPassFilter(double soundInstanceID, double lowPassFilter, double Q);
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.