Skip to content

Commit

Permalink
Create camera_driver_poll
Browse files Browse the repository at this point in the history
  • Loading branch information
inactive123 committed May 7, 2017
1 parent a2fe3dc commit f97d084
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
31 changes: 17 additions & 14 deletions camera/camera_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ static const camera_driver_t *camera_drivers[] = {
NULL,
};

static struct retro_camera_callback camera_cb;
static const camera_driver_t *camera_driver = NULL;
static void *camera_data = NULL;
static bool camera_driver_active = false;
static bool camera_driver_data_own = false;

/**
* camera_driver_find_handle:
* @idx : index of driver to get handle to.
Expand Down Expand Up @@ -102,14 +108,20 @@ bool driver_camera_start(void)
return camera_driver_ctl(RARCH_CAMERA_CTL_START, NULL);
}

void camera_driver_poll(void)
{
if (!camera_cb.caps)
return;
if (!camera_driver || !camera_driver->poll || !camera_data)
return;
camera_driver->poll(camera_data,
camera_cb.frame_raw_framebuffer,
camera_cb.frame_opengl_texture);
}

bool camera_driver_ctl(enum rarch_camera_ctl_state state, void *data)
{
settings_t *settings = config_get_ptr();
static struct retro_camera_callback camera_cb;
static const camera_driver_t *camera_driver = NULL;
static void *camera_data = NULL;
static bool camera_driver_active = false;
static bool camera_driver_data_own = false;

switch (state)
{
Expand Down Expand Up @@ -195,15 +207,6 @@ bool camera_driver_ctl(enum rarch_camera_ctl_state state, void *data)
"Camera is explicitly disabled.\n", 1, 180, false);
}
break;
case RARCH_CAMERA_CTL_POLL:
if (!camera_cb.caps)
return false;
if (!camera_driver || !camera_driver->poll || !camera_data)
return false;
camera_driver->poll(camera_data,
camera_cb.frame_raw_framebuffer,
camera_cb.frame_opengl_texture);
break;
case RARCH_CAMERA_CTL_SET_CB:
{
struct retro_camera_callback *cb =
Expand Down
1 change: 0 additions & 1 deletion camera/camera_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ enum rarch_camera_ctl_state
RARCH_CAMERA_CTL_UNSET_ACTIVE,
RARCH_CAMERA_CTL_IS_ACTIVE,
RARCH_CAMERA_CTL_FIND_DRIVER,
RARCH_CAMERA_CTL_POLL,
RARCH_CAMERA_CTL_SET_CB,
RARCH_CAMERA_CTL_STOP,
RARCH_CAMERA_CTL_START,
Expand Down
2 changes: 1 addition & 1 deletion runloop.c
Original file line number Diff line number Diff line change
Expand Up @@ -1164,7 +1164,7 @@ int runloop_iterate(unsigned *sleep_ms)

bsv_movie_set_frame_start();

camera_driver_ctl(RARCH_CAMERA_CTL_POLL, NULL);
camera_driver_poll();

/* Update binds for analog dpad modes. */
for (i = 0; i < max_users; i++)
Expand Down

0 comments on commit f97d084

Please sign in to comment.