mirror of
https://github.com/love2d/love-android.git
synced 2026-08-12 00:20:57 +02:00
Pass sample rate and frames/buffer to opensl_latency.cpp to be used with Oboe later.
This commit is contained in:
@@ -120,7 +120,8 @@ LOCAL_SRC_FILES := \
|
||||
alc/uhjfilter.cpp \
|
||||
alc/uiddefs.cpp \
|
||||
alc/voice.cpp \
|
||||
alc/mixer/mixer_c.cpp
|
||||
alc/mixer/mixer_c.cpp \
|
||||
opensl_latency.cpp
|
||||
|
||||
#
|
||||
# Conditionals source files
|
||||
@@ -159,11 +160,6 @@ LOCAL_SRC_FILES += \
|
||||
alc/backends/opensl.cpp \
|
||||
alc/backends/wave.cpp
|
||||
|
||||
#
|
||||
# OpenSL latency setting workaround
|
||||
#
|
||||
LOCAL_SRC_FILES += opensl_latency.cpp
|
||||
|
||||
#
|
||||
# Libraries related
|
||||
#
|
||||
|
||||
@@ -66,9 +66,11 @@ public class GameActivity extends SDLActivity {
|
||||
public int safeAreaBottom = 0;
|
||||
public int safeAreaRight = 0;
|
||||
|
||||
private static native void nativeSetDefaultStreamValues(int sampleRate, int framesPerBurst);
|
||||
|
||||
@Override
|
||||
protected String[] getLibraries() {
|
||||
return new String[]{
|
||||
return new String[] {
|
||||
"c++_shared",
|
||||
"mpg123",
|
||||
"openal",
|
||||
@@ -117,6 +119,9 @@ public class GameActivity extends SDLActivity {
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindowManager().getDefaultDisplay().getMetrics(metrics);
|
||||
|
||||
// Set low-latency audio values
|
||||
nativeSetDefaultStreamValues(getAudioFreq(), getAudioSMP());
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT >= 28) {
|
||||
getWindow().getAttributes().layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_NEVER;
|
||||
shortEdgesMode = false;
|
||||
@@ -534,4 +539,28 @@ public class GameActivity extends SDLActivity {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getAudioSMP() {
|
||||
int smp = 256;
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT >= 17) {
|
||||
AudioManager a = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
|
||||
int b = Integer.parseInt(a.getProperty(AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER));
|
||||
return b > 0 ? b : smp;
|
||||
}
|
||||
|
||||
return smp;
|
||||
}
|
||||
|
||||
public int getAudioFreq() {
|
||||
int freq = 44100;
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT >= 17) {
|
||||
AudioManager a = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
|
||||
int b = Integer.parseInt(a.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE));
|
||||
return b > 0 ? b : freq;
|
||||
}
|
||||
|
||||
return freq;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user