Skip to content

Commit

Permalink
* Update MiniAudio to 0.11.21
Browse files Browse the repository at this point in the history
* Update libGDX to 1.12.1
* Allow to disable low latency mode
  • Loading branch information
fgnm committed Dec 4, 2023
1 parent e89e638 commit a7e4868
Show file tree
Hide file tree
Showing 6 changed files with 1,920 additions and 913 deletions.
4 changes: 3 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[0.4]
- Update MiniAudio to 0.11.14
- Update MiniAudio to 0.11.21
- Update libGDX to 1.12.1
- Support MASound end callback
- Allow to disable low latency mode

[0.3]
- Full MiniAudio engine customization
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
jniGenVersion=2.3.1
gdxVersion=1.11.0
miniaudioVersion=0.3-SNAPSHOT
gdxVersion=1.12.1
miniaudioVersion=0.4-SNAPSHOT
2,810 changes: 1,907 additions & 903 deletions jni/miniaudio.h

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions src/main/java/games/rednblack/miniaudio/MiniAudio.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public MiniAudio(boolean initEngine) {
throw new MiniAudioException("Unable to init MiniAudio Context", result);
}

if (initEngine) initEngine(1, -1, -1, 0, 0, 0, 0, MAFormatType.F32, false, false);
if (initEngine) initEngine(1, -1, -1, 0, 0, 0, 0, MAFormatType.F32, false, false, true);
endCallbackSound = new MASound(this);
}

Expand All @@ -143,14 +143,15 @@ public MiniAudio(boolean initEngine) {
* @param formatType devices data format, see {@link MAFormatType}
* @param fullDuplex enable/disable full duplex engine (require microphone permission)
* @param exclusive enable/disable capture exclusive device mode
* @param lowLatency enable/disable low latency profile
*/
public void initEngine(int listenerCount, long playbackId, long captureId, int channels, int bufferPeriodMillis, int bufferPeriodFrames, int sampleRate, MAFormatType formatType, boolean fullDuplex, boolean exclusive) {
public void initEngine(int listenerCount, long playbackId, long captureId, int channels, int bufferPeriodMillis, int bufferPeriodFrames, int sampleRate, MAFormatType formatType, boolean fullDuplex, boolean exclusive, boolean lowLatency) {
if (engineAddress != 0) throw new IllegalStateException("A MiniAudio Engine is already initialized.");

if (listenerCount < 1 || listenerCount > MA_ENGINE_MAX_LISTENERS)
throw new IllegalArgumentException("Listeners must be between 1 and MA_ENGINE_MAX_LISTENERS");

int result = jniInitEngine(listenerCount, playbackId, captureId, channels, bufferPeriodMillis, bufferPeriodFrames, sampleRate, formatType.code, fullDuplex, exclusive);
int result = jniInitEngine(listenerCount, playbackId, captureId, channels, bufferPeriodMillis, bufferPeriodFrames, sampleRate, formatType.code, fullDuplex, exclusive, lowLatency);
if (result != MAResult.MA_SUCCESS) {
throw new MiniAudioException("Unable to init MiniAudio Engine", result);
}
Expand Down Expand Up @@ -179,7 +180,7 @@ public void setLogLevel(MALogLevel logLevel) {

/**
* Enumerate every device attached to the device with their capabilities,
* check devices before {@link #initEngine(int, long, long, int, int, int, int, MAFormatType, boolean, boolean)}
* check devices before {@link #initEngine(int, long, long, int, int, int, int, MAFormatType, boolean, boolean, boolean)}
*
* @return array of devices information
*/
Expand Down Expand Up @@ -332,7 +333,7 @@ public MADeviceInfo[] enumerateDevices() {
return ret;
*/

private native int jniInitEngine(int listenerCount, long playbackId, long captureId, int channels, int bufferPeriodMillis, int bufferPeriodFrames, int sampleRate, int format, boolean fullDuplex, boolean exclusive);/*
private native int jniInitEngine(int listenerCount, long playbackId, long captureId, int channels, int bufferPeriodMillis, int bufferPeriodFrames, int sampleRate, int format, boolean fullDuplex, boolean exclusive, boolean lowLatency);/*
ma_result res;
ma_device_config deviceConfig;
if (fullDuplex)
Expand All @@ -348,7 +349,7 @@ public MADeviceInfo[] enumerateDevices() {
deviceConfig.playback.channels = channels;
deviceConfig.sampleRate = sampleRate;
deviceConfig.dataCallback = data_callback;
deviceConfig.performanceProfile = ma_performance_profile_low_latency;
deviceConfig.performanceProfile = lowLatency ? ma_performance_profile_low_latency : ma_performance_profile_conservative;
deviceConfig.periodSizeInFrames = bufferPeriodFrames;
deviceConfig.periodSizeInMilliseconds = bufferPeriodMillis;
deviceConfig.wasapi.noAutoConvertSRC = true;
Expand Down
2 changes: 1 addition & 1 deletion testApp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies {
implementation "com.badlogicgames.gdx:gdx:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
//implementation "games.rednblack.miniaudio:miniaudio:$miniaudioVersion:natives-desktop"
implementation "games.rednblack.miniaudio:miniaudio:$miniaudioVersion:natives-desktop"

implementation project(":")

Expand Down
Binary file modified testApp/src/main/resources/libgdx-miniaudio64.so
Binary file not shown.

0 comments on commit a7e4868

Please sign in to comment.