mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-13 13:28:49 +00:00
(Android) Set buffer count to 4 instead of 8 for Jelly Bean and
higher - test experimental lower latency for fast OpenSL mixer
This commit is contained in:
parent
321596fc73
commit
623822126a
@ -34,9 +34,10 @@ struct droid
|
||||
unsigned width;
|
||||
unsigned height;
|
||||
struct saved_state state;
|
||||
int version;
|
||||
};
|
||||
|
||||
extern struct droid g_android;
|
||||
|
||||
extern int android_get_sdk_version(void);
|
||||
|
||||
#endif
|
||||
|
@ -65,6 +65,11 @@ static void print_cur_config(struct android_app* android_app)
|
||||
AConfiguration_getUiModeNight(android_app->config));
|
||||
}
|
||||
|
||||
int android_get_sdk_version(void)
|
||||
{
|
||||
return AConfiguration_getSdkVersion(g_android.app->config);
|
||||
}
|
||||
|
||||
static void android_get_char_argv(char *argv, size_t sizeof_argv, const char *arg_name)
|
||||
{
|
||||
JNIEnv *env;
|
||||
@ -283,15 +288,11 @@ static void* android_app_entry(void* param)
|
||||
|
||||
char rom_path[512];
|
||||
char libretro_path[512];
|
||||
char android_version[16];
|
||||
|
||||
// Get arguments */
|
||||
android_get_char_argv(rom_path, sizeof(rom_path), "ROM");
|
||||
android_get_char_argv(libretro_path, sizeof(libretro_path), "LIBRETRO");
|
||||
android_get_char_argv(android_version, sizeof(android_version), "ANDROIDVER");
|
||||
g_android.version = atoi(android_version);
|
||||
|
||||
RARCH_LOG("Android version: %d\n", g_android.version);
|
||||
RARCH_LOG("Checking arguments passed...\n");
|
||||
RARCH_LOG("ROM Filename: [%s].\n", rom_path);
|
||||
RARCH_LOG("Libretro path: [%s].\n", libretro_path);
|
||||
|
@ -91,7 +91,6 @@ public class phoenix extends Activity
|
||||
myIntent = new Intent(this, NativeActivity.class);
|
||||
myIntent.putExtra("ROM", data.getStringExtra("PATH"));
|
||||
myIntent.putExtra("LIBRETRO", libretro_path);
|
||||
myIntent.putExtra("ANDROIDVER", Integer.toString(android.os.Build.VERSION.SDK_INT));
|
||||
startActivity(myIntent);
|
||||
}
|
||||
else
|
||||
|
@ -36,7 +36,6 @@
|
||||
|
||||
// TODO: Are these sane?
|
||||
#define BUFFER_SIZE 4096
|
||||
#define NUM_BUFFERS 8
|
||||
|
||||
typedef struct sl
|
||||
{
|
||||
@ -53,6 +52,7 @@ typedef struct sl
|
||||
slock_t *lock;
|
||||
scond_t *cond;
|
||||
bool nonblock;
|
||||
unsigned buf_count;
|
||||
} sl_t;
|
||||
|
||||
static void opensl_callback(SLAndroidSimpleBufferQueueItf bq, void *ctx)
|
||||
@ -132,6 +132,17 @@ static void *sl_init(const char *device, unsigned rate, unsigned latency)
|
||||
GOTO_IF_FAIL(SLEngineItf_CreateOutputMix(sl->engine, &sl->output_mix, 0, NULL, NULL));
|
||||
GOTO_IF_FAIL(SLObjectItf_Realize(sl->output_mix, SL_BOOLEAN_FALSE));
|
||||
|
||||
int api_level = android_get_sdk_version();
|
||||
if(api_level > 15)
|
||||
{
|
||||
RARCH_LOG("API level 16 and higher has a fast OpenSL mixer - adjust settings for lower audio latency...\n");
|
||||
sl->buf_count = 4;
|
||||
}
|
||||
else
|
||||
sl->buf_count = 8;
|
||||
|
||||
RARCH_LOG("[SLES] : Android API level [%d] detected, setting audio latency (buffer size: [%d])..\n", api_level, sl->buf_count * BUFFER_SIZE);
|
||||
|
||||
fmt_pcm.formatType = SL_DATAFORMAT_PCM;
|
||||
fmt_pcm.numChannels = 2;
|
||||
fmt_pcm.samplesPerSec = rate * 1000; // Samplerate is in milli-Hz.
|
||||
@ -144,7 +155,7 @@ static void *sl_init(const char *device, unsigned rate, unsigned latency)
|
||||
audio_src.pFormat = &fmt_pcm;
|
||||
|
||||
loc_bufq.locatorType = SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE;
|
||||
loc_bufq.numBuffers = NUM_BUFFERS;
|
||||
loc_bufq.numBuffers = sl->buf_count;
|
||||
|
||||
loc_outmix.locatorType = SL_DATALOCATOR_OUTPUTMIX;
|
||||
loc_outmix.outputMix = sl->output_mix;
|
||||
@ -161,7 +172,7 @@ static void *sl_init(const char *device, unsigned rate, unsigned latency)
|
||||
|
||||
sl->cond = scond_new();
|
||||
sl->lock = slock_new();
|
||||
sl->fifo = fifo_new(BUFFER_SIZE * NUM_BUFFERS);
|
||||
sl->fifo = fifo_new(BUFFER_SIZE * sl->buf_count);
|
||||
|
||||
(*buffer_queue)->RegisterCallback(buffer_queue, opensl_callback, sl);
|
||||
(*buffer_queue)->Enqueue(buffer_queue, sl->buffer, BUFFER_SIZE);
|
||||
@ -248,7 +259,8 @@ static size_t sl_write_avail(void *data)
|
||||
|
||||
static size_t sl_buffer_size(void *data)
|
||||
{
|
||||
return BUFFER_SIZE * NUM_BUFFERS;
|
||||
sl_t *sl = (sl_t*)data;
|
||||
return BUFFER_SIZE * sl->buf_count;
|
||||
}
|
||||
|
||||
const audio_driver_t audio_opensl = {
|
||||
|
@ -74,7 +74,7 @@ static inline bool input_key_pressed_func(int key)
|
||||
#define audio_free_func() sl_free(driver.audio_data)
|
||||
#define audio_use_float_func() driver.audio->use_float(driver.audio_data)
|
||||
#define audio_write_avail_func() sl_write_avail(driver.audio_data)
|
||||
#define audio_buffer_size_func() (BUFFER_SIZE * NUM_BUFFERS)
|
||||
#define audio_buffer_size_func() (BUFFER_SIZE * ((sl_t*)driver.audio_data)->buf_count)
|
||||
|
||||
#else
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user