Skip to content

Commit

Permalink
Expose machine pause and resume operation
Browse files Browse the repository at this point in the history
  • Loading branch information
sangwonl committed Jan 9, 2022
1 parent f6114cc commit 4c60c2d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/osd/headless/headless.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,20 @@ static int headless_run(const char *system_name)
return emulator_info::start_frontend(*s_inst->opts, *s_inst->osd, dummy_args);
}

static void headless_pause() {
assert(s_inst != nullptr);
assert(s_inst->osd != nullptr);

s_inst->osd->machine().pause();
}

static void headless_resume() {
assert(s_inst != nullptr);
assert(s_inst->osd != nullptr);

s_inst->osd->machine().resume();
}

mame_t* get_mame_instance()
{
if (s_inst != nullptr && s_inst->mame != nullptr) {
Expand All @@ -153,6 +167,8 @@ mame_t* get_mame_instance()
s_inst->mame->set_sound_frame_cb = headless_set_sound_frame_cb;;
s_inst->mame->enqueue_input_event = headless_enqueue_input_evt;
s_inst->mame->run = headless_run;
s_inst->mame->pause = headless_pause;
s_inst->mame->resume = headless_resume;

headless_init();

Expand Down
3 changes: 3 additions & 0 deletions src/osd/headless/headless.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ extern "C" {
void (*set_image_frame_cb)(void *ctx, mame_image_frame_cb_t frame_cb);
void (*set_sound_frame_cb)(void *ctx, mame_sound_frame_cb_t frame_cb);
void (*enqueue_input_event)(mame_input_event_t input_event);

int (*run)(const char *system_name);
void (*pause)();
void (*resume)();
} mame_t;

mame_t* get_mame_instance();
Expand Down
3 changes: 2 additions & 1 deletion src/osd/headless/headless_osd_video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ void headless_osd_interface::update(bool skip_redraw)
{
osd_common_t::update(skip_redraw);

render_pixels_and_callback(skip_redraw);
if (!machine().paused())
render_pixels_and_callback(skip_redraw);
}

void headless_osd_interface::render_pixels_and_callback(bool skip_redraw)
Expand Down

0 comments on commit 4c60c2d

Please sign in to comment.