mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-25 17:10:12 +00:00
(Android) Detects buffer size properly now on Android 4.2 and up -
bases requested latency on this. Old fallback applies for non-4.2
This commit is contained in:
parent
67f4f1b3ed
commit
d13542f12b
@ -163,6 +163,18 @@ public class MainMenuActivity extends PreferenceActivity {
|
||||
return Integer.parseInt(manager
|
||||
.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE));
|
||||
}
|
||||
|
||||
@TargetApi(17)
|
||||
public static int getLowLatencyBufferSize() {
|
||||
AudioManager manager = (AudioManager) MainMenuActivity.getInstance()
|
||||
.getApplicationContext()
|
||||
.getSystemService(Context.AUDIO_SERVICE);
|
||||
int buffersize = Integer.parseInt(manager
|
||||
.getProperty(AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER));
|
||||
|
||||
Log.i(TAG, "Queried ideal buffer size: " + buffersize);
|
||||
return buffersize;
|
||||
}
|
||||
|
||||
public static int getOptimalSamplingRate() {
|
||||
int ret;
|
||||
@ -251,8 +263,20 @@ public class MainMenuActivity extends PreferenceActivity {
|
||||
prefs.getBoolean("audio_rate_control", true));
|
||||
config.setInt("audio_out_rate",
|
||||
MainMenuActivity.getOptimalSamplingRate());
|
||||
config.setInt("audio_latency",
|
||||
prefs.getBoolean("audio_high_latency", false) ? 160 : 64);
|
||||
|
||||
int buffersize = 0;
|
||||
|
||||
if (android.os.Build.VERSION.SDK_INT >= 17) {
|
||||
buffersize = getLowLatencyBufferSize();
|
||||
if (config.getBoolean("audio_high_latency") == false) {
|
||||
config.setInt("audio_latency", buffersize / 32);
|
||||
}
|
||||
}
|
||||
else {
|
||||
config.setInt("audio_latency",
|
||||
prefs.getBoolean("audio_high_latency", false) ? 160 : 64);
|
||||
}
|
||||
|
||||
config.setBoolean("audio_enable",
|
||||
prefs.getBoolean("audio_enable", true));
|
||||
config.setBoolean("video_smooth",
|
||||
|
@ -115,6 +115,8 @@ static void *sl_init(const char *device, unsigned rate, unsigned latency)
|
||||
if (!sl)
|
||||
goto error;
|
||||
|
||||
RARCH_LOG("[SLES ] : Requested audio latency: %dms...", latency);
|
||||
|
||||
GOTO_IF_FAIL(slCreateEngine(&sl->engine_object, 0, NULL, 0, NULL, NULL));
|
||||
GOTO_IF_FAIL(SLObjectItf_Realize(sl->engine_object, SL_BOOLEAN_FALSE));
|
||||
GOTO_IF_FAIL(SLObjectItf_GetInterface(sl->engine_object, SL_IID_ENGINE, &sl->engine));
|
||||
|
Loading…
Reference in New Issue
Block a user