summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd
diff options
context:
space:
mode:
author Miodrag Milanovic <mmicko@gmail.com>2016-04-15 16:01:35 +0200
committer Miodrag Milanovic <mmicko@gmail.com>2016-04-15 16:01:35 +0200
commit37c94e3373e18bd71095bf736ba5105bf3b04e2e (patch)
treef61d632fef40057353cbb9f5ca427dda2b092154 /src/osd
parentbd04e5b17dcf679cd8618a02e97ce957d2c62865 (diff)
Update windows to use platform independent watchdog implementation (nw)
Diffstat (limited to 'src/osd')
-rw-r--r--src/osd/modules/lib/osdobj_common.cpp18
-rw-r--r--src/osd/modules/lib/osdobj_common.h16
-rw-r--r--src/osd/sdl/osdsdl.h3
-rw-r--r--src/osd/sdl/sdlmain.cpp12
-rw-r--r--src/osd/sdl/video.cpp9
-rw-r--r--src/osd/watchdog.cpp (renamed from src/osd/sdl/watchdog.cpp)0
-rw-r--r--src/osd/watchdog.h (renamed from src/osd/sdl/watchdog.h)0
-rw-r--r--src/osd/windows/video.cpp5
-rw-r--r--src/osd/windows/winmain.cpp77
-rw-r--r--src/osd/windows/winmain.h2
10 files changed, 30 insertions, 112 deletions
diff --git a/src/osd/modules/lib/osdobj_common.cpp b/src/osd/modules/lib/osdobj_common.cpp
index 32f1a6047ac..adc202ce4db 100644
--- a/src/osd/modules/lib/osdobj_common.cpp
+++ b/src/osd/modules/lib/osdobj_common.cpp
@@ -175,7 +175,8 @@ osd_common_t::osd_common_t(osd_options &options)
m_mouse_input(nullptr),
m_lightgun_input(nullptr),
m_joystick_input(nullptr),
- m_output(nullptr)
+ m_output(nullptr),
+ m_watchdog(nullptr)
{
osd_output::push(this);
}
@@ -420,6 +421,16 @@ void osd_common_t::init(running_machine &machine)
// ensure we get called on the way out
machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(osd_common_t::osd_exit), this));
+
+
+ /* now setup watchdog */
+ int watchdog_timeout = options.watchdog();
+
+ if (watchdog_timeout != 0)
+ {
+ m_watchdog = std::make_unique<watchdog>();
+ m_watchdog->setTimeout(watchdog_timeout);
+ }
}
@@ -437,6 +448,11 @@ void osd_common_t::update(bool skip_redraw)
// irregular intervals in some circumstances (e.g., multi-screen games
// or games with asynchronous updates).
//
+ if (m_watchdog != NULL)
+ m_watchdog->reset();
+
+ update_slider_list();
+
}
diff --git a/src/osd/modules/lib/osdobj_common.h b/src/osd/modules/lib/osdobj_common.h
index cd83ba61e7b..9afce249eb1 100644
--- a/src/osd/modules/lib/osdobj_common.h
+++ b/src/osd/modules/lib/osdobj_common.h
@@ -14,6 +14,7 @@
#define MAME_OSD_LIB_OSDOBJ_COMMON_H
#include "osdepend.h"
+#include "watchdog.h"
#include "modules/osdmodule.h"
#include "modules/font/font_module.h"
#include "modules/input/input_module.h"
@@ -273,14 +274,15 @@ private:
}
protected:
- sound_module* m_sound;
- debug_module* m_debugger;
- midi_module* m_midi;
- input_module* m_keyboard_input;
- input_module* m_mouse_input;
- input_module* m_lightgun_input;
- input_module* m_joystick_input;
+ sound_module* m_sound;
+ debug_module* m_debugger;
+ midi_module* m_midi;
+ input_module* m_keyboard_input;
+ input_module* m_mouse_input;
+ input_module* m_lightgun_input;
+ input_module* m_joystick_input;
output_module* m_output;
+ std::unique_ptr<watchdog> m_watchdog;
std::vector<ui_menu_item> m_sliders;
private:
diff --git a/src/osd/sdl/osdsdl.h b/src/osd/sdl/osdsdl.h
index c239966c7ab..d7d4a1a4a3c 100644
--- a/src/osd/sdl/osdsdl.h
+++ b/src/osd/sdl/osdsdl.h
@@ -3,7 +3,6 @@
#ifndef _osdsdl_h_
#define _osdsdl_h_
-#include "watchdog.h"
#include "modules/lib/osdobj_common.h"
#include "modules/osdmodule.h"
#include "modules/font/font_module.h"
@@ -168,8 +167,6 @@ private:
void extract_video_config();
sdl_options &m_options;
-
- watchdog *m_watchdog;
};
//============================================================
diff --git a/src/osd/sdl/sdlmain.cpp b/src/osd/sdl/sdlmain.cpp
index 270bc714320..43b1052df01 100644
--- a/src/osd/sdl/sdlmain.cpp
+++ b/src/osd/sdl/sdlmain.cpp
@@ -53,8 +53,6 @@
#include <X11/Xutil.h>
#endif
-#include "watchdog.h"
-
//============================================================
// OPTIONS
//============================================================
@@ -250,7 +248,7 @@ static void output_oslog(const running_machine &machine, const char *buffer)
//============================================================
sdl_osd_interface::sdl_osd_interface(sdl_options &options)
-: osd_common_t(options), m_options(options), m_watchdog(nullptr)
+: osd_common_t(options), m_options(options)
{
}
@@ -505,15 +503,7 @@ void sdl_osd_interface::init(running_machine &machine)
if (options().oslog())
machine.add_logerror_callback(output_oslog);
- /* now setup watchdog */
-
- int watchdog_timeout = options().watchdog();
- if (watchdog_timeout != 0)
- {
- m_watchdog = auto_alloc(machine, watchdog);
- m_watchdog->setTimeout(watchdog_timeout);
- }
#ifdef SDLMAME_EMSCRIPTEN
SDL_EventState(SDL_TEXTINPUT, SDL_FALSE);
diff --git a/src/osd/sdl/video.cpp b/src/osd/sdl/video.cpp
index 582836f0c8e..8a8402e44b3 100644
--- a/src/osd/sdl/video.cpp
+++ b/src/osd/sdl/video.cpp
@@ -134,18 +134,13 @@ void sdl_monitor_info::refresh()
void sdl_osd_interface::update(bool skip_redraw)
{
- sdl_window_info *window;
-
- if (m_watchdog != NULL)
- m_watchdog->reset();
-
- update_slider_list();
+ osd_common_t::update(skip_redraw);
// if we're not skipping this redraw, update all windows
if (!skip_redraw)
{
// profiler_mark(PROFILER_BLIT);
- for (window = sdl_window_list; window != NULL; window = window->m_next)
+ for (sdl_window_info *window = sdl_window_list; window != NULL; window = window->m_next)
window->update();
// profiler_mark(PROFILER_END);
}
diff --git a/src/osd/sdl/watchdog.cpp b/src/osd/watchdog.cpp
index 8a86464cb56..8a86464cb56 100644
--- a/src/osd/sdl/watchdog.cpp
+++ b/src/osd/watchdog.cpp
diff --git a/src/osd/sdl/watchdog.h b/src/osd/watchdog.h
index f9c06e72bb0..f9c06e72bb0 100644
--- a/src/osd/sdl/watchdog.h
+++ b/src/osd/watchdog.h
diff --git a/src/osd/windows/video.cpp b/src/osd/windows/video.cpp
index f6de9222c50..b0f28ee7d13 100644
--- a/src/osd/windows/video.cpp
+++ b/src/osd/windows/video.cpp
@@ -166,10 +166,7 @@ osd_monitor_info *win_monitor_info::monitor_from_handle(HMONITOR hmonitor)
void windows_osd_interface::update(bool skip_redraw)
{
- // ping the watchdog on each update
- winmain_watchdog_ping();
-
- update_slider_list();
+ osd_common_t::update(skip_redraw);
// if we're not skipping this redraw, update all windows
if (!skip_redraw)
diff --git a/src/osd/windows/winmain.cpp b/src/osd/windows/winmain.cpp
index 7249c9ee747..0d0a8ed7b1c 100644
--- a/src/osd/windows/winmain.cpp
+++ b/src/osd/windows/winmain.cpp
@@ -280,10 +280,6 @@ static int timeresult = !TIMERR_NOERROR;
static TIMECAPS timecaps;
#endif
-static HANDLE watchdog_reset_event;
-static HANDLE watchdog_exit_event;
-static HANDLE watchdog_thread;
-
static running_machine *g_current_machine;
@@ -293,7 +289,6 @@ static running_machine *g_current_machine;
static BOOL WINAPI control_handler(DWORD type);
static int is_double_click_start(int argc);
-static DWORD WINAPI watchdog_thread_entry(LPVOID lpParameter);
static LONG WINAPI exception_filter(struct _EXCEPTION_POINTERS *info);
@@ -702,17 +697,6 @@ void windows_osd_interface::init(running_machine &machine)
timeBeginPeriod(timecaps.wPeriodMin);
#endif
- // if a watchdog thread is requested, create one
- int watchdog = options.watchdog();
- if (watchdog != 0)
- {
- watchdog_reset_event = CreateEvent(nullptr, FALSE, FALSE, nullptr);
- assert_always(watchdog_reset_event != nullptr, "Failed to create watchdog reset event");
- watchdog_exit_event = CreateEvent(nullptr, TRUE, FALSE, nullptr);
- assert_always(watchdog_exit_event != nullptr, "Failed to create watchdog exit event");
- watchdog_thread = CreateThread(nullptr, 0, watchdog_thread_entry, (LPVOID)(FPTR)watchdog, 0, nullptr);
- assert_always(watchdog_thread != nullptr, "Failed to create watchdog thread");
- }
// create and start the profiler
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
@@ -745,18 +729,6 @@ void windows_osd_interface::osd_exit()
osd_common_t::osd_exit();
- // take down the watchdog thread if it exists
- if (watchdog_thread != nullptr)
- {
- SetEvent(watchdog_exit_event);
- WaitForSingleObject(watchdog_thread, INFINITE);
- CloseHandle(watchdog_reset_event);
- CloseHandle(watchdog_exit_event);
- CloseHandle(watchdog_thread);
- watchdog_reset_event = nullptr;
- watchdog_exit_event = nullptr;
- watchdog_thread = nullptr;
- }
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
// stop the profiler
@@ -777,55 +749,6 @@ void windows_osd_interface::osd_exit()
}
-//============================================================
-// watchdog_thread_entry
-//============================================================
-
-static DWORD WINAPI watchdog_thread_entry(LPVOID lpParameter)
-{
- DWORD timeout = (int)(FPTR)lpParameter * 1000;
-
- while (TRUE)
- {
- HANDLE handle_list[2];
- DWORD wait_result;
-
- // wait for either a reset or an exit, or a timeout
- handle_list[0] = watchdog_reset_event;
- handle_list[1] = watchdog_exit_event;
- wait_result = WaitForMultipleObjects(2, handle_list, FALSE, timeout);
-
- // on a reset, just loop around and re-wait
- if (wait_result == WAIT_OBJECT_0 + 0)
- continue;
-
- // on an exit, break out
- if (wait_result == WAIT_OBJECT_0 + 1)
- break;
-
- // on a timeout, kill the process
- if (wait_result == WAIT_TIMEOUT)
- {
- fprintf(stderr, "Terminating due to watchdog timeout\n");
- fflush(stderr);
- TerminateProcess(GetCurrentProcess(), -1);
- }
- }
- return EXCEPTION_CONTINUE_SEARCH;
-}
-
-
-//============================================================
-// winmain_watchdog_ping
-//============================================================
-
-void winmain_watchdog_ping(void)
-{
- // if we have a watchdog, reset it
- if (watchdog_reset_event != nullptr)
- SetEvent(watchdog_reset_event);
-}
-
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
diff --git a/src/osd/windows/winmain.h b/src/osd/windows/winmain.h
index 7bd2917a2a7..b41092bf500 100644
--- a/src/osd/windows/winmain.h
+++ b/src/osd/windows/winmain.h
@@ -337,8 +337,6 @@ extern int osd_num_processors;
// FUNCTION PROTOTYPES
//============================================================
-// use this to ping the watchdog
-void winmain_watchdog_ping(void);
void winmain_dump_stack();
#endif