mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-01-20 01:43:37 +00:00
Add video_threaded option to Android.
This commit is contained in:
parent
2cd60e0551
commit
76bf41188a
@ -6,7 +6,6 @@ HAVE_SINC := 1
|
||||
HAVE_LOGGER := 1
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
ifeq ($(TARGET_ARCH),arm)
|
||||
LOCAL_CFLAGS += -DANDROID_ARM -marm
|
||||
LOCAL_ARM_MODE := arm
|
||||
@ -52,7 +51,7 @@ ifeq ($(PERF_TEST), 1)
|
||||
LOCAL_CFLAGS += -DPERF_TEST
|
||||
endif
|
||||
|
||||
LOCAL_CFLAGS += -Wall -Wno-unused-function -O3 -fno-stack-protector -funroll-loops -DNDEBUG -DHAVE_GRIFFIN -DANDROID -DHAVE_DYNAMIC -DHAVE_OPENGL -DHAVE_FBO -DHAVE_OVERLAY -DHAVE_OPENGLES -DHAVE_VID_CONTEXT -DHAVE_OPENGLES2 -DGLSL_DEBUG -DHAVE_GLSL -DWANT_RZLIB -DHAVE_ZLIB -DINLINE=inline -DLSB_FIRST -DHAVE_THREAD -D__LIBRETRO__ -DRARCH_PERFORMANCE_MODE -DPACKAGE_VERSION=\"$(RARCH_VERSION)\" -std=gnu99 -I../../../deps/rzlib
|
||||
LOCAL_CFLAGS += -Wall -pthread -Wno-unused-function -O3 -fno-stack-protector -funroll-loops -DNDEBUG -DHAVE_GRIFFIN -DANDROID -DHAVE_DYNAMIC -DHAVE_OPENGL -DHAVE_FBO -DHAVE_OVERLAY -DHAVE_OPENGLES -DHAVE_VID_CONTEXT -DHAVE_OPENGLES2 -DGLSL_DEBUG -DHAVE_GLSL -DWANT_RZLIB -DHAVE_ZLIB -DINLINE=inline -DLSB_FIRST -DHAVE_THREADS -D__LIBRETRO__ -DRARCH_PERFORMANCE_MODE -DPACKAGE_VERSION=\"$(RARCH_VERSION)\" -std=gnu99 -I../../../deps/rzlib
|
||||
|
||||
LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -landroid -lEGL -lGLESv2 $(LOGGER_LDLIBS) -ldl
|
||||
|
||||
|
@ -81,12 +81,16 @@
|
||||
android:title="Aspect ratio" />
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory android:title="Synchronization" >
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="true"
|
||||
android:key="video_threaded"
|
||||
android:summary="Uses a multi-threaded video driver. Is likely to improve performance at the expense of slightly more latency and jitter. Use this if you have troubles getting good video and audio."
|
||||
android:title="Threaded video driver" />
|
||||
<EditTextPreference
|
||||
android:key="video_refresh_rate"
|
||||
android:numeric="decimal"
|
||||
android:summary="Force a specific refresh rate to be detected. Only set manually if calibration reports wrong refresh rate."
|
||||
android:title="Forced refresh rate (Hz)" />
|
||||
|
||||
<Preference
|
||||
android:summary="Attempts to find the true refresh rate of monitor. Updates value in 'Force refresh rate (Hz)' option. To help ensure accuracy, make sure no intense background services are running, and avoid triggering screensaver."
|
||||
android:title="Calibrate refresh rate" >
|
||||
|
@ -371,6 +371,7 @@ public class RetroArch extends Activity implements
|
||||
config.setInt("input_autodetect_icade_profile_pad4", prefs.getInt("input_autodetect_icade_profile_pad4", 0));
|
||||
|
||||
config.setDouble("video_refresh_rate", getRefreshRate());
|
||||
config.setBoolean("video_threaded", prefs.getBoolean("video_threaded", true));
|
||||
|
||||
String aspect = prefs.getString("video_aspect_ratio", "auto");
|
||||
if (aspect.equals("full")) {
|
||||
|
@ -31,12 +31,10 @@
|
||||
#define M_PI 3.14159265358979323846264338327
|
||||
#endif
|
||||
|
||||
typedef float sample_t;
|
||||
|
||||
struct resampler_data
|
||||
{
|
||||
const sample_t *data_in;
|
||||
sample_t *data_out;
|
||||
const float *data_in;
|
||||
float *data_out;
|
||||
|
||||
size_t input_frames;
|
||||
size_t output_frames;
|
||||
|
19
audio/sinc.c
19
audio/sinc.c
@ -104,9 +104,9 @@
|
||||
|
||||
typedef struct rarch_sinc_resampler
|
||||
{
|
||||
sample_t *phase_table;
|
||||
sample_t *buffer_l;
|
||||
sample_t *buffer_r;
|
||||
float *phase_table;
|
||||
float *buffer_l;
|
||||
float *buffer_r;
|
||||
|
||||
unsigned taps;
|
||||
|
||||
@ -115,7 +115,7 @@ typedef struct rarch_sinc_resampler
|
||||
|
||||
// A buffer for phase_table, buffer_l and buffer_r are created in a single calloc().
|
||||
// Ensure that we get as good cache locality as we can hope for.
|
||||
sample_t *main_buffer;
|
||||
float *main_buffer;
|
||||
} rarch_sinc_resampler_t;
|
||||
|
||||
static inline double sinc(double val)
|
||||
@ -389,9 +389,10 @@ static void process_sinc_neon(rarch_sinc_resampler_t *resamp, float *out_buffer)
|
||||
const float *buffer_r = resamp->buffer_r + resamp->ptr;
|
||||
|
||||
unsigned phase = resamp->time >> SUBPHASE_BITS;
|
||||
const float *phase_table = resamp->phase_table[phase];
|
||||
unsigned taps = resamp->taps;
|
||||
const float *phase_table = resamp->phase_table + phase * taps;
|
||||
|
||||
process_sinc_neon_asm(out_buffer, buffer_l, buffer_r, phase_table, resamp->taps);
|
||||
process_sinc_neon_asm(out_buffer, buffer_l, buffer_r, phase_table, taps);
|
||||
}
|
||||
#else // Plain ol' C99
|
||||
#define process_sinc_func process_sinc_C
|
||||
@ -403,8 +404,8 @@ static void resampler_sinc_process(void *re_, struct resampler_data *data)
|
||||
|
||||
uint32_t ratio = PHASES / data->ratio;
|
||||
|
||||
const sample_t *input = data->data_in;
|
||||
sample_t *output = data->data_out;
|
||||
const float *input = data->data_in;
|
||||
float *output = data->data_out;
|
||||
size_t frames = data->input_frames;
|
||||
size_t out_frames = 0;
|
||||
|
||||
@ -475,7 +476,7 @@ static void *resampler_sinc_new(double bandwidth_mod)
|
||||
#endif
|
||||
size_t elems = phase_elems + 4 * re->taps;
|
||||
|
||||
re->main_buffer = (sample_t*)aligned_alloc__(128, sizeof(sample_t) * elems);
|
||||
re->main_buffer = (float*)aligned_alloc__(128, sizeof(float) * elems);
|
||||
if (!re->main_buffer)
|
||||
goto error;
|
||||
|
||||
|
@ -377,15 +377,18 @@ RETROARCH
|
||||
/*============================================================
|
||||
THREAD
|
||||
============================================================ */
|
||||
// This is supposed to be HAVE_THREADS.
|
||||
#if defined(HAVE_THREAD) && defined(XENON)
|
||||
#include "../../thread/xenon_sdl_threads.c"
|
||||
#elif defined(HAVE_THREAD)
|
||||
#elif defined(HAVE_THREADS)
|
||||
#include "../../thread.c"
|
||||
#include "../../gfx/thread_wrapper.c"
|
||||
#ifdef ANDROID
|
||||
#include "../../autosave.c"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/*============================================================
|
||||
NETPLAY
|
||||
============================================================ */
|
||||
|
2
driver.c
2
driver.c
@ -424,7 +424,7 @@ void init_audio(void)
|
||||
g_extern.audio_data.data_ptr = 0;
|
||||
|
||||
rarch_assert(g_settings.audio.out_rate < g_settings.audio.in_rate * AUDIO_MAX_RATIO);
|
||||
rarch_assert(g_extern.audio_data.outsamples = (sample_t*)malloc(outsamples_max * sizeof(sample_t)));
|
||||
rarch_assert(g_extern.audio_data.outsamples = (float*)malloc(outsamples_max * sizeof(float)));
|
||||
|
||||
if (g_extern.audio_active && g_settings.audio.rate_control)
|
||||
{
|
||||
|
@ -18,7 +18,7 @@
|
||||
#ifndef _RARCH_DRIVER_FUNCS_H
|
||||
#define _RARCH_DRIVER_FUNCS_H
|
||||
|
||||
#if !defined(HAVE_GRIFFIN) /* Normal */
|
||||
#if !defined(HAVE_GRIFFIN) || defined(ANDROID) /* Normal */
|
||||
|
||||
#define audio_init_func(device, rate, latency) driver.audio->init(device, rate, latency)
|
||||
#define audio_write_func(buf, size) driver.audio->write(driver.audio_data, buf, size)
|
||||
|
@ -397,7 +397,7 @@ struct global
|
||||
bool use_float;
|
||||
bool mute;
|
||||
|
||||
sample_t *outsamples;
|
||||
float *outsamples;
|
||||
int16_t *conv_outsamples;
|
||||
|
||||
int16_t *rewind_buf;
|
||||
|
@ -15,10 +15,12 @@
|
||||
*/
|
||||
|
||||
#include "../../driver.h"
|
||||
#include "../../general.h"
|
||||
#include "../gfx_common.h"
|
||||
#include "../gl_common.h"
|
||||
|
||||
#include <EGL/egl.h> /* Requires NDK r5 or newer */
|
||||
#include <android/looper.h>
|
||||
|
||||
#include "../../frontend/frontend_android.h"
|
||||
#include "../image.h"
|
||||
@ -148,6 +150,10 @@ static bool gfx_ctx_init(void)
|
||||
goto error;
|
||||
}
|
||||
|
||||
ALooper *looper = ALooper_forThread();
|
||||
if (!looper)
|
||||
ALooper_prepare(ALOOPER_PREPARE_ALLOW_NON_CALLBACKS);
|
||||
|
||||
return true;
|
||||
|
||||
error:
|
||||
|
@ -340,7 +340,6 @@ static bool thread_frame(void *data, const void *frame_,
|
||||
for (unsigned h = 0; h < height; h++, src += pitch, dst += copy_stride)
|
||||
memcpy(dst, src, copy_stride);
|
||||
thr->frame.updated = true;
|
||||
scond_signal(thr->cond_thread);
|
||||
thr->frame.width = width;
|
||||
thr->frame.height = height;
|
||||
thr->frame.pitch = copy_stride;
|
||||
@ -350,6 +349,7 @@ static bool thread_frame(void *data, const void *frame_,
|
||||
else
|
||||
*thr->frame.msg = '\0';
|
||||
|
||||
scond_signal(thr->cond_thread);
|
||||
slock_unlock(thr->frame.lock);
|
||||
}
|
||||
slock_unlock(thr->lock);
|
||||
@ -380,16 +380,21 @@ static bool thread_init(thread_video_t *thr, const video_info_t *info, const inp
|
||||
thr->alive = true;
|
||||
thr->focus = true;
|
||||
|
||||
thr->frame.buffer = (uint8_t*)malloc((info->rgb32 ? sizeof(uint32_t) : sizeof(uint16_t)) *
|
||||
info->input_scale * info->input_scale * RARCH_SCALE_BASE * RARCH_SCALE_BASE);
|
||||
size_t max_size = info->input_scale * RARCH_SCALE_BASE;
|
||||
max_size *= max_size;
|
||||
max_size *= info->rgb32 ? sizeof(uint32_t) : sizeof(uint16_t);
|
||||
thr->frame.buffer = (uint8_t*)malloc(max_size);
|
||||
if (!thr->frame.buffer)
|
||||
return false;
|
||||
|
||||
memset(thr->frame.buffer, 0x80, max_size);
|
||||
|
||||
thr->thread = sthread_create(thread_loop, thr);
|
||||
if (!thr->thread)
|
||||
return false;
|
||||
thread_send_cmd(thr, CMD_INIT);
|
||||
thread_wait_reply(thr, CMD_INIT);
|
||||
|
||||
return thr->cmd_data.b;
|
||||
}
|
||||
|
||||
|
@ -1023,7 +1023,7 @@ static void ffemu_audio_resample(ffemu_t *handle, struct ffemu_audio_data *data)
|
||||
{
|
||||
// It's always two channels ...
|
||||
struct resampler_data info = {0};
|
||||
info.data_in = (const sample_t*)data->data;
|
||||
info.data_in = (const float*)data->data;
|
||||
info.data_out = handle->audio.resample_out;
|
||||
info.input_frames = data->frames;
|
||||
info.ratio = handle->audio.ratio;
|
||||
|
@ -366,7 +366,7 @@ static bool audio_flush(const int16_t *data, size_t samples)
|
||||
if (!g_extern.audio_active)
|
||||
return false;
|
||||
|
||||
const sample_t *output_data = NULL;
|
||||
const float *output_data = NULL;
|
||||
unsigned output_frames = 0;
|
||||
|
||||
struct resampler_data src_data = {0};
|
||||
|
Loading…
x
Reference in New Issue
Block a user