diff options
author | 2023-01-28 08:00:27 +1100 | |
---|---|---|
committer | 2023-01-28 08:16:53 +1100 | |
commit | 2498f2b7cfb77f6a6d8d08f07075b7fa1c3ab63b (patch) | |
tree | 07f72639213d6ada8dd143be21e11178160a4894 /src/osd/modules | |
parent | 536c6eeb55a7d5b69ef61cb79ec35c3e09a1458e (diff) |
Miscellaneous fixes and refactoring:
ui/analogipt.cpp: Fixed bar graph display for fields with ranges
that wrap through zero.
emu/inputdev.cpp: Separateed analog axis deadzone and switch threshold
settings, reduced default deadzone, and fixed a potential division by
zero if the deadzone and saturation settings are equal.
emu/ioport.cpp: Fixed behaviour of absolute analog fields where range
passes through zero - it previously only worked for specific
combinations of mask, minimum and default. Removed a workaround from
universal/getaway.cpp that is no longer necessary.
emu/input.cpp: Fixed unintuitive behaviour when an absolute field is
assigned an OR combination of a relative control folled by an absolute
control (e.g. Mouse X or Joy 1 LSX). Also fixed reading axis input
sequences where an axis code is followed by a switch code (these can
only be produced by manually editing configuration files, not through
MAME's UI), and fixed the returned type when multiple relative axes sum
to zero.
osd/modules/input_dinput.cpp: Fixed hat switches being stuck in up
position when input is suspended in the background
taito/taitoio_yoke.cpp: Give throttle control a distinct type, and don't
auto-centre.
osd: Added option to select MIDI provider module (currently only
PortMidi and the dummy module are available). Also put various things
in namespaces, and fixed builds including SDL sound module with native
Windows OSD.
emu/validity.cpp: Added check to catch I/O port fields using UI input
types.
emu/inpttype.ipp: Renamed inputs that were causing confusion. "Bill"
and "Track" were causing confusion for translators and hence likely
causing confusion for many users, especially those who are not native
English speakers. "Track" as an abbreviation for "Trackball" was
frequently being mistranslated, e.g. in the sense of a CD track
selection button or even in the sense of a railway track. There's no
reason to abbreviate it. "Bill" in the US English sense as a banknote
is too ambiguous and was causing confusion for translators. It's better
to use the less ambiguous "Banknote". Corrected Greek translations of
"Trackball".
Don't run GitHub Actions on issue template changes.
Diffstat (limited to 'src/osd/modules')
-rw-r--r-- | src/osd/modules/font/font_dwrite.cpp | 22 | ||||
-rw-r--r-- | src/osd/modules/input/input_dinput.cpp | 6 | ||||
-rw-r--r-- | src/osd/modules/lib/osdobj_common.cpp | 88 | ||||
-rw-r--r-- | src/osd/modules/lib/osdobj_common.h | 13 | ||||
-rw-r--r-- | src/osd/modules/midi/none.cpp | 81 | ||||
-rw-r--r-- | src/osd/modules/midi/portmidi.cpp | 26 | ||||
-rw-r--r-- | src/osd/modules/osdmodule.cpp | 14 | ||||
-rw-r--r-- | src/osd/modules/osdmodule.h | 31 | ||||
-rw-r--r-- | src/osd/modules/output/none.cpp | 14 | ||||
-rw-r--r-- | src/osd/modules/sound/coreaudio_sound.cpp | 21 | ||||
-rw-r--r-- | src/osd/modules/sound/js_sound.cpp | 2 | ||||
-rw-r--r-- | src/osd/modules/sound/none.cpp | 18 | ||||
-rw-r--r-- | src/osd/modules/sound/pa_sound.cpp | 35 | ||||
-rw-r--r-- | src/osd/modules/sound/sdl_sound.cpp | 21 | ||||
-rw-r--r-- | src/osd/modules/sound/sound_module.h | 10 |
15 files changed, 197 insertions, 205 deletions
diff --git a/src/osd/modules/font/font_dwrite.cpp b/src/osd/modules/font/font_dwrite.cpp index 47a52dbd197..b66a53e4383 100644 --- a/src/osd/modules/font/font_dwrite.cpp +++ b/src/osd/modules/font/font_dwrite.cpp @@ -41,6 +41,11 @@ DEFINE_GUID(GUID_WICPixelFormat8bppAlpha, 0xe6cd0116, 0xeeba, 0x4161, 0xaa, 0x85 #include <wrl/client.h> #undef interface + +namespace osd { + +namespace { + using namespace Microsoft::WRL; //------------------------------------------------- @@ -363,7 +368,7 @@ public: bool italic = (strreplace(name, "[I]", "") + strreplace(name, "[i]", "") > 0); // convert the face name - std::wstring familyName = osd::text::to_wstring(name.c_str()); + std::wstring familyName = text::to_wstring(name); // find the font HR_RET0(find_font( @@ -625,7 +630,7 @@ private: HR_RETHR(fonts->FindFamilyName(familyName.c_str(), &family_index, &exists)); if (!exists) { - osd_printf_error("Font with family name %s does not exist.\n", osd::text::from_wstring(familyName)); + osd_printf_error("Font with family name %s does not exist.\n", text::from_wstring(familyName)); return E_FAIL; } @@ -744,7 +749,7 @@ public: std::unique_ptr<WCHAR[]> name = nullptr; HR_RET0(get_localized_familyname(names, name)); - std::string utf8_name = osd::text::from_wstring(name.get()); + std::string utf8_name = text::from_wstring(name.get()); name.reset(); // Review: should the config name, be unlocalized? @@ -808,8 +813,15 @@ private: } }; +} // anonymous namespace + +} // namespace osd + #else -MODULE_NOT_SUPPORTED(font_dwrite, OSD_FONT_PROVIDER, "dwrite") + +namespace osd { namespace { MODULE_NOT_SUPPORTED(font_dwrite, OSD_FONT_PROVIDER, "dwrite") } } + #endif -MODULE_DEFINITION(FONT_DWRITE, font_dwrite) + +MODULE_DEFINITION(FONT_DWRITE, osd::font_dwrite) diff --git a/src/osd/modules/input/input_dinput.cpp b/src/osd/modules/input/input_dinput.cpp index 56f46532eb1..3461f9aad24 100644 --- a/src/osd/modules/input/input_dinput.cpp +++ b/src/osd/modules/input/input_dinput.cpp @@ -413,6 +413,7 @@ dinput_joystick_device::dinput_joystick_device(running_machine &machine, std::st void dinput_joystick_device::reset() { memset(&joystick.state, 0, sizeof(joystick.state)); + std::fill(std::begin(joystick.state.rgdwPOV), std::end(joystick.state.rgdwPOV), 0xffff); } void dinput_joystick_device::poll() @@ -531,11 +532,10 @@ int dinput_joystick_device::configure() std::string name = dinput_module::device_item_name(this, offset, default_button_name(butnum).c_str(), nullptr); input_item_id itemid; - if (butnum < INPUT_MAX_BUTTONS) - itemid = static_cast<input_item_id>(ITEM_ID_BUTTON1 + butnum); + itemid = input_item_id(ITEM_ID_BUTTON1 + butnum); else if (butnum < INPUT_MAX_BUTTONS + INPUT_MAX_ADD_SWITCH) - itemid = static_cast<input_item_id>(ITEM_ID_ADD_SWITCH1 - INPUT_MAX_BUTTONS + butnum); + itemid = input_item_id(ITEM_ID_ADD_SWITCH1 - INPUT_MAX_BUTTONS + butnum); else itemid = ITEM_ID_OTHER_SWITCH; diff --git a/src/osd/modules/lib/osdobj_common.cpp b/src/osd/modules/lib/osdobj_common.cpp index 9aab7f1dec0..3cde2b3d2aa 100644 --- a/src/osd/modules/lib/osdobj_common.cpp +++ b/src/osd/modules/lib/osdobj_common.cpp @@ -166,6 +166,9 @@ const options_entry osd_options::s_option_entries[] = { OSDOPTION_AUDIO_EFFECT "9", OSDOPTVAL_NONE, core_options::option_type::STRING, "AudioUnit effect 9" }, #endif + { nullptr, nullptr, core_options::option_type::HEADER, "OSD MIDI OPTIONS" }, + { OSDOPTION_MIDI_PROVIDER, OSDOPTVAL_AUTO, core_options::option_type::STRING, "MIDI I/O method: " }, + { nullptr, nullptr, core_options::option_type::HEADER, "BGFX POST-PROCESSING OPTIONS" }, { OSDOPTION_BGFX_PATH, "bgfx", core_options::option_type::PATH, "path to BGFX-related files" }, { OSDOPTION_BGFX_BACKEND, "auto", core_options::option_type::STRING, "BGFX backend to use (d3d9, d3d11, d3d12, metal, opengl, gles, vulkan)" }, @@ -221,7 +224,7 @@ osd_common_t::~osd_common_t() osd_output::pop(this); } -#define REGISTER_MODULE(_O, _X ) { extern const module_type _X; _O . register_module( _X ); } +#define REGISTER_MODULE(O, X) { extern const module_type X; O.register_module(X); } void osd_common_t::register_options() { @@ -301,72 +304,16 @@ void osd_common_t::register_options() // after initialization we know which modules are supported - const char *names[20]; - int num; - std::vector<const char *> dnames; - - m_mod_man.get_module_names(OSD_MONITOR_PROVIDER, 20, num, names); - for (int i = 0; i < num; i++) - dnames.push_back(names[i]); - update_option(OSD_MONITOR_PROVIDER, dnames); - - m_mod_man.get_module_names(OSD_FONT_PROVIDER, 20, num, names); - dnames.clear(); - for (int i = 0; i < num; i++) - dnames.push_back(names[i]); - update_option(OSD_FONT_PROVIDER, dnames); - - m_mod_man.get_module_names(OSD_KEYBOARDINPUT_PROVIDER, 20, num, names); - dnames.clear(); - for (int i = 0; i < num; i++) - dnames.push_back(names[i]); - update_option(OSD_KEYBOARDINPUT_PROVIDER, dnames); - - m_mod_man.get_module_names(OSD_MOUSEINPUT_PROVIDER, 20, num, names); - dnames.clear(); - for (int i = 0; i < num; i++) - dnames.push_back(names[i]); - update_option(OSD_MOUSEINPUT_PROVIDER, dnames); - - m_mod_man.get_module_names(OSD_LIGHTGUNINPUT_PROVIDER, 20, num, names); - dnames.clear(); - for (int i = 0; i < num; i++) - dnames.push_back(names[i]); - update_option(OSD_LIGHTGUNINPUT_PROVIDER, dnames); - - m_mod_man.get_module_names(OSD_JOYSTICKINPUT_PROVIDER, 20, num, names); - dnames.clear(); - for (int i = 0; i < num; i++) - dnames.push_back(names[i]); - update_option(OSD_JOYSTICKINPUT_PROVIDER, dnames); - - m_mod_man.get_module_names(OSD_SOUND_PROVIDER, 20, num, names); - dnames.clear(); - for (int i = 0; i < num; i++) - dnames.push_back(names[i]); - update_option(OSD_SOUND_PROVIDER, dnames); - -#if 0 - // Register midi options and update options - m_mod_man.get_module_names(OSD_MIDI_PROVIDER, 20, num, names); - dnames.clear(); - for (int i = 0; i < num; i++) - dnames.push_back(names[i]); - update_option(OSD_MIDI_PROVIDER, dnames); -#endif - - // Register debugger options and update options - m_mod_man.get_module_names(OSD_DEBUG_PROVIDER, 20, num, names); - dnames.clear(); - for (int i = 0; i < num; i++) - dnames.push_back(names[i]); - update_option(OSD_DEBUG_PROVIDER, dnames); - - m_mod_man.get_module_names(OSD_OUTPUT_PROVIDER, 20, num, names); - dnames.clear(); - for (int i = 0; i < num; i++) - dnames.push_back(names[i]); - update_option(OSD_OUTPUT_PROVIDER, dnames); + update_option(OSD_MONITOR_PROVIDER, m_mod_man.get_module_names(OSD_MONITOR_PROVIDER)); + update_option(OSD_FONT_PROVIDER, m_mod_man.get_module_names(OSD_FONT_PROVIDER)); + update_option(OSD_KEYBOARDINPUT_PROVIDER, m_mod_man.get_module_names(OSD_KEYBOARDINPUT_PROVIDER)); + update_option(OSD_MOUSEINPUT_PROVIDER, m_mod_man.get_module_names(OSD_MOUSEINPUT_PROVIDER)); + update_option(OSD_LIGHTGUNINPUT_PROVIDER, m_mod_man.get_module_names(OSD_LIGHTGUNINPUT_PROVIDER)); + update_option(OSD_JOYSTICKINPUT_PROVIDER, m_mod_man.get_module_names(OSD_JOYSTICKINPUT_PROVIDER)); + update_option(OSD_SOUND_PROVIDER, m_mod_man.get_module_names(OSD_SOUND_PROVIDER)); + update_option(OSD_MIDI_PROVIDER, m_mod_man.get_module_names(OSD_MIDI_PROVIDER)); + update_option(OSD_DEBUG_PROVIDER, m_mod_man.get_module_names(OSD_DEBUG_PROVIDER)); + update_option(OSD_OUTPUT_PROVIDER, m_mod_man.get_module_names(OSD_OUTPUT_PROVIDER)); // Register video options and update options video_options_add("none", nullptr); @@ -374,21 +321,20 @@ void osd_common_t::register_options() update_option(OSDOPTION_VIDEO, m_video_names); } -void osd_common_t::update_option(const std::string &key, std::vector<const char *> &values) +void osd_common_t::update_option(const std::string &key, std::vector<std::string_view> const &values) { std::string current_value(m_options.description(key.c_str())); std::string new_option_value(""); for (unsigned int index = 0; index < values.size(); index++) { - std::string t(values[index]); if (new_option_value.length() > 0) { - if( index != (values.size()-1)) + if (index != (values.size() - 1)) new_option_value.append(", "); else new_option_value.append(" or "); } - new_option_value.append(t); + new_option_value.append(values[index]); } m_option_descs[key] = current_value + new_option_value; diff --git a/src/osd/modules/lib/osdobj_common.h b/src/osd/modules/lib/osdobj_common.h index bf680195fca..00e7ddc0483 100644 --- a/src/osd/modules/lib/osdobj_common.h +++ b/src/osd/modules/lib/osdobj_common.h @@ -24,8 +24,9 @@ #include <iosfwd> #include <list> -#include <string> #include <memory> +#include <string> +#include <string_view> #include <unordered_map> #include <vector> @@ -86,8 +87,7 @@ #define OSDOPTION_AUDIO_OUTPUT "audio_output" #define OSDOPTION_AUDIO_EFFECT "audio_effect" -#define OSDOPTVAL_AUTO "auto" -#define OSDOPTVAL_NONE "none" +#define OSDOPTION_MIDI_PROVIDER "midiprovider" #define OSDOPTION_BGFX_PATH "bgfx_path" #define OSDOPTION_BGFX_BACKEND "bgfx_backend" @@ -97,6 +97,9 @@ #define OSDOPTION_BGFX_LUT "bgfx_lut" #define OSDOPTION_BGFX_AVI_NAME "bgfx_avi_name" +#define OSDOPTVAL_AUTO "auto" +#define OSDOPTVAL_NONE "none" + //============================================================ // TYPE DEFINITIONS //============================================================ @@ -286,7 +289,7 @@ private: osd_module_manager m_mod_man; font_module *m_font_module; - void update_option(const std::string &key, std::vector<const char *> &values); + void update_option(const std::string &key, std::vector<std::string_view> const &values); // FIXME: should be elsewhere osd_module *select_module_options(const core_options &opts, const std::string &opt_name) { @@ -321,7 +324,7 @@ protected: std::vector<ui::menu_item> m_sliders; private: - std::vector<const char *> m_video_names; + std::vector<std::string_view> m_video_names; std::unordered_map<std::string, std::string> m_option_descs; }; diff --git a/src/osd/modules/midi/none.cpp b/src/osd/modules/midi/none.cpp index 21837d1be3c..97333cb54de 100644 --- a/src/osd/modules/midi/none.cpp +++ b/src/osd/modules/midi/none.cpp @@ -6,87 +6,56 @@ Empty shim for systems not supporting midi / portmidi -*******************************************************************c********/ +***************************************************************************/ #include "osdcore.h" #include "modules/osdmodule.h" #include "midi_module.h" -class none_module : public osd_module, public midi_module -{ -public: +#include <memory> - none_module() : osd_module(OSD_MIDI_PROVIDER, "pm"), midi_module() - { - } - virtual ~none_module() { } - virtual int init(const osd_options &options) override; - virtual void exit() override; - - virtual std::unique_ptr<osd_midi_device> create_midi_device() override; - virtual void list_midi_devices() override; -}; +namespace osd { +namespace { class osd_midi_device_none : public osd_midi_device { public: - virtual ~osd_midi_device_none() { } - virtual bool open_input(const char *devname) override; - virtual bool open_output(const char *devname) override; - virtual void close() override; - virtual bool poll() override; - virtual int read(uint8_t *pOut) override; - virtual void write(uint8_t data) override; + virtual bool open_input(const char *devname) override { return false; } + virtual bool open_output(const char *devname) override { return false; } + virtual void close() override { } + virtual bool poll() override { return false; } + virtual int read(uint8_t *pOut) override { return 0; } + virtual void write(uint8_t data) override { } }; -std::unique_ptr<osd_midi_device> none_module::create_midi_device() -{ - return std::make_unique<osd_midi_device_none>(); -} - -int none_module::init(const osd_options &options) +class none_module : public osd_module, public midi_module { - return 0; -} +public: + none_module() : osd_module(OSD_MIDI_PROVIDER, "none"), midi_module() { } -void none_module::exit() -{ -} + virtual int init(const osd_options &options) override { return 0; } + virtual void exit() override { } -void none_module::list_midi_devices() -{ - osd_printf_warning("\nMIDI is not supported in this build\n"); -} - -bool osd_midi_device_none::open_input(const char *devname) -{ - return false; -} + virtual std::unique_ptr<osd_midi_device> create_midi_device() override; + virtual void list_midi_devices() override; +}; -bool osd_midi_device_none::open_output(const char *devname) +std::unique_ptr<osd_midi_device> none_module::create_midi_device() { - return false; + return std::make_unique<osd_midi_device_none>(); } -void osd_midi_device_none::close() +void none_module::list_midi_devices() { + osd_printf_warning("\nMIDI is not supported in this configuration\n"); } -bool osd_midi_device_none::poll() -{ - return false; -} +} // anonymous namespace -int osd_midi_device_none::read(uint8_t *pOut) -{ - return 0; -} +} // namespace osd -void osd_midi_device_none::write(uint8_t data) -{ -} -MODULE_DEFINITION(MIDI_NONE, none_module) +MODULE_DEFINITION(MIDI_NONE, osd::none_module) diff --git a/src/osd/modules/midi/portmidi.cpp b/src/osd/modules/midi/portmidi.cpp index 73d965d854a..4661779c0bd 100644 --- a/src/osd/modules/midi/portmidi.cpp +++ b/src/osd/modules/midi/portmidi.cpp @@ -8,14 +8,22 @@ *******************************************************************c********/ +#include "midi_module.h" + +#include "modules/osdmodule.h" + #ifndef NO_USE_MIDI #include <portmidi.h> -#include "modules/osdmodule.h" -#include "midi_module.h" + #include <cstdio> #include <cstring> + +namespace osd { + +namespace { + class pm_module : public osd_module, public midi_module { public: @@ -26,7 +34,7 @@ public: virtual ~pm_module() { } virtual int init(const osd_options &options)override; - virtual void exit()override; + virtual void exit() override; virtual std::unique_ptr<osd_midi_device> create_midi_device() override; virtual void list_midi_devices() override; @@ -464,12 +472,16 @@ void osd_midi_device_pm::write(uint8_t data) } } + +} // anonymous namespace + +} // namespace osd + #else - #include "modules/osdmodule.h" - #include "midi_module.h" - MODULE_NOT_SUPPORTED(pm_module, OSD_MIDI_PROVIDER, "pm") +namespace osd { namespace { MODULE_NOT_SUPPORTED(pm_module, OSD_MIDI_PROVIDER, "pm") } } + #endif -MODULE_DEFINITION(MIDI_PM, pm_module) +MODULE_DEFINITION(MIDI_PM, osd::pm_module) diff --git a/src/osd/modules/osdmodule.cpp b/src/osd/modules/osdmodule.cpp index 4f2cf079e3b..9c3f0a9a693 100644 --- a/src/osd/modules/osdmodule.cpp +++ b/src/osd/modules/osdmodule.cpp @@ -1,11 +1,12 @@ // license:BSD-3-Clause // copyright-holders:Couriersud /* - * osdmodule.c + * osdmodule.cpp * */ #include "modules/osdmodule.h" + #include "osdcore.h" #include <algorithm> @@ -83,12 +84,13 @@ int osd_module_manager::get_module_index(const char *type, const char *name) con return -1; } -void osd_module_manager::get_module_names(const char *type, const int max, int &num, const char *names[]) const +std::vector<std::string_view> osd_module_manager::get_module_names(const char *type) const { - num = 0; - for (int i = 0; (m_modules.size() > i) && (max > num); i++) + std::vector<std::string_view> result; + for (auto &m : m_modules) { - if (m_modules[i]->type() == type) - names[num++] = m_modules[i]->name().c_str(); + if (m->type() == type) + result.emplace_back(m->name()); } + return result; } diff --git a/src/osd/modules/osdmodule.h b/src/osd/modules/osdmodule.h index 1c662417601..3e944b28a9f 100644 --- a/src/osd/modules/osdmodule.h +++ b/src/osd/modules/osdmodule.h @@ -15,6 +15,7 @@ #include <functional> #include <memory> #include <string> +#include <string_view> #include <vector> @@ -24,7 +25,10 @@ class osd_options; -// ======================> osd_module + +//============================================================ +// TYPE DEFINITIONS +//============================================================ class osd_module { @@ -48,9 +52,11 @@ private: std::string const m_type; }; + // a module_type is simply a pointer to its alloc function typedef std::unique_ptr<osd_module> (*module_type)(); + // this template function creates a stub which constructs a module template <class ModuleClass> std::unique_ptr<osd_module> module_creator() @@ -58,6 +64,7 @@ std::unique_ptr<osd_module> module_creator() return std::unique_ptr<osd_module>(new ModuleClass); } + class osd_module_manager { public: @@ -77,7 +84,7 @@ public: osd_module *select_module(const char *type, const char *name = ""); - void get_module_names(const char *type, const int max, int &num, const char *names[]) const; + std::vector<std::string_view> get_module_names(const char *type) const; void init(const osd_options &options); @@ -90,18 +97,20 @@ private: std::vector<std::reference_wrapper<osd_module> > m_selected; }; + #define MODULE_DEFINITION(mod_id, mod_class) \ - extern const module_type mod_id ; \ - const module_type mod_id = &module_creator< mod_class >; + extern const module_type mod_id ; \ + const module_type mod_id = &module_creator<mod_class>; #define MODULE_NOT_SUPPORTED(mod_class, mod_type, mod_name) \ - class mod_class : public osd_module { \ - public: \ - mod_class () : osd_module(mod_type, mod_name) { } \ - virtual ~mod_class() { } \ - virtual int init(const osd_options &options) override { return -1; } \ - virtual bool probe() override { return false; } \ - }; + class mod_class : public osd_module \ + { \ + public: \ + mod_class () : osd_module(mod_type, mod_name) { } \ + virtual ~mod_class() { } \ + virtual int init(const osd_options &options) override { return -1; } \ + virtual bool probe() override { return false; } \ + }; #endif /* MAME_OSD_MODULES_OSDMODULE_H */ diff --git a/src/osd/modules/output/none.cpp b/src/osd/modules/output/none.cpp index a4a613ef29f..2e103cded8e 100644 --- a/src/osd/modules/output/none.cpp +++ b/src/osd/modules/output/none.cpp @@ -9,13 +9,17 @@ *******************************************************************c********/ #include "output_module.h" + #include "modules/osdmodule.h" +namespace osd { + +namespace { + class output_none : public osd_module, public output_module { public: - output_none() - : osd_module(OSD_OUTPUT_PROVIDER, "none"), output_module() + output_none() : osd_module(OSD_OUTPUT_PROVIDER, "none") { } virtual ~output_none() { } @@ -29,4 +33,8 @@ public: }; -MODULE_DEFINITION(OUTPUT_NONE, output_none) +} // anonymous namespace + +} // namespace osd + +MODULE_DEFINITION(OUTPUT_NONE, osd::output_none) diff --git a/src/osd/modules/sound/coreaudio_sound.cpp b/src/osd/modules/sound/coreaudio_sound.cpp index dcc74ec5fe9..675b01c8451 100644 --- a/src/osd/modules/sound/coreaudio_sound.cpp +++ b/src/osd/modules/sound/coreaudio_sound.cpp @@ -24,16 +24,9 @@ #include <cstring> -#ifdef MAC_OS_X_VERSION_MAX_ALLOWED - -#if MAC_OS_X_VERSION_MAX_ALLOWED < 1060 - -typedef ComponentDescription AudioComponentDescription; - -#endif // MAC_OS_X_VERSION_MAX_ALLOWED < 1060 - -#endif // MAC_OS_X_VERSION_MAX_ALLOWED +namespace osd { +namespace { class sound_coreaudio : public osd_module, public sound_module { @@ -1013,8 +1006,14 @@ OSStatus sound_coreaudio::render_callback( return ((sound_coreaudio *)refcon)->render(action_flags, timestamp, bus_number, number_frames, data); } +} // anonymous namespace + +} // namespace osd + #else /* SDLMAME_MACOSX */ - MODULE_NOT_SUPPORTED(sound_coreaudio, OSD_SOUND_PROVIDER, "coreaudio") + +namespace osd { namespace { MODULE_NOT_SUPPORTED(sound_coreaudio, OSD_SOUND_PROVIDER, "coreaudio") } } + #endif -MODULE_DEFINITION(SOUND_COREAUDIO, sound_coreaudio) +MODULE_DEFINITION(SOUND_COREAUDIO, osd::sound_coreaudio) diff --git a/src/osd/modules/sound/js_sound.cpp b/src/osd/modules/sound/js_sound.cpp index afcf6ec8f2b..f863973d1de 100644 --- a/src/osd/modules/sound/js_sound.cpp +++ b/src/osd/modules/sound/js_sound.cpp @@ -47,7 +47,7 @@ public: }; -#else /* SDLMAME_UNIX */ +#else /* SDLMAME_EMSCRIPTEN */ MODULE_NOT_SUPPORTED(sound_js, OSD_SOUND_PROVIDER, "js") #endif diff --git a/src/osd/modules/sound/none.cpp b/src/osd/modules/sound/none.cpp index 685cdc884c2..8d18ea635b1 100644 --- a/src/osd/modules/sound/none.cpp +++ b/src/osd/modules/sound/none.cpp @@ -2,20 +2,25 @@ // copyright-holders:Miodrag Milanovic /*************************************************************************** - none.c + none.cpp Dummy sound interface. *******************************************************************c********/ #include "sound_module.h" + #include "modules/osdmodule.h" + +namespace osd { + +namespace { + class sound_none : public osd_module, public sound_module { public: - sound_none() - : osd_module(OSD_SOUND_PROVIDER, "none"), sound_module() + sound_none() : osd_module(OSD_SOUND_PROVIDER, "none") { } virtual ~sound_none() { } @@ -27,7 +32,10 @@ public: virtual void update_audio_stream(bool is_throttled, const int16_t *buffer, int samples_this_frame) override { } virtual void set_mastervolume(int attenuation) override { } - }; -MODULE_DEFINITION(SOUND_NONE, sound_none) +} // anonymous namespace + +} // namespace osd + +MODULE_DEFINITION(SOUND_NONE, osd::sound_none) diff --git a/src/osd/modules/sound/pa_sound.cpp b/src/osd/modules/sound/pa_sound.cpp index 9472f6812cb..fec69835851 100644 --- a/src/osd/modules/sound/pa_sound.cpp +++ b/src/osd/modules/sound/pa_sound.cpp @@ -9,35 +9,40 @@ *******************************************************************c********/ #include "sound_module.h" + #include "modules/osdmodule.h" #ifndef NO_USE_PORTAUDIO -#include <portaudio.h> #include "modules/lib/osdobj_common.h" +#include "osdcore.h" -#include <iostream> -#include <fstream> -#include <sstream> +#include <portaudio.h> + +#include <algorithm> #include <atomic> -#include <cmath> #include <climits> -#include <algorithm> +#include <cmath> +#include <fstream> +#include <iostream> +#include <sstream> #ifdef _WIN32 #include "pa_win_wasapi.h" #endif + +namespace osd { + +namespace { + #define LOG_FILE "pa.log" #define LOG_BUFCNT 0 -using osd::s16; - class sound_pa : public osd_module, public sound_module { public: - sound_pa() - : osd_module(OSD_SOUND_PROVIDER, "portaudio"), sound_module() + sound_pa() : osd_module(OSD_SOUND_PROVIDER, "portaudio") { } virtual ~sound_pa() { } @@ -458,8 +463,14 @@ void sound_pa::exit() osd_printf_verbose("Sound: overflows=%d underflows=%d\n", m_overflows, m_underflows); } +} // anonymous namespace + +} // namespace osd + #else - MODULE_NOT_SUPPORTED(sound_pa, OSD_SOUND_PROVIDER, "portaudio") + +namespace osd { namespace { MODULE_NOT_SUPPORTED(sound_pa, OSD_SOUND_PROVIDER, "portaudio") } } + #endif -MODULE_DEFINITION(SOUND_PORTAUDIO, sound_pa) +MODULE_DEFINITION(SOUND_PORTAUDIO, osd::sound_pa) diff --git a/src/osd/modules/sound/sdl_sound.cpp b/src/osd/modules/sound/sdl_sound.cpp index 9b65a6c176b..d17e3b7d296 100644 --- a/src/osd/modules/sound/sdl_sound.cpp +++ b/src/osd/modules/sound/sdl_sound.cpp @@ -9,6 +9,7 @@ //============================================================ #include "sound_module.h" + #include "modules/osdmodule.h" #if (defined(OSD_SDL) || defined(USE_SDL_SOUND)) @@ -26,6 +27,11 @@ #include <fstream> #include <memory> + +namespace osd { + +namespace { + //============================================================ // DEBUGGING //============================================================ @@ -41,13 +47,13 @@ class sound_sdl : public osd_module, public sound_module public: // number of samples per SDL callback - static const int SDL_XFER_SAMPLES = 512; + static inline constexpr int SDL_XFER_SAMPLES = 512; sound_sdl() : osd_module(OSD_SOUND_PROVIDER, "sdl"), sound_module(), stream_in_initialized(0), attenuation(0), buf_locked(0), stream_buffer(nullptr), stream_buffer_size(0), buffer_underflows(0), buffer_overflows(0) -{ + { sdl_xfer_samples = SDL_XFER_SAMPLES; } virtual ~sound_sdl() { } @@ -456,10 +462,15 @@ void sound_sdl::sdl_destroy_buffers() stream_buffer.reset(); } +} // anonymous namespace + +} // namespace osd + + +#else // (defined(OSD_SDL) || defined(USE_SDL_SOUND)) +namespace osd { namespace { MODULE_NOT_SUPPORTED(sound_sdl, OSD_SOUND_PROVIDER, "sdl") } } -#else /* SDLMAME_UNIX */ - MODULE_NOT_SUPPORTED(sound_sdl, OSD_SOUND_PROVIDER, "sdl") #endif -MODULE_DEFINITION(SOUND_SDL, sound_sdl) +MODULE_DEFINITION(SOUND_SDL, osd::sound_sdl) diff --git a/src/osd/modules/sound/sound_module.h b/src/osd/modules/sound/sound_module.h index b72f50f7c8c..d741c732622 100644 --- a/src/osd/modules/sound/sound_module.h +++ b/src/osd/modules/sound/sound_module.h @@ -4,9 +4,10 @@ * sound_module.h * */ +#ifndef MAME_OSD_SOUND_SOUND_MODULE_H +#define MAME_OSD_SOUND_SOUND_MODULE_H -#ifndef SOUND_MODULE_H_ -#define SOUND_MODULE_H_ +#pragma once #include <cstdint> @@ -21,15 +22,16 @@ class sound_module public: sound_module() : m_sample_rate(0), m_audio_latency(1) { } - virtual ~sound_module() { } + virtual ~sound_module() = default; virtual void update_audio_stream(bool is_throttled, const int16_t *buffer, int samples_this_frame) = 0; virtual void set_mastervolume(int attenuation) = 0; int sample_rate() const { return m_sample_rate; } + // FIXME: these should be set by the implementation on initialisation, not by the OSD object int m_sample_rate; int m_audio_latency; }; -#endif /* FONT_MODULE_H_ */ +#endif // MAME_OSD_SOUND_SOUND_MODULE_H |