From 3d0cf668f6f297e9dd70ed9c64102650a503bc41 Mon Sep 17 00:00:00 2001 From: hap Date: Thu, 31 Aug 2023 18:36:21 +0200 Subject: samples: move interface variables to protected --- src/devices/sound/samples.cpp | 2 +- src/devices/sound/samples.h | 25 +++++++++++-------------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/devices/sound/samples.cpp b/src/devices/sound/samples.cpp index 999f4da7e0b..afd72f5391a 100644 --- a/src/devices/sound/samples.cpp +++ b/src/devices/sound/samples.cpp @@ -54,9 +54,9 @@ samples_device::samples_device(const machine_config &mconfig, const char *tag, d samples_device::samples_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, type, tag, owner, clock) , device_sound_interface(mconfig, *this) + , m_samples_start_cb(*this) , m_channels(0) , m_names(nullptr) - , m_samples_start_cb(*this) { } diff --git a/src/devices/sound/samples.h b/src/devices/sound/samples.h index e1f8599ad60..c2123fe1dbb 100644 --- a/src/devices/sound/samples.h +++ b/src/devices/sound/samples.h @@ -12,10 +12,6 @@ #pragma once -//************************************************************************** -// GLOBAL VARIABLES -//************************************************************************** - // device type definition DECLARE_DEVICE_TYPE(SAMPLES, samples_device) @@ -48,6 +44,7 @@ public: uint32_t base_frequency(uint8_t channel) const; uint8_t channels() { return m_channels; } size_t samples() { return m_sample.size(); } + const char *const *names() { return m_names; } // start/stop helpers void start(uint8_t channel, uint32_t samplenum, bool loop = false); @@ -71,10 +68,6 @@ public: }; static bool read_sample(emu_file &file, sample_t &sample); - // interface - uint8_t m_channels; // number of discrete audio channels needed - const char *const *m_names; // array of sample names - protected: // subclasses can do it this way samples_device(const machine_config &mconfig, device_type type, const char *tag, device_t *owner, uint32_t clock); @@ -108,6 +101,10 @@ protected: start_cb_delegate m_samples_start_cb; // optional callback + // interface + uint8_t m_channels; // number of discrete audio channels needed + const char *const *m_names; // array of sample names + // internal state std::vector m_channel; std::vector m_sample; @@ -135,24 +132,24 @@ public: } // getters - const char *altbasename() const { return (m_samples.m_names && m_samples.m_names[0] && m_samples.m_names[0][0] == '*') ? &m_samples.m_names[0][1] : nullptr; } + const char *altbasename() const { return (m_samples.names() && m_samples.names()[0] && m_samples.names()[0][0] == '*') ? &m_samples.names()[0][1] : nullptr; } // iteration const char *first() { - if (!m_samples.m_names || !m_samples.m_names[0]) + if (!m_samples.names() || !m_samples.names()[0]) return nullptr; m_current = 0; - if (m_samples.m_names[0][0] == '*') + if (m_samples.names()[0][0] == '*') m_current++; - return m_samples.m_names[m_current++]; + return m_samples.names()[m_current++]; } const char *next() { - if (m_current == -1 || !m_samples.m_names[m_current]) + if (m_current == -1 || !m_samples.names()[m_current]) return nullptr; - return m_samples.m_names[m_current++]; + return m_samples.names()[m_current++]; } // counting -- cgit v1.2.3