mirror of
https://github.com/libretro/RetroArch.git
synced 2026-11-07 08:36:02 -10:00
(Android) Supply device-optimal audio defaults through the intent
The launch intent carries AUDIO_RATE and AUDIO_FRAMES extras with the AudioManager-reported optimal sample rate and buffer size. The frontend stores them in g_defaults and config_set_defaults applies them as the audio_out_rate and audio_block_frames defaults, so a value saved in the config file still overrides them on load.
This commit is contained in:
1 parent
3a93737c25
commit
992b34b727
3 files changed
+59
No files matched your search
@@ -5487,6 +5487,17 @@ void config_set_defaults(void *data)
|
||||
if (!g_defaults.settings_in_latency)
|
||||
g_defaults.settings_in_latency = DEFAULT_IN_LATENCY;
|
||||
|
||||
/* Device-optimal audio parameters supplied by the frontend.
|
||||
* Values saved in the config file still override these on
|
||||
* load. */
|
||||
if (g_defaults.settings_out_sample_rate > 0)
|
||||
settings->uints.audio_output_sample_rate =
|
||||
(unsigned)g_defaults.settings_out_sample_rate;
|
||||
|
||||
if (g_defaults.settings_out_block_frames > 0)
|
||||
settings->uints.audio_block_frames =
|
||||
(unsigned)g_defaults.settings_out_block_frames;
|
||||
|
||||
|
||||
audio_set_float(AUDIO_ACTION_VOLUME_GAIN, settings->floats.audio_volume);
|
||||
#ifdef HAVE_AUDIOMIXER
|
||||
|
||||
@@ -81,6 +81,11 @@ struct defaults
|
||||
#endif
|
||||
int settings_out_latency;
|
||||
int settings_in_latency;
|
||||
/* Device-optimal audio output parameters supplied by the
|
||||
* frontend; 0 means the frontend has no opinion and the
|
||||
* built-in defaults apply. */
|
||||
int settings_out_sample_rate;
|
||||
int settings_out_block_frames;
|
||||
#ifdef HAVE_MENU
|
||||
unsigned menu_materialui_menu_color_theme;
|
||||
#endif
|
||||
|
||||
@@ -1989,6 +1989,49 @@ static void frontend_unix_get_env(int *argc,
|
||||
}
|
||||
}
|
||||
|
||||
/* Device-optimal audio output parameters, queried from
|
||||
* AudioManager on the Java side. These become the defaults;
|
||||
* values saved in the config file still win. */
|
||||
CALL_OBJ_METHOD_PARAM(env, jstr, obj, android_app->getStringExtra,
|
||||
(*env)->NewStringUTF(env, "AUDIO_RATE"));
|
||||
|
||||
if (android_app->getStringExtra && jstr)
|
||||
{
|
||||
const char *argv = (*env)->GetStringUTFChars(env, jstr, 0);
|
||||
int rate = 0;
|
||||
|
||||
if (argv && *argv)
|
||||
rate = atoi(argv);
|
||||
(*env)->ReleaseStringUTFChars(env, jstr, argv);
|
||||
|
||||
if (rate > 0)
|
||||
{
|
||||
g_defaults.settings_out_sample_rate = rate;
|
||||
__android_log_print(ANDROID_LOG_INFO,
|
||||
"RetroArch", "[ENV] Device sample rate: %d Hz.\n", rate);
|
||||
}
|
||||
}
|
||||
|
||||
CALL_OBJ_METHOD_PARAM(env, jstr, obj, android_app->getStringExtra,
|
||||
(*env)->NewStringUTF(env, "AUDIO_FRAMES"));
|
||||
|
||||
if (android_app->getStringExtra && jstr)
|
||||
{
|
||||
const char *argv = (*env)->GetStringUTFChars(env, jstr, 0);
|
||||
int frames = 0;
|
||||
|
||||
if (argv && *argv)
|
||||
frames = atoi(argv);
|
||||
(*env)->ReleaseStringUTFChars(env, jstr, argv);
|
||||
|
||||
if (frames > 0)
|
||||
{
|
||||
g_defaults.settings_out_block_frames = frames;
|
||||
__android_log_print(ANDROID_LOG_INFO,
|
||||
"RetroArch", "[ENV] Device audio block frames: %d.\n", frames);
|
||||
}
|
||||
}
|
||||
|
||||
/* Content. */
|
||||
CALL_OBJ_METHOD_PARAM(env, jstr, obj, android_app->getStringExtra,
|
||||
(*env)->NewStringUTF(env, "DATADIR"));
|
||||
|
||||
Reference in new issue
Block a user