summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/machine
diff options
context:
space:
mode:
author couriersud <couriersud@gmx.org>2020-08-16 00:21:43 +0200
committer couriersud <couriersud@gmx.org>2020-08-16 00:21:52 +0200
commit75925e190565d9063b31817181da886deaa3b4b5 (patch)
tree83d768fe5f56e3809d0f309f6c2567adbcf5872e /src/devices/machine
parente120cfc6539e7d8a589ed9ce8534b41fda2510da (diff)
netlist: buffered_param_setter refactoring
* Each parameter to set now has a dedicated buffered_param_setter device. * This allows different sample times per device * Updated netlist.cpp for new approach * buffered_param_setter is a template. The template parameter is a class which is expected to support the [] operator. The value passed to [] operator is the requested sample number.
Diffstat (limited to 'src/devices/machine')
-rw-r--r--src/devices/machine/netlist.cpp55
-rw-r--r--src/devices/machine/netlist.h15
2 files changed, 33 insertions, 37 deletions
diff --git a/src/devices/machine/netlist.cpp b/src/devices/machine/netlist.cpp
index 9f7a9834a85..cd59afcc6eb 100644
--- a/src/devices/machine/netlist.cpp
+++ b/src/devices/machine/netlist.cpp
@@ -333,7 +333,7 @@ netlist_data_memregions_t::stream_ptr netlist_data_memregions_t::stream(const ps
// sound_in
// ----------------------------------------------------------------------------------------
-using sound_in_type = netlist::interface::NETLIB_NAME(buffered_param_setter)<stream_sample_t, 16>;
+using sound_in_type = netlist::interface::NETLIB_NAME(buffered_param_setter)<stream_sample_t *>;
class NETLIB_NAME(sound_in) : public sound_in_type
{
@@ -750,15 +750,13 @@ void netlist_mame_stream_input_device::device_start()
void netlist_mame_stream_input_device::custom_netlist_additions(netlist::nlparse_t &parser)
{
- if (!parser.device_exists("STREAM_INPUT"))
- parser.register_dev("NETDEV_SOUND_IN", "STREAM_INPUT");
+ pstring name = plib::pfmt("STREAM_INPUT_{}")(m_channel);
+ parser.register_dev("NETDEV_SOUND_IN", name);
- pstring sparam = plib::pfmt("STREAM_INPUT.CHAN{1}")(m_channel);
- parser.register_param(sparam, pstring(m_param_name));
- sparam = plib::pfmt("STREAM_INPUT.MULT{1}")(m_channel);
- parser.register_param_val(sparam, m_mult);
- sparam = plib::pfmt("STREAM_INPUT.OFFSET{1}")(m_channel);
- parser.register_param_val(sparam, m_offset);
+ parser.register_param(name + ".CHAN", pstring(m_param_name));
+ parser.register_param_val(name + ".MULT", m_mult);
+ parser.register_param_val(name + ".OFFSET", m_offset);
+ parser.register_param_val(name + ".ID", m_channel);
}
@@ -1317,7 +1315,6 @@ offs_t netlist_disassembler::disassemble(std::ostream &stream, offs_t pc, const
netlist_mame_sound_device::netlist_mame_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: netlist_mame_device(mconfig, NETLIST_SOUND, tag, owner, 0)
, device_sound_interface(mconfig, *this)
- , m_in(nullptr)
, m_stream(nullptr)
, m_cur_time(attotime::zero)
, m_sound_clock(clock)
@@ -1332,7 +1329,7 @@ void netlist_mame_sound_device::device_validity_check(validity_checker &valid) c
auto lnetlist = base_validity_check(valid);
if (lnetlist)
{
- /*Ok - do some more checks */
+ /* Ok - do some more checks */
if (m_out.size() == 0)
osd_printf_error("No output devices\n");
else
@@ -1340,14 +1337,16 @@ void netlist_mame_sound_device::device_validity_check(validity_checker &valid) c
for (auto &outdev : m_out)
{
if (outdev.first < 0 || outdev.first >= m_out.size())
- osd_printf_error("illegal channel number %d\n", outdev.first);
+ osd_printf_error("illegal output channel number %d\n", outdev.first);
}
}
std::vector<nld_sound_in *> indevs = lnetlist->get_device_list<nld_sound_in>();
- if (indevs.size() > 1)
- osd_printf_error("A maximum of one input device is allowed but found %d!\n", (int)indevs.size());
+ for (auto &e : indevs)
+ {
+ if (e->id() >= indevs.size())
+ osd_printf_error("illegal input channel number %d\n", e->id());
+ }
}
-
}
@@ -1379,29 +1378,29 @@ void netlist_mame_sound_device::device_start()
for (auto &outdev : m_out)
{
if (outdev.first < 0 || outdev.first >= m_out.size())
- fatalerror("illegal channel number %d", outdev.first);
+ fatalerror("illegal output channel number %d", outdev.first);
outdev.second->set_sample_time(netlist::netlist_time::from_hz(m_sound_clock));
outdev.second->buffer_reset(netlist::netlist_time_ext::zero());
}
// Configure inputs
- // FIXME: The limitation to one input device seems artificial.
- // We should allow multiple devices with one channel each.
- m_in = nullptr;
+ m_in.clear();
std::vector<nld_sound_in *> indevs = netlist().get_device_list<nld_sound_in>();
- if (indevs.size() > 1)
- fatalerror("A maximum of one input device is allowed!");
- if (indevs.size() == 1)
+ for (auto &e : indevs)
{
- m_in = indevs[0];
+ m_in.emplace(e->id(), e);
const auto sample_time = netlist::netlist_time::from_raw(static_cast<netlist::netlist_time::internal_type>(nltime_from_attotime(m_attotime_per_clock).as_raw()));
- m_in->resolve_params(sample_time);
+ e->resolve_params(sample_time);
+ }
+ for (auto &e : m_in)
+ {
+ if (e.first < 0 || e.first >= m_in.size())
+ fatalerror("illegal input channel number %d", e.first);
}
-
/* initialize the stream(s) */
- m_stream = machine().sound().stream_alloc(*this, m_in ? m_in->num_channels() : 0, m_out.size(), m_sound_clock);
+ m_stream = machine().sound().stream_alloc(*this, m_in.size(), m_out.size(), m_sound_clock);
LOGDEVCALLS("sound device_start exit\n");
}
@@ -1452,10 +1451,10 @@ void netlist_mame_sound_device::sound_stream_update(sound_stream &stream, stream
m_last_update_to_current_time = mtime;
LOGDEBUG("samples %d\n", samples);
- if (m_in)
+ for (auto &e : m_in)
{
auto sample_time = netlist::netlist_time::from_raw(static_cast<netlist::netlist_time::internal_type>(nltime_from_attotime(m_attotime_per_clock).as_raw()));
- m_in->buffer_reset(sample_time, samples, inputs);
+ e.second->buffer_reset(sample_time, samples, &inputs[e.first]);
}
m_cur_time += (samples * m_attotime_per_clock);
diff --git a/src/devices/machine/netlist.h b/src/devices/machine/netlist.h
index 951ef38ef01..acca73431aa 100644
--- a/src/devices/machine/netlist.h
+++ b/src/devices/machine/netlist.h
@@ -112,8 +112,6 @@ private:
// netlist_mame_cpu_device
// ----------------------------------------------------------------------------------------
-class netlist_mame_cpu_device;
-
class netlist_disassembler : public util::disasm_interface
{
public:
@@ -233,24 +231,23 @@ public:
inline sound_stream *get_stream() { return m_stream; }
void update_to_current_time();
-
- // device_sound_interface overrides
- virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) override;
- virtual void device_validity_check(validity_checker &valid) const override;
-
void register_stream_output(int channel, netlist_mame_stream_output_device *so);
protected:
+
// netlist_mame_device
virtual void nl_register_devices(netlist::nlparse_t &parser) const override;
// device_t overrides
virtual void device_start() override;
- virtual void device_reset() override;
+ // device_sound_interface overrides
+ virtual void sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) override;
+ virtual void device_validity_check(validity_checker &valid) const override;
+ //virtual void device_reset() override;
private:
std::map<int, netlist_mame_stream_output_device *> m_out;
- nld_sound_in *m_in;
+ std::map<std::size_t, nld_sound_in *> m_in;
sound_stream *m_stream;
attotime m_cur_time;
uint32_t m_sound_clock;