summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices')
-rw-r--r--src/devices/bus/odyssey2/voice.cpp2
-rw-r--r--src/devices/machine/netlist.cpp35
-rw-r--r--src/devices/machine/netlist.h12
3 files changed, 34 insertions, 15 deletions
diff --git a/src/devices/bus/odyssey2/voice.cpp b/src/devices/bus/odyssey2/voice.cpp
index 9ca1ea26101..678757bb775 100644
--- a/src/devices/bus/odyssey2/voice.cpp
+++ b/src/devices/bus/odyssey2/voice.cpp
@@ -139,7 +139,7 @@ void o2_voice_device::device_add_mconfig(machine_config &config)
// The Voice uses a speaker with its own volume control so the relative volumes to use are subjective, these sound good
m_speech->add_route(ALL_OUTPUTS, "mono", 1.00);
- O2_CART_SLOT(config, m_subslot, o2_cart, nullptr);
+ O2_CART_SLOT(config, m_subslot, o2_cart, nullptr).set_must_be_loaded(true);
}
ROM_START( o2voice )
diff --git a/src/devices/machine/netlist.cpp b/src/devices/machine/netlist.cpp
index 8d4d6cedf4d..a3d6ae3e656 100644
--- a/src/devices/machine/netlist.cpp
+++ b/src/devices/machine/netlist.cpp
@@ -322,6 +322,7 @@ class NETLIB_NAME(sound_in) : public sound_in_type
public:
using base_type = sound_in_type;
using base_type::base_type;
+ sound_stream *m_stream = nullptr;
};
netlist::setup_t &netlist_mame_device::setup()
@@ -1387,6 +1388,11 @@ void netlist_mame_sound_device::device_start()
std::vector<nld_sound_in *> indevs = netlist().get_device_list<nld_sound_in>();
for (auto &e : indevs)
{
+ // We cannot use the resampler because the stream is not
+ // always audio. In particular the ay8910 may send a stream
+ // of resistor values, which would be destroyed by resampling.
+
+ e->m_stream = stream_alloc(1, 0, SAMPLE_RATE_INPUT_ADAPTIVE);
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()));
e->resolve_params(sample_time);
@@ -1399,7 +1405,7 @@ void netlist_mame_sound_device::device_start()
m_inbuffer.resize(m_in.size());
/* initialize the stream(s) */
- m_stream = stream_alloc(m_in.size(), m_out.size(), m_sound_clock);
+ m_stream = stream_alloc(0, m_out.size(), m_sound_clock);
LOGDEVCALLS("sound device_start exit\n");
}
@@ -1444,21 +1450,30 @@ void netlist_mame_sound_device::update_to_current_time()
void netlist_mame_sound_device::sound_stream_update(sound_stream &stream)
{
- for (auto &e : m_in)
+ if (stream.input_count() == 1)
{
- auto clock_period = stream.sample_period();
- auto sample_time = netlist::netlist_time::from_raw(static_cast<netlist::netlist_time::internal_type>(nltime_from_attotime(clock_period).as_raw()));
- m_inbuffer[e.first] = netlist_mame_sound_input_buffer(stream, e.first);
- e.second->buffer_reset(sample_time, stream.samples(), &m_inbuffer[e.first]);
+ for (auto &e : m_in)
+ if (e.second->m_stream == &stream)
+ {
+ auto clock_period = stream.sample_period();
+ auto sample_time = netlist::netlist_time::from_raw(static_cast<netlist::netlist_time::internal_type>(nltime_from_attotime(clock_period).as_raw()));
+ m_inbuffer[e.first] = netlist_mame_sound_input_buffer(stream);
+ e.second->buffer_reset(sample_time, stream.samples(), &m_inbuffer[e.first]);
+ return;
+ }
+ fatalerror("netlist: Got input from an unknown stream\n");
}
int samples = stream.samples();
LOGDEBUG("samples %d\n", samples);
- // end_time() is the time at the END of the last sample we're generating
- // however, the sample value is the value at the START of that last sample,
- // so subtract one sample period so that we only process up to the minimum
- auto nl_target_time = nltime_from_attotime(stream.end_time() - stream.sample_period());
+ // Ensure all input streams are up-to-date
+ for (auto &e : m_in)
+ if (e.second->m_stream)
+ e.second->m_stream->update();
+
+ // Get the start time of the last sample to generate
+ auto nl_target_time = nltime_from_attotime(stream.sample_to_time(stream.end_index() - 1));
auto nltime(netlist().exec().time());
if (nltime < nl_target_time)
diff --git a/src/devices/machine/netlist.h b/src/devices/machine/netlist.h
index 67b6b7d143c..57fc6b05c3a 100644
--- a/src/devices/machine/netlist.h
+++ b/src/devices/machine/netlist.h
@@ -255,14 +255,18 @@ private:
class netlist_mame_sound_input_buffer
{
public:
- sound_stream *m_stream = nullptr;
- int m_stream_input = 0;
+ std::vector<sound_stream::sample_t> m_buffer;
netlist_mame_sound_input_buffer() {}
- netlist_mame_sound_input_buffer(sound_stream &stream, int input) : m_stream(&stream), m_stream_input(input) { }
+ netlist_mame_sound_input_buffer(sound_stream &stream) {
+ int samples = stream.samples();
+ m_buffer.resize(samples);
+ for (int i=0; i != samples; i++)
+ m_buffer[i] = stream.get(0, i);
+ }
- sound_stream::sample_t operator[](std::size_t index) { return m_stream->get(m_stream_input, index); }
+ sound_stream::sample_t operator[](std::size_t index) { return m_buffer[index]; }
};
// ----------------------------------------------------------------------------------------