summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/modules/lib/osdobj_common.c
diff options
context:
space:
mode:
author couriersud <couriersud@arcor.de>2015-03-04 01:39:52 +0100
committer couriersud <couriersud@arcor.de>2015-03-04 01:39:52 +0100
commit98a6781c271b004174052bbd1750351149bf91ce (patch)
treeaea69d555669dfacd6eb94ff0dd84d02a9443fd8 /src/osd/modules/lib/osdobj_common.c
parentc5deacfe57571bdcfdfb7bec9a3033be1f78fda7 (diff)
First step to move osd_printf_* into osd again. Callbacks are now
implemented using an interface and use a push/pop approach where the pop can happen out of order of pushes. [Couriersud]
Diffstat (limited to 'src/osd/modules/lib/osdobj_common.c')
-rw-r--r--src/osd/modules/lib/osdobj_common.c43
1 files changed, 35 insertions, 8 deletions
diff --git a/src/osd/modules/lib/osdobj_common.c b/src/osd/modules/lib/osdobj_common.c
index df208356c52..222a7d0aca6 100644
--- a/src/osd/modules/lib/osdobj_common.c
+++ b/src/osd/modules/lib/osdobj_common.c
@@ -133,12 +133,24 @@ osd_options::osd_options()
//-------------------------------------------------
osd_common_t::osd_common_t(osd_options &options)
- : m_machine(NULL),
+ : osd_output(), m_machine(NULL),
m_options(options),
m_sound(NULL),
m_debugger(NULL)
+{
+ osd_output::push(this);
+}
+
+//-------------------------------------------------
+// osd_interface - destructor
+//-------------------------------------------------
+osd_common_t::~osd_common_t()
{
+ for(int i= 0; i < m_video_names.count(); ++i)
+ osd_free(const_cast<char*>(m_video_names[i]));
+ //m_video_options,reset();
+ osd_output::pop(this);
}
#define REGISTER_MODULE(_O, _X ) { extern const module_type _X; _O . register_module( _X ); }
@@ -228,18 +240,33 @@ void osd_common_t::update_option(const char * key, dynamic_array<const char *> &
m_options.set_description(key, core_strdup(current_value.cat(new_option_value).cstr()));
}
+
//-------------------------------------------------
-// osd_interface - destructor
+// output_callback - callback for osd_printf_...
//-------------------------------------------------
-
-osd_common_t::~osd_common_t()
+void osd_common_t::output_callback(osd_output_channel channel, const char *msg, va_list args)
{
- for(int i= 0; i < m_video_names.count(); ++i)
- osd_free(const_cast<char*>(m_video_names[i]));
- //m_video_options,reset();
+ switch (channel)
+ {
+ case OSD_OUTPUT_CHANNEL_ERROR:
+ case OSD_OUTPUT_CHANNEL_WARNING:
+ vfprintf(stderr, msg, args);
+ break;
+ case OSD_OUTPUT_CHANNEL_INFO:
+ case OSD_OUTPUT_CHANNEL_VERBOSE:
+ case OSD_OUTPUT_CHANNEL_LOG:
+ vfprintf(stdout, msg, args);
+ break;
+ case OSD_OUTPUT_CHANNEL_DEBUG:
+#ifdef MAME_DEBUG
+ vfprintf(stdout, msg, args);
+#endif
+ break;
+ default:
+ break;
+ }
}
-
//-------------------------------------------------
// init - initialize the OSD system.
//-------------------------------------------------