Add RARCH_MAIN_CTL_IS_PAUSED

This commit is contained in:
twinaphex 2015-09-26 13:04:07 +02:00
parent cc4a918296
commit 0d18c61bc5
8 changed files with 39 additions and 21 deletions

View File

@ -594,7 +594,7 @@ void audio_driver_set_nonblocking_state(bool enable)
**/
bool audio_driver_flush(const int16_t *data, size_t samples)
{
bool is_slowmotion;
bool is_slowmotion, is_paused;
static struct retro_perf_counter audio_convert_s16 = {0};
static struct retro_perf_counter audio_convert_float = {0};
static struct retro_perf_counter audio_dsp = {0};
@ -619,7 +619,9 @@ bool audio_driver_flush(const int16_t *data, size_t samples)
driver->recording->push_audio(driver->recording_data, &ffemu_data);
}
if (rarch_main_is_paused() || settings->audio.mute_enable)
rarch_main_ctl(RARCH_MAIN_CTL_IS_PAUSED, &is_paused);
if (is_paused || settings->audio.mute_enable)
return true;
if (!driver->audio_active || !audio_data.data)
return false;

View File

@ -1439,7 +1439,9 @@ bool event_command(enum event_command cmd)
#endif
break;
case EVENT_CMD_PAUSE_CHECKS:
if (rarch_main_is_paused())
rarch_main_ctl(RARCH_MAIN_CTL_IS_PAUSED, &boolean);
if (boolean)
{
RARCH_LOG("%s\n", msg_hash_to_str(MSG_PAUSED));
event_command(EVENT_CMD_AUDIO_STOP);
@ -1454,7 +1456,8 @@ bool event_command(enum event_command cmd)
}
break;
case EVENT_CMD_PAUSE_TOGGLE:
rarch_main_set_pause(!rarch_main_is_paused());
rarch_main_ctl(RARCH_MAIN_CTL_IS_PAUSED, &boolean);
rarch_main_set_pause(!boolean);
event_command(EVENT_CMD_PAUSE_CHECKS);
break;
case EVENT_CMD_UNPAUSE:

View File

@ -1632,7 +1632,7 @@ static bool gl_frame(void *data, const void *frame,
uint64_t frame_count,
unsigned pitch, const char *msg)
{
bool is_slowmotion;
bool is_slowmotion, is_paused;
unsigned width, height;
struct gfx_tex_info feedback_info;
static struct retro_perf_counter frame_run = {0};
@ -1840,12 +1840,14 @@ static bool gl_frame(void *data, const void *frame,
#endif
#endif
rarch_main_ctl(RARCH_MAIN_CTL_IS_SLOWMOTION, &is_slowmotion);
rarch_main_ctl(RARCH_MAIN_CTL_IS_PAUSED, &is_paused);
/* Disable BFI during fast forward, slow-motion,
* and pause to prevent flicker. */
if (settings->video.black_frame_insertion &&
!driver->nonblock_state && !is_slowmotion
&& !rarch_main_is_paused())
if (
settings->video.black_frame_insertion
&& !driver->nonblock_state
&& !is_slowmotion && !is_paused)
{
gfx_ctx_swap_buffers(gl);
glClear(GL_COLOR_BUFFER_BIT);

View File

@ -430,10 +430,12 @@ static void thread_loop(void *data)
static bool thread_alive(void *data)
{
bool ret;
bool ret, is_paused;
thread_video_t *thr = (thread_video_t*)data;
if (rarch_main_is_paused())
rarch_main_ctl(RARCH_MAIN_CTL_IS_PAUSED, &is_paused);
if (is_paused)
{
thread_packet_t pkt = { CMD_ALIVE };
thread_send_and_wait(thr, &pkt);

View File

@ -293,6 +293,7 @@ error:
static void engine_handle_cmd(void)
{
bool is_paused;
int8_t cmd;
struct android_app *android_app = (struct android_app*)g_android;
driver_t *driver = driver_get_ptr();
@ -330,7 +331,9 @@ static void engine_handle_cmd(void)
scond_broadcast(android_app->cond);
slock_unlock(android_app->mutex);
if (rarch_main_is_paused())
rarch_main_ctl(RARCH_MAIN_CTL_IS_PAUSED, &is_paused);
if (is_paused)
event_command(EVENT_CMD_REINIT);
break;

View File

@ -896,11 +896,6 @@ void rarch_main_set_idle(unsigned enable)
main_is_idle = enable;
}
bool rarch_main_is_paused(void)
{
return main_is_paused;
}
bool rarch_main_ctl(enum rarch_main_ctl_state state, void *data)
{
switch (state)
@ -921,6 +916,15 @@ bool rarch_main_ctl(enum rarch_main_ctl_state state, void *data)
*ptr = main_is_slowmotion;
}
return true;
case RARCH_MAIN_CTL_IS_PAUSED:
{
bool *ptr = (bool*)data;
if (!ptr)
return false;
*ptr = main_is_paused;
}
return true;
}
return false;

View File

@ -36,7 +36,8 @@ extern "C" {
enum rarch_main_ctl_state
{
RARCH_MAIN_CTL_IS_IDLE = 0,
RARCH_MAIN_CTL_IS_SLOWMOTION
RARCH_MAIN_CTL_IS_SLOWMOTION,
RARCH_MAIN_CTL_IS_PAUSED,
};
typedef struct rarch_resolution
@ -335,8 +336,6 @@ FILE *rarch_main_log_file(void);
bool rarch_main_ctl(enum rarch_main_ctl_state state, void *data);
bool rarch_main_is_paused(void);
void rarch_main_set_slowmotion(unsigned enable);
void rarch_main_set_pause(unsigned enable);

View File

@ -131,6 +131,7 @@ static bool take_screenshot_raw(void)
**/
bool take_screenshot(void)
{
bool is_paused;
bool viewport_read = false;
bool ret = true;
const char *msg = NULL;
@ -205,9 +206,11 @@ bool take_screenshot(void)
msg = msg_hash_to_str(MSG_FAILED_TO_TAKE_SCREENSHOT);
}
rarch_main_msg_queue_push(msg, 1, rarch_main_is_paused() ? 1 : 180, true);
rarch_main_ctl(RARCH_MAIN_CTL_IS_PAUSED, &is_paused);
if (rarch_main_is_paused())
rarch_main_msg_queue_push(msg, 1, is_paused ? 1 : 180, true);
if (is_paused)
video_driver_cached_frame();
return ret;