Add null camera - remove HAVE_CAMERA ifdefs

This commit is contained in:
twinaphex 2014-08-14 02:55:04 +02:00
parent 027bd68bb3
commit e1a122843b
16 changed files with 64 additions and 64 deletions

View File

@ -45,6 +45,7 @@ OBJ = frontend/frontend.o \
audio/sinc.o \
audio/cc_resampler.o \
location/null.o \
camera/nullcamera.o \
performance.o
@ -180,7 +181,7 @@ endif
ifeq ($(HAVE_V4L2),1)
OBJ += camera/video4linux2.o
DEFINES += -DHAVE_CAMERA -DHAVE_V4L2
DEFINES += -DHAVE_V4L2
endif
ifeq ($(HAVE_JACK),1)

View File

@ -51,6 +51,8 @@ OBJ = frontend/platform/platform_emscripten.o \
audio/null.o \
performance.o \
core_info.o \
location/null.o \
camera/nullcamera.o \
camera/rwebcam.o
HAVE_OPENGL = 1
@ -71,7 +73,7 @@ endif
libretro = libretro_emscripten.bc
LIBS =
DEFINES = -DHAVE_CAMERA -DHAVE_NULLAUDIO -DRARCH_INTERNAL -DHAVE_CC_RESAMPLER
DEFINES = -DHAVE_NULLAUDIO -DRARCH_INTERNAL -DHAVE_CC_RESAMPLER
LDFLAGS = -L. -s TOTAL_MEMORY=$(MEMORY) -s OUTLINING_LIMIT=50000 --js-library emscripten/library_rwebaudio.js --js-library emscripten/library_rwebinput.js --js-library emscripten/library_rwebcam.js --no-heap-copy
ifeq ($(HAVE_RGUI), 1)

View File

@ -50,6 +50,7 @@ OBJ = frontend/frontend.o \
audio/sinc.o \
audio/cc_resampler.o \
location/null.o \
camera/nullcamera.o \
performance.o
JOBJ := conf/config_file.o \

View File

@ -54,7 +54,7 @@ else
GLES_LIB := -lGLESv2
endif
LOCAL_CFLAGS += -Wall -pthread -Wno-unused-function -fno-stack-protector -funroll-loops -DNDEBUG -DRARCH_MOBILE -DHAVE_GRIFFIN -DANDROID -DHAVE_DYNAMIC -DHAVE_OPENGL -DHAVE_FBO -DHAVE_OVERLAY -DHAVE_OPENGLES -DHAVE_OPENGLES2 -DGLSL_DEBUG -DHAVE_DYLIB -DHAVE_GLSL -DHAVE_MENU -DHAVE_RGUI -DHAVE_ZLIB -DINLINE=inline -DLSB_FIRST -DHAVE_THREADS -D__LIBRETRO__ -DHAVE_RSOUND -DHAVE_NETPLAY -DHAVE_CAMERA -DRARCH_INTERNAL -DHAVE_CC_RESAMPLER -DHAVE_FILTERS_BUILTIN
LOCAL_CFLAGS += -Wall -pthread -Wno-unused-function -fno-stack-protector -funroll-loops -DNDEBUG -DRARCH_MOBILE -DHAVE_GRIFFIN -DANDROID -DHAVE_DYNAMIC -DHAVE_OPENGL -DHAVE_FBO -DHAVE_OVERLAY -DHAVE_OPENGLES -DHAVE_OPENGLES2 -DGLSL_DEBUG -DHAVE_DYLIB -DHAVE_GLSL -DHAVE_MENU -DHAVE_RGUI -DHAVE_ZLIB -DINLINE=inline -DLSB_FIRST -DHAVE_THREADS -D__LIBRETRO__ -DHAVE_RSOUND -DHAVE_NETPLAY -DRARCH_INTERNAL -DHAVE_CC_RESAMPLER -DHAVE_FILTERS_BUILTIN
LOCAL_CFLAGS += -O2

50
camera/nullcamera.c Normal file
View File

@ -0,0 +1,50 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Michael Lelli
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "../driver.h"
static void *nullcamera_init(const char *device, uint64_t caps, unsigned width, unsigned height)
{
(void)device;
return (void*)-1;
}
static void nullcamera_free(void *data)
{
}
static bool nullcamera_start(void *data)
{
return true;
}
static void nullcamera_stop(void *data)
{
}
static bool nullcamera_poll(void *data, retro_camera_frame_raw_framebuffer_t frame_raw_cb,
retro_camera_frame_opengl_texture_t frame_gl_cb)
{
return true;
}
const camera_driver_t camera_null = {
nullcamera_init,
nullcamera_free,
nullcamera_start,
nullcamera_stop,
nullcamera_poll,
"null",
};

View File

@ -272,7 +272,6 @@ void uninit_osk(void)
}
#endif
#ifdef HAVE_CAMERA
static const camera_driver_t *camera_drivers[] = {
#ifdef HAVE_V4L2
&camera_v4l2,
@ -286,6 +285,7 @@ static const camera_driver_t *camera_drivers[] = {
#ifdef IOS
&camera_ios,
#endif
&camera_null,
NULL,
};
@ -399,7 +399,6 @@ void uninit_camera(void)
}
driver.camera_data = NULL;
}
#endif
static const location_driver_t *location_drivers[] = {
#ifdef ANDROID
@ -773,9 +772,7 @@ void init_drivers_pre(void)
find_audio_driver();
find_video_driver();
find_input_driver();
#ifdef HAVE_CAMERA
find_camera_driver();
#endif
find_location_driver();
#ifdef HAVE_OSK
find_osk_driver();
@ -935,9 +932,7 @@ void init_drivers(void)
driver.video_data_own = false;
driver.audio_data_own = false;
driver.input_data_own = false;
#ifdef HAVE_CAMERA
driver.camera_data_own = false;
#endif
driver.location_data_own = false;
#ifdef HAVE_OSK
driver.osk_data_own = false;
@ -959,11 +954,9 @@ void init_drivers(void)
init_audio();
#ifdef HAVE_CAMERA
// Only initialize camera driver if we're ever going to use it.
if (g_extern.camera_active)
init_camera();
#endif
// Only initialize location driver if we're ever going to use it.
if (g_extern.location_active)
@ -1058,13 +1051,11 @@ void uninit_drivers(void)
if (!driver.video_data_own)
driver.video_data = NULL;
#ifdef HAVE_CAMERA
if (!driver.camera_data_own)
{
uninit_camera();
driver.camera_data = NULL;
}
#endif
if (!driver.location_data_own)
{

View File

@ -419,10 +419,8 @@ typedef struct driver
const input_osk_driver_t *osk;
void *osk_data;
#endif
#ifdef HAVE_CAMERA
const camera_driver_t *camera;
void *camera_data;
#endif
const location_driver_t *location;
void *location_data;
void *audio_data;
@ -452,9 +450,7 @@ typedef struct driver
bool video_data_own;
bool audio_data_own;
bool input_data_own;
#ifdef HAVE_CAMERA
bool camera_data_own;
#endif
bool location_data_own;
#ifdef HAVE_OSK
bool osk_data_own;
@ -520,12 +516,10 @@ void find_next_audio_driver(void);
void find_next_input_driver(void);
void find_next_resampler_driver(void);
#ifdef HAVE_CAMERA
void init_camera(void);
void uninit_camera(void);
void find_prev_camera_driver(void);
void find_next_camera_driver(void);
#endif
void init_location(void);
void uninit_location(void);
@ -558,11 +552,9 @@ unsigned dspfilter_get_last_idx(void);
const char *rarch_dspfilter_get_name(void *data);
// Used by RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE
#ifdef HAVE_CAMERA
bool driver_camera_start(void);
void driver_camera_stop(void);
void driver_camera_poll(void);
#endif
// Used by RETRO_ENVIRONMENT_GET_LOCATION_INTERFACE
bool driver_location_start(void);
@ -636,6 +628,7 @@ extern const camera_driver_t camera_v4l2;
extern const camera_driver_t camera_android;
extern const camera_driver_t camera_rwebcam;
extern const camera_driver_t camera_ios;
extern const camera_driver_t camera_null;
extern const location_driver_t location_apple;
extern const location_driver_t location_android;
extern const location_driver_t location_null;

View File

@ -379,9 +379,7 @@ void uninit_libretro_sym(void)
free(g_extern.system.special);
free(g_extern.system.ports);
memset(&g_extern.system, 0, sizeof(g_extern.system));
#ifdef HAVE_CAMERA
g_extern.camera_active = false;
#endif
g_extern.location_active = false;
// Performance counters no longer valid.
@ -820,7 +818,6 @@ bool rarch_environment_cb(unsigned cmd, void *data)
break;
}
#ifdef HAVE_CAMERA
case RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE:
{
RARCH_LOG("Environ GET_CAMERA_INTERFACE.\n");
@ -831,7 +828,7 @@ bool rarch_environment_cb(unsigned cmd, void *data)
g_extern.camera_active = cb->caps != 0;
break;
}
#endif
case RETRO_ENVIRONMENT_GET_LOCATION_INTERFACE:
{
RARCH_LOG("Environ GET_LOCATION_INTERFACE.\n");

View File

@ -312,9 +312,7 @@ static void menu_common_entries_init(menu_handle_t *menu, unsigned menu_type)
break;
case MENU_SETTINGS_PRIVACY_OPTIONS:
file_list_clear(menu->selection_buf);
#ifdef HAVE_CAMERA
file_list_push(menu->selection_buf, "", "camera_allow", MENU_SETTINGS_PRIVACY_CAMERA_ALLOW, 0);
#endif
file_list_push(menu->selection_buf, "", "location_allow", MENU_SETTINGS_PRIVACY_LOCATION_ALLOW, 0);
break;
case MENU_SETTINGS_DISK_OPTIONS:
@ -408,9 +406,7 @@ static void menu_common_entries_init(menu_handle_t *menu, unsigned menu_type)
file_list_push(menu->selection_buf, "Audio Driver", "", MENU_SETTINGS_DRIVER_AUDIO, 0);
file_list_push(menu->selection_buf, "Audio Resampler", "", MENU_SETTINGS_DRIVER_AUDIO_RESAMPLER, 0);
file_list_push(menu->selection_buf, "Input Driver", "", MENU_SETTINGS_DRIVER_INPUT, 0);
#ifdef HAVE_CAMERA
file_list_push(menu->selection_buf, "Camera Driver", "", MENU_SETTINGS_DRIVER_CAMERA, 0);
#endif
file_list_push(menu->selection_buf, "Location Driver", "", MENU_SETTINGS_DRIVER_LOCATION, 0);
#ifdef HAVE_MENU
file_list_push(menu->selection_buf, "Menu Driver", "", MENU_SETTINGS_DRIVER_MENU, 0);
@ -3791,14 +3787,12 @@ static int menu_common_setting_set(unsigned id, unsigned action, rarch_setting_t
else if (action == MENU_ACTION_RIGHT)
find_next_input_driver();
break;
#ifdef HAVE_CAMERA
case MENU_SETTINGS_DRIVER_CAMERA:
if (action == MENU_ACTION_LEFT)
find_prev_camera_driver();
else if (action == MENU_ACTION_RIGHT)
find_next_camera_driver();
break;
#endif
case MENU_SETTINGS_DRIVER_LOCATION:
if (action == MENU_ACTION_LEFT)
find_prev_location_driver();
@ -4246,11 +4240,9 @@ static void menu_common_setting_set_label(char *type_str, size_t type_str_size,
case MENU_SETTINGS_DRIVER_INPUT:
strlcpy(type_str, g_settings.input.driver, type_str_size);
break;
#ifdef HAVE_CAMERA
case MENU_SETTINGS_DRIVER_CAMERA:
strlcpy(type_str, g_settings.camera.driver, type_str_size);
break;
#endif
case MENU_SETTINGS_DRIVER_LOCATION:
strlcpy(type_str, g_settings.location.driver, type_str_size);
break;
@ -4663,11 +4655,9 @@ static void menu_common_setting_set_label(char *type_str, size_t type_str_size,
snprintf(type_str, type_str_size, g_extern.netplay_is_spectate ? "ON" : "OFF");
break;
#endif
#ifdef HAVE_CAMERA
case MENU_SETTINGS_PRIVACY_CAMERA_ALLOW:
snprintf(type_str, type_str_size, g_settings.camera.allow ? "ON" : "OFF");
break;
#endif
case MENU_SETTINGS_PRIVACY_LOCATION_ALLOW:
snprintf(type_str, type_str_size, g_settings.location.allow ? "ON" : "OFF");
break;

View File

@ -246,7 +246,6 @@ struct settings
} menu;
#endif
#ifdef HAVE_CAMERA
struct
{
char driver[32];
@ -255,7 +254,6 @@ struct settings
unsigned width;
unsigned height;
} camera;
#endif
struct
{
@ -401,9 +399,7 @@ struct global
bool perfcnt_enable;
bool audio_active;
bool video_active;
#ifdef HAVE_CAMERA
bool camera_active;
#endif
bool location_active;
#ifdef HAVE_OSK
bool osk_active;
@ -750,9 +746,7 @@ extern struct defaults g_defaults;
// Public functions
void config_load(void);
void config_set_defaults(void);
#ifdef HAVE_CAMERA
const char *config_get_default_camera(void);
#endif
const char *config_get_default_location(void);
#ifdef HAVE_OSK
const char *config_get_default_osk(void);

View File

@ -367,7 +367,6 @@ AUDIO RESAMPLER
/*============================================================
CAMERA
============================================================ */
#ifdef HAVE_CAMERA
#if defined(ANDROID)
#include "../camera/android.c"
#elif defined(EMSCRIPTEN)
@ -378,7 +377,7 @@ CAMERA
#include "../camera/video4linux2.c"
#endif
#endif
#include "../camera/nullcamera.c"
/*============================================================
LOCATION

View File

@ -321,6 +321,8 @@
</ClCompile>
<ClCompile Include="..\..\location\null.c">
</ClCompile>
<ClCompile Include="..\..\camera\nullcamera.c">
</ClCompile>
<ClCompile Include="..\..\rewind.c">
</ClCompile>
<ClCompile Include="..\..\screenshot.c">

View File

@ -23,6 +23,7 @@
<ClCompile Include="..\..\patch.c" />
<ClCompile Include="..\..\retroarch.c" />
<ClCompile Include="..\..\location\null.c" />
<ClCompile Include="..\..\camera\nullcamera.c" />
<ClCompile Include="..\..\rewind.c" />
<ClCompile Include="..\..\screenshot.c" />
<ClCompile Include="..\..\settings.c" />

View File

@ -3266,10 +3266,8 @@ bool rarch_main_iterate(void)
if (g_extern.bsv.movie)
bsv_movie_set_frame_start(g_extern.bsv.movie);
#ifdef HAVE_CAMERA
if (g_extern.system.camera_callback.caps)
driver_camera_poll();
#endif
// Update binds for analog dpad modes.
for (i = 0; i < MAX_PLAYERS; i++)

View File

@ -203,7 +203,6 @@ const char *config_get_default_osk(void)
}
#endif
#ifdef HAVE_CAMERA
const char *config_get_default_camera(void)
{
switch (CAMERA_DEFAULT_DRIVER)
@ -222,7 +221,6 @@ const char *config_get_default_camera(void)
return NULL;
}
}
#endif
const char *config_get_default_location(void)
{
@ -249,12 +247,10 @@ void config_set_defaults(void)
#ifdef HAVE_MENU
const char *def_menu = config_get_default_menu();
#endif
#ifdef HAVE_CAMERA
const char *def_camera = config_get_default_camera();
if (def_camera)
strlcpy(g_settings.camera.driver, def_camera, sizeof(g_settings.camera.driver));
#endif
const char *def_location = config_get_default_location();
@ -373,10 +369,7 @@ void config_set_defaults(void)
#endif
g_settings.location.allow = false;
#ifdef HAVE_CAMERA
g_settings.camera.allow = false;
#endif
rarch_assert(sizeof(g_settings.input.binds[0]) >= sizeof(retro_keybinds_1));
rarch_assert(sizeof(g_settings.input.binds[1]) >= sizeof(retro_keybinds_rest));
@ -975,10 +968,8 @@ bool config_load_file(const char *path, bool set_defaults)
g_extern.audio_data.volume_db = g_settings.audio.volume;
g_extern.audio_data.volume_gain = db_to_gain(g_settings.audio.volume);
#ifdef HAVE_CAMERA
CONFIG_GET_STRING(camera.device, "camera_device");
CONFIG_GET_BOOL(camera.allow, "camera_allow");
#endif
CONFIG_GET_BOOL(location.allow, "location_allow");
CONFIG_GET_STRING(video.driver, "video_driver");
@ -1389,10 +1380,8 @@ bool config_save_file(const char *path)
config_set_int(conf, "aspect_ratio_index", g_settings.video.aspect_ratio_idx);
config_set_string(conf, "audio_device", g_settings.audio.device);
config_set_string(conf, "audio_dsp_plugin", g_settings.audio.dsp_plugin);
#ifdef HAVE_CAMERA
config_set_string(conf, "camera_device", g_settings.camera.device);
config_set_bool(conf, "camera_allow", g_settings.camera.allow);
#endif
config_set_bool(conf, "audio_rate_control", g_settings.audio.rate_control);
config_set_float(conf, "audio_rate_control_delta", g_settings.audio.rate_control_delta);
config_set_string(conf, "audio_driver", g_settings.audio.driver);

View File

@ -997,10 +997,8 @@ static void general_read_handler(const void *data)
*setting->value.boolean = g_settings.video.aspect_ratio_auto;
else if (!strcmp(setting->name, "video_filter"))
strlcpy(setting->value.string, g_settings.video.filter_path, setting->size);
#ifdef HAVE_CAMERA
else if (!strcmp(setting->name, "camera_allow"))
*setting->value.boolean = g_settings.camera.allow;
#endif
else if (!strcmp(setting->name, "location_allow"))
*setting->value.boolean = g_settings.location.allow;
else if (!strcmp(setting->name, "video_shared_context"))
@ -1328,10 +1326,8 @@ static void general_write_handler(const void *data)
strlcpy(g_settings.video.filter_path, setting->value.string, sizeof(g_settings.video.filter_path));
rarch_cmd = RARCH_CMD_REINIT;
}
#ifdef HAVE_CAMERA
else if (!strcmp(setting->name, "camera_allow"))
g_settings.camera.allow = *setting->value.boolean;
#endif
else if (!strcmp(setting->name, "location_allow"))
g_settings.location.allow = *setting->value.boolean;
else if (!strcmp(setting->name, "video_shared_context"))
@ -1453,9 +1449,7 @@ rarch_setting_t* setting_data_get_list(void)
#endif
CONFIG_STRING(g_settings.audio.driver, "audio_driver", "Audio Driver", config_get_default_audio(), GROUP_NAME, SUBGROUP_NAME, NULL, NULL)
CONFIG_STRING(g_settings.audio.resampler, "audio_driver", "Audio Resampler Driver", config_get_default_audio_resampler(), GROUP_NAME, SUBGROUP_NAME, NULL, NULL)
#ifdef HAVE_CAMERA
CONFIG_STRING(g_settings.camera.device, "camera_device", "Camera Driver", config_get_default_camera(), GROUP_NAME, SUBGROUP_NAME, NULL, NULL)
#endif
CONFIG_STRING(g_settings.location.driver, "location_driver", "Location Driver", config_get_default_location(), GROUP_NAME, SUBGROUP_NAME, NULL, NULL)
CONFIG_STRING(g_settings.input.joypad_driver, "input_joypad_driver", "Joypad Driver", "", GROUP_NAME, SUBGROUP_NAME, NULL, NULL)
CONFIG_STRING(g_settings.input.keyboard_layout, "input_keyboard_layout", "Keyboard Layout", "", GROUP_NAME, SUBGROUP_NAME, NULL, NULL)
@ -1755,9 +1749,7 @@ rarch_setting_t* setting_data_get_list(void)
/***********/
START_GROUP("Privacy Options")
START_SUB_GROUP("State")
#ifdef HAVE_CAMERA
CONFIG_BOOL(g_settings.camera.allow, "camera_allow", "Allow Camera", false, GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler)
#endif
CONFIG_BOOL(g_settings.location.allow, "location_allow", "Allow Location", false, GROUP_NAME, SUBGROUP_NAME, general_write_handler, general_read_handler)
END_SUB_GROUP()
END_GROUP()