mirror of
https://github.com/libretro/RetroArch
synced 2025-03-27 14:37:32 +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
@ -164,6 +164,18 @@ public class MainMenuActivity extends PreferenceActivity {
|
|||||||
.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE));
|
.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() {
|
public static int getOptimalSamplingRate() {
|
||||||
int ret;
|
int ret;
|
||||||
if (android.os.Build.VERSION.SDK_INT >= 17)
|
if (android.os.Build.VERSION.SDK_INT >= 17)
|
||||||
@ -251,8 +263,20 @@ public class MainMenuActivity extends PreferenceActivity {
|
|||||||
prefs.getBoolean("audio_rate_control", true));
|
prefs.getBoolean("audio_rate_control", true));
|
||||||
config.setInt("audio_out_rate",
|
config.setInt("audio_out_rate",
|
||||||
MainMenuActivity.getOptimalSamplingRate());
|
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",
|
config.setBoolean("audio_enable",
|
||||||
prefs.getBoolean("audio_enable", true));
|
prefs.getBoolean("audio_enable", true));
|
||||||
config.setBoolean("video_smooth",
|
config.setBoolean("video_smooth",
|
||||||
|
@ -115,6 +115,8 @@ static void *sl_init(const char *device, unsigned rate, unsigned latency)
|
|||||||
if (!sl)
|
if (!sl)
|
||||||
goto error;
|
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(slCreateEngine(&sl->engine_object, 0, NULL, 0, NULL, NULL));
|
||||||
GOTO_IF_FAIL(SLObjectItf_Realize(sl->engine_object, SL_BOOLEAN_FALSE));
|
GOTO_IF_FAIL(SLObjectItf_Realize(sl->engine_object, SL_BOOLEAN_FALSE));
|
||||||
GOTO_IF_FAIL(SLObjectItf_GetInterface(sl->engine_object, SL_IID_ENGINE, &sl->engine));
|
GOTO_IF_FAIL(SLObjectItf_GetInterface(sl->engine_object, SL_IID_ENGINE, &sl->engine));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user