From 69e021ed3c88252bee30caec13b5f9f524fb9416 Mon Sep 17 00:00:00 2001 From: Aaron Giles Date: Wed, 16 Sep 2020 12:10:29 -0700 Subject: cdp1863/cdp1864/cpd1869: update to new stream callbacks --- src/devices/sound/cdp1863.cpp | 27 ++++++++++++--------------- src/devices/sound/cdp1863.h | 4 ++-- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/devices/sound/cdp1863.cpp b/src/devices/sound/cdp1863.cpp index f72490607ae..984a306b28a 100644 --- a/src/devices/sound/cdp1863.cpp +++ b/src/devices/sound/cdp1863.cpp @@ -64,7 +64,7 @@ cdp1863_device::cdp1863_device(const machine_config &mconfig, const char *tag, d void cdp1863_device::device_start() { // create sound stream - m_stream = stream_alloc_legacy(0, 1, machine().sample_rate()); + m_stream = stream_alloc(0, 1, SAMPLE_RATE_OUTPUT_ADAPTIVE); // register for state saving save_item(NAME(m_clock1)); @@ -77,24 +77,19 @@ void cdp1863_device::device_start() //------------------------------------------------- -// sound_stream_update_legacy - handle update requests for +// sound_stream_update - handle update requests for // our sound stream //------------------------------------------------- -void cdp1863_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) +void cdp1863_device::sound_stream_update(sound_stream &stream, std::vector const &inputs, std::vector &outputs) { - // reset the output stream - memset(outputs[0], 0, samples * sizeof(*outputs[0])); - - int16_t signal = m_signal; - stream_sample_t *buffer = outputs[0]; - - memset( buffer, 0, samples * sizeof(*buffer) ); + stream_buffer::sample_t signal = m_signal; + auto &buffer = outputs[0]; if (m_oe) { double frequency; - int rate = machine().sample_rate() / 2; + int rate = buffer.sample_rate() / 2; // get progress through wave int incr = m_incr; @@ -112,16 +107,16 @@ void cdp1863_device::sound_stream_update_legacy(sound_stream &stream, stream_sam if (signal < 0) { - signal = -0x7fff; + signal = -1.0; } else { - signal = 0x7fff; + signal = 1.0; } - while( samples-- > 0 ) + for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) { - *buffer++ = signal; + buffer.put(sampindex, signal); incr -= frequency; while( incr < 0 ) { @@ -134,6 +129,8 @@ void cdp1863_device::sound_stream_update_legacy(sound_stream &stream, stream_sam m_incr = incr; m_signal = signal; } + else + buffer.fill(0); } diff --git a/src/devices/sound/cdp1863.h b/src/devices/sound/cdp1863.h index 9441779a4f4..ec0706e9a7c 100644 --- a/src/devices/sound/cdp1863.h +++ b/src/devices/sound/cdp1863.h @@ -54,7 +54,7 @@ protected: virtual void device_start() override; // internal callbacks - virtual void sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) override; + virtual void sound_stream_update(sound_stream &stream, std::vector const &inputs, std::vector &outputs) override; private: sound_stream *m_stream; @@ -65,7 +65,7 @@ private: // sound state int m_oe; // output enable int m_latch; // sound latch - int16_t m_signal; // current signal + stream_buffer::sample_t m_signal;// current signal int m_incr; // initial wave state }; -- cgit v1.2.3