diff options
author | 2020-09-15 02:52:15 -0700 | |
---|---|---|
committer | 2020-09-15 02:52:37 -0700 | |
commit | 78f4e7be7e72507576c1bbe895a13fbeb2069b8a (patch) | |
tree | be3b1ab45225932640adfc25ccf87cc9fac2a9e5 | |
parent | c65b8623c44e6341aef659c558e50fdaeb826cc3 (diff) |
beep/bsmt2000/c140/c352/c6280/cdda: Update to new stream callbacks
-rw-r--r-- | src/devices/sound/beep.cpp | 20 | ||||
-rw-r--r-- | src/devices/sound/beep.h | 4 | ||||
-rw-r--r-- | src/devices/sound/bsmt2000.cpp | 14 | ||||
-rw-r--r-- | src/devices/sound/bsmt2000.h | 2 | ||||
-rw-r--r-- | src/devices/sound/c140.cpp | 44 | ||||
-rw-r--r-- | src/devices/sound/c140.h | 4 | ||||
-rw-r--r-- | src/devices/sound/c352.cpp | 25 | ||||
-rw-r--r-- | src/devices/sound/c352.h | 2 | ||||
-rw-r--r-- | src/devices/sound/c6280.cpp | 33 | ||||
-rw-r--r-- | src/devices/sound/c6280.h | 2 | ||||
-rw-r--r-- | src/devices/sound/cdda.cpp | 29 | ||||
-rw-r--r-- | src/devices/sound/cdda.h | 4 |
12 files changed, 94 insertions, 89 deletions
diff --git a/src/devices/sound/beep.cpp b/src/devices/sound/beep.cpp index 77e43fa2de8..58096c4b561 100644 --- a/src/devices/sound/beep.cpp +++ b/src/devices/sound/beep.cpp @@ -47,9 +47,9 @@ beep_device::beep_device(const machine_config &mconfig, const char *tag, device_ void beep_device::device_start() { - m_stream = stream_alloc_legacy(0, 1, BEEP_RATE); + m_stream = stream_alloc(0, 1, BEEP_RATE); m_enable = 0; - m_signal = 0x07fff; + m_signal = 1.0; // register for savestates save_item(NAME(m_enable)); @@ -60,12 +60,12 @@ void beep_device::device_start() //------------------------------------------------- -// sound_stream_update_legacy - handle a stream update +// sound_stream_update - handle a stream update //------------------------------------------------- -void beep_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) +void beep_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) { - stream_sample_t *buffer = outputs[0]; + auto &buffer = outputs[0]; int16_t signal = m_signal; int clock = 0, rate = BEEP_RATE / 2; @@ -78,14 +78,14 @@ void beep_device::sound_stream_update_legacy(sound_stream &stream, stream_sample /* if we're not enabled, just fill with 0 */ if ( !m_enable || clock == 0 ) { - memset( buffer, 0, samples * sizeof(*buffer) ); + buffer.fill(0); return; } /* fill in the sample */ - while( samples-- > 0 ) + for (int sampindex = 0; sampindex < buffer.samples(); sampindex++) { - *buffer++ = signal; + buffer.put(sampindex, signal); incr -= clock; while( incr < 0 ) { @@ -116,7 +116,7 @@ WRITE_LINE_MEMBER(beep_device::set_state) /* restart wave from beginning */ m_incr = 0; - m_signal = 0x07fff; + m_signal = 1.0; } @@ -131,6 +131,6 @@ void beep_device::set_clock(uint32_t frequency) m_stream->update(); m_frequency = frequency; - m_signal = 0x07fff; + m_signal = 1.0; m_incr = 0; } diff --git a/src/devices/sound/beep.h b/src/devices/sound/beep.h index 68b9b42bc2c..6c5ef2ae65f 100644 --- a/src/devices/sound/beep.h +++ b/src/devices/sound/beep.h @@ -22,7 +22,7 @@ protected: virtual void device_start() override; // sound stream update overrides - 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<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; public: DECLARE_WRITE_LINE_MEMBER(set_state); // enable/disable sound output @@ -33,7 +33,7 @@ private: int m_enable; /* enable beep */ int m_frequency; /* set frequency - this can be changed using the appropriate function */ int m_incr; /* initial wave state */ - int16_t m_signal; /* current signal */ + stream_buffer::sample_t m_signal; /* current signal */ }; DECLARE_DEVICE_TYPE(BEEP, beep_device) diff --git a/src/devices/sound/bsmt2000.cpp b/src/devices/sound/bsmt2000.cpp index c815a1e0a08..09392661079 100644 --- a/src/devices/sound/bsmt2000.cpp +++ b/src/devices/sound/bsmt2000.cpp @@ -116,7 +116,7 @@ void bsmt2000_device::device_start() // in theory we should generate a 24MHz stream, but that's certainly overkill // internally at 24MHz the max output sample rate is 32kHz // divided by 128 gives us 6x the max output rate which is plenty for oversampling - m_stream = stream_alloc_legacy(0, 2, clock() / 128); + m_stream = stream_alloc(0, 2, clock() / 128); // register for save states save_item(NAME(m_register_select)); @@ -171,18 +171,16 @@ void bsmt2000_device::device_timer(emu_timer &timer, device_timer_id id, int par //------------------------------------------------- -// sound_stream_update_legacy - handle update requests +// sound_stream_update - handle update requests // for our sound stream //------------------------------------------------- -void bsmt2000_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) +void bsmt2000_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) { // just fill with current left/right values - for (int samp = 0; samp < samples; samp++) - { - outputs[0][samp] = m_left_data; - outputs[1][samp] = m_right_data; - } + constexpr stream_buffer::sample_t sample_scale = 1.0 / 32768.0; + outputs[0].fill(stream_buffer::sample_t(m_left_data) * sample_scale); + outputs[1].fill(stream_buffer::sample_t(m_right_data) * sample_scale); } diff --git a/src/devices/sound/bsmt2000.h b/src/devices/sound/bsmt2000.h index 014d6bc6b2d..289457cffd9 100644 --- a/src/devices/sound/bsmt2000.h +++ b/src/devices/sound/bsmt2000.h @@ -53,7 +53,7 @@ protected: virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; // device_sound_interface overrides - 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<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; // device_rom_interface overrides virtual void rom_bank_updated() override; diff --git a/src/devices/sound/c140.cpp b/src/devices/sound/c140.cpp index 3fe32fd13db..0edb1920a8c 100644 --- a/src/devices/sound/c140.cpp +++ b/src/devices/sound/c140.cpp @@ -77,9 +77,9 @@ DEFINE_DEVICE_TYPE(C219, c219_device, "c219", "Namco C219") // LIVE DEVICE //************************************************************************** -static inline int limit(s32 in) +static inline stream_buffer::sample_t limit(stream_buffer::sample_t in) { - return std::max(-0x7fff, std::min(0x8000, in)); + return std::max(-1.0f, std::min(1.0f, in)); } @@ -125,7 +125,7 @@ void c140_device::device_start() m_int1_callback.resolve_safe(); m_int1_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(c140_device::int1_on), this)); - m_stream = stream_alloc_legacy(0, 2, m_sample_rate); + m_stream = stream_alloc(0, 2, m_sample_rate); // make decompress pcm table (Verified from Wii Virtual Console Arcade Starblade) for (int i = 0; i < 256; i++) @@ -217,10 +217,10 @@ void c140_device::rom_bank_updated() //------------------------------------------------- -// sound_stream_update_legacy - handle a stream update +// sound_stream_update - handle a stream update //------------------------------------------------- -void c140_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) +void c140_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) { s32 dt; @@ -228,6 +228,7 @@ void c140_device::sound_stream_update_legacy(sound_stream &stream, stream_sample s16 *lmix, *rmix; + int samples = outputs[0].samples(); if (samples > m_sample_rate) samples = m_sample_rate; /* zap the contents of the mixer buffer */ @@ -323,21 +324,22 @@ void c140_device::sound_stream_update_legacy(sound_stream &stream, stream_sample lmix = m_mixer_buffer_left.get(); rmix = m_mixer_buffer_right.get(); { - stream_sample_t *dest1 = outputs[0]; - stream_sample_t *dest2 = outputs[1]; + auto &dest1 = outputs[0]; + auto &dest2 = outputs[1]; + constexpr stream_buffer::sample_t sample_scale = 8.0 / 32768.0; for (int i = 0; i < samples; i++) { - s32 val; + stream_buffer::sample_t val; - val = 8 * (*lmix++); - *dest1++ = limit(val); - val = 8 * (*rmix++); - *dest2++ = limit(val); + val = stream_buffer::sample_t(*lmix++) * sample_scale; + dest1.put(i, limit(val)); + val = stream_buffer::sample_t(*rmix++) * sample_scale; + dest2.put(i, limit(val)); } } } -void c219_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) +void c219_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) { s32 dt; @@ -345,6 +347,7 @@ void c219_device::sound_stream_update_legacy(sound_stream &stream, stream_sample s16 *lmix, *rmix; + int samples = outputs[0].samples(); if (samples > m_sample_rate) samples = m_sample_rate; /* zap the contents of the mixer buffer */ @@ -460,16 +463,17 @@ void c219_device::sound_stream_update_legacy(sound_stream &stream, stream_sample lmix = m_mixer_buffer_left.get(); rmix = m_mixer_buffer_right.get(); { - stream_sample_t *dest1 = outputs[0]; - stream_sample_t *dest2 = outputs[1]; + auto &dest1 = outputs[0]; + auto &dest2 = outputs[1]; + constexpr stream_buffer::sample_t sample_scale = 8.0 / 32768.0; for (int i = 0; i < samples; i++) { - s32 val; + stream_buffer::sample_t val; - val = 8 * (*lmix++); - *dest1++ = limit(val); - val = 8 * (*rmix++); - *dest2++ = limit(val); + val = stream_buffer::sample_t(*lmix++) * sample_scale; + dest1.put(i, limit(val)); + val = stream_buffer::sample_t(*rmix++) * sample_scale; + dest2.put(i, limit(val)); } } } diff --git a/src/devices/sound/c140.h b/src/devices/sound/c140.h index a6df491815b..3008d964a9d 100644 --- a/src/devices/sound/c140.h +++ b/src/devices/sound/c140.h @@ -44,7 +44,7 @@ protected: virtual void rom_bank_updated() override; // sound stream update overrides - 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<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; virtual int find_sample(int adrs, int bank, int voice); @@ -116,7 +116,7 @@ protected: virtual void device_start() override; // sound stream update overrides - 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<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; virtual int find_sample(int adrs, int bank, int voice) override; diff --git a/src/devices/sound/c352.cpp b/src/devices/sound/c352.cpp index ed27870c053..826f194437a 100644 --- a/src/devices/sound/c352.cpp +++ b/src/devices/sound/c352.cpp @@ -122,14 +122,15 @@ void c352_device::ramp_volume(c352_voice_t &v, int ch, u8 val) v.curr_vol[ch] += (vol_delta > 0) ? -1 : 1; } -void c352_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) +void c352_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) { - stream_sample_t *buffer_fl = outputs[0]; - stream_sample_t *buffer_fr = outputs[1]; - stream_sample_t *buffer_rl = outputs[2]; - stream_sample_t *buffer_rr = outputs[3]; + auto &buffer_fl = outputs[0]; + auto &buffer_fr = outputs[1]; + auto &buffer_rl = outputs[2]; + auto &buffer_rr = outputs[3]; - for (int i = 0; i < samples; i++) + constexpr stream_buffer::sample_t sample_scale = 1.0 / 32768.0; + for (int i = 0; i < buffer_fl.samples(); i++) { int out[4] = { 0, 0, 0, 0 }; @@ -173,10 +174,10 @@ void c352_device::sound_stream_update_legacy(sound_stream &stream, stream_sample out[3] += (((v.flags & C352_FLG_PHASEFR) ? -s : s) * v.curr_vol[3]) >> 8; } - *buffer_fl++ = (s16)(out[0] >> 3); - *buffer_fr++ = (s16)(out[1] >> 3); - *buffer_rl++ = (s16)(out[2] >> 3); - *buffer_rr++ = (s16)(out[3] >> 3); + buffer_fl.put(i, stream_buffer::sample_t(s16(out[0] >> 3)) * sample_scale); + buffer_fr.put(i, stream_buffer::sample_t(s16(out[1] >> 3)) * sample_scale); + buffer_rl.put(i, stream_buffer::sample_t(s16(out[2] >> 3)) * sample_scale); + buffer_rr.put(i, stream_buffer::sample_t(s16(out[3] >> 3)) * sample_scale); } } @@ -358,14 +359,14 @@ void c352_device::device_clock_changed() if (m_stream != nullptr) m_stream->set_sample_rate(m_sample_rate_base); else - m_stream = stream_alloc_legacy(0, 4, m_sample_rate_base); + m_stream = stream_alloc(0, 4, m_sample_rate_base); } void c352_device::device_start() { m_sample_rate_base = clock() / m_divider; - m_stream = stream_alloc_legacy(0, 4, m_sample_rate_base); + m_stream = stream_alloc(0, 4, m_sample_rate_base); // generate mulaw table (Output similar to namco's VC emulator) int j = 0; diff --git a/src/devices/sound/c352.h b/src/devices/sound/c352.h index cbb2f1fd2a6..d21ac96cd86 100644 --- a/src/devices/sound/c352.h +++ b/src/devices/sound/c352.h @@ -39,7 +39,7 @@ protected: virtual void device_clock_changed() override; // device_sound_interface overrides - 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<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; // device_rom_interface overrides virtual void rom_bank_updated() override; diff --git a/src/devices/sound/c6280.cpp b/src/devices/sound/c6280.cpp index f118b3725c5..d01dd74125a 100644 --- a/src/devices/sound/c6280.cpp +++ b/src/devices/sound/c6280.cpp @@ -42,15 +42,16 @@ #include <algorithm> -void c6280_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) +void c6280_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) { const u8 lmal = (m_balance >> 4) & 0x0f; const u8 rmal = (m_balance >> 0) & 0x0f; /* Clear buffer */ - std::fill_n(&outputs[0][0], samples, 0); - std::fill_n(&outputs[1][0], samples, 0); + outputs[0].fill(0); + outputs[1].fill(0); + constexpr stream_buffer::sample_t sample_scale = 1.0 / 32768.0; for (int ch = 0; ch < 6; ch++) { channel *chan = &m_channel[ch]; @@ -76,7 +77,7 @@ void c6280_device::sound_stream_update_legacy(sound_stream &stream, stream_sampl { /* Noise mode */ const u32 step = (chan->noise_control & 0x1f) ^ 0x1f; - for (int i = 0; i < samples; i += 1) + for (int i = 0; i < outputs[0].samples(); i += 1) { s16 data = BIT(chan->noise_seed, 0) ? 0x1f : 0; chan->noise_counter--; @@ -87,18 +88,18 @@ void c6280_device::sound_stream_update_legacy(sound_stream &stream, stream_sampl // based on Charles MacDonald's research chan->noise_seed = (seed >> 1) | ((BIT(seed, 0) ^ BIT(seed, 1) ^ BIT(seed, 11) ^ BIT(seed, 12) ^ BIT(seed, 17)) << 17); } - outputs[0][i] += (s16)(vll * (data - 16)); - outputs[1][i] += (s16)(vlr * (data - 16)); + outputs[0].add(i, stream_buffer::sample_t(s16(vll * (data - 16))) * sample_scale); + outputs[1].add(i, stream_buffer::sample_t(s16(vlr * (data - 16))) * sample_scale); } } else if (chan->control & 0x40) { /* DDA mode */ - for (int i = 0; i < samples; i++) + for (int i = 0; i < outputs[0].samples(); i++) { - outputs[0][i] += (s16)(vll * (chan->dda - 16)); - outputs[1][i] += (s16)(vlr * (chan->dda - 16)); + outputs[0].add(i, stream_buffer::sample_t(s16(vll * (chan->dda - 16))) * sample_scale); + outputs[1].add(i, stream_buffer::sample_t(s16(vlr * (chan->dda - 16))) * sample_scale); } } else @@ -111,7 +112,7 @@ void c6280_device::sound_stream_update_legacy(sound_stream &stream, stream_sampl channel *lfo_srcchan = &m_channel[1]; channel *lfo_dstchan = &m_channel[0]; const u16 lfo_step = lfo_srcchan->frequency ? lfo_srcchan->frequency : 0x1000; - for (int i = 0; i < samples; i += 1) + for (int i = 0; i < outputs[0].samples(); i += 1) { s32 step = lfo_dstchan->frequency ? lfo_dstchan->frequency : 0x1000; if (m_lfo_control & 0x80) // reset LFO @@ -137,8 +138,8 @@ void c6280_device::sound_stream_update_legacy(sound_stream &stream, stream_sampl lfo_dstchan->tick = step; lfo_dstchan->index = (lfo_dstchan->index + 1) & 0x1f; } - outputs[0][i] += (s16)(vll * (data - 16)); - outputs[1][i] += (s16)(vlr * (data - 16)); + outputs[0].add(i, stream_buffer::sample_t(s16(vll * (data - 16))) * sample_scale); + outputs[1].add(i, stream_buffer::sample_t(s16(vlr * (data - 16))) * sample_scale); } } } @@ -146,7 +147,7 @@ void c6280_device::sound_stream_update_legacy(sound_stream &stream, stream_sampl { /* Waveform mode */ const u32 step = chan->frequency ? chan->frequency : 0x1000; - for (int i = 0; i < samples; i += 1) + for (int i = 0; i < outputs[0].samples(); i += 1) { const s16 data = chan->waveform[chan->index]; chan->tick--; @@ -155,8 +156,8 @@ void c6280_device::sound_stream_update_legacy(sound_stream &stream, stream_sampl chan->tick = step; chan->index = (chan->index + 1) & 0x1f; } - outputs[0][i] += (s16)(vll * (data - 16)); - outputs[1][i] += (s16)(vlr * (data - 16)); + outputs[0].add(i, stream_buffer::sample_t(s16(vll * (data - 16))) * sample_scale); + outputs[1].add(i, stream_buffer::sample_t(s16(vlr * (data - 16))) * sample_scale); } } } @@ -319,7 +320,7 @@ void c6280_device::device_start() m_lfo_control = 0; memset(m_channel, 0, sizeof(channel) * 8); - m_stream = stream_alloc_legacy(0, 2, clock()); + m_stream = stream_alloc(0, 2, clock()); /* Make volume table */ /* PSG has 48dB volume range spread over 32 steps */ diff --git a/src/devices/sound/c6280.h b/src/devices/sound/c6280.h index 406a2f8e2a9..60ea993f71b 100644 --- a/src/devices/sound/c6280.h +++ b/src/devices/sound/c6280.h @@ -22,7 +22,7 @@ protected: virtual void device_clock_changed() override; // sound stream update overrides - 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<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; private: struct channel { diff --git a/src/devices/sound/cdda.cpp b/src/devices/sound/cdda.cpp index 47dab749d49..ca2bd280de8 100644 --- a/src/devices/sound/cdda.cpp +++ b/src/devices/sound/cdda.cpp @@ -12,14 +12,14 @@ //------------------------------------------------- -// sound_stream_update_legacy - handle a stream update +// sound_stream_update - handle a stream update //------------------------------------------------- -void cdda_device::sound_stream_update_legacy(sound_stream &stream, stream_sample_t const * const *inputs, stream_sample_t * const *outputs, int samples) +void cdda_device::sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) { - get_audio_data(&outputs[0][0], &outputs[1][0], samples); - m_audio_volume[0] = int16_t(outputs[0][0]); - m_audio_volume[1] = int16_t(outputs[1][0]); + get_audio_data(outputs[0], outputs[1]); + m_audio_volume[0] = outputs[0].get(0); + m_audio_volume[1] = outputs[1].get(0); } //------------------------------------------------- @@ -31,7 +31,7 @@ void cdda_device::device_start() /* allocate an audio cache */ m_audio_cache = std::make_unique<uint8_t[]>(CD_MAX_SECTOR_DATA * MAX_SECTORS ); - m_stream = stream_alloc_legacy(0, 2, clock()); + m_stream = stream_alloc(0, 2, clock()); m_audio_playing = 0; m_audio_pause = 0; @@ -159,12 +159,13 @@ int cdda_device::audio_ended() converts it to 2 16-bit 44.1 kHz streams -------------------------------------------------*/ -void cdda_device::get_audio_data(stream_sample_t *bufL, stream_sample_t *bufR, uint32_t samples_wanted) +void cdda_device::get_audio_data(write_stream_view &bufL, write_stream_view &bufR) { int i; int16_t *audio_cache = (int16_t *) m_audio_cache.get(); - while (samples_wanted > 0) + constexpr stream_buffer::sample_t sample_scale = 1.0 / 32768.0; + for (int sampindex = 0; sampindex < bufL.samples(); ) { /* if no file, audio not playing, audio paused, or out of disc data, just zero fill */ @@ -176,12 +177,12 @@ void cdda_device::get_audio_data(stream_sample_t *bufL, stream_sample_t *bufR, u m_audio_ended_normally = true; } - memset(bufL, 0, sizeof(stream_sample_t)*samples_wanted); - memset(bufR, 0, sizeof(stream_sample_t)*samples_wanted); + bufL.fill(0, sampindex); + bufR.fill(0, sampindex); return; } - int samples = samples_wanted; + int samples = bufL.samples() - sampindex; if (samples > m_audio_samples) { samples = m_audio_samples; @@ -190,11 +191,11 @@ void cdda_device::get_audio_data(stream_sample_t *bufL, stream_sample_t *bufR, u for (i = 0; i < samples; i++) { /* CD-DA data on the disc is big-endian */ - *bufL++ = (int16_t) big_endianize_int16( audio_cache[ m_audio_bptr ] ); m_audio_bptr++; - *bufR++ = (int16_t) big_endianize_int16( audio_cache[ m_audio_bptr ] ); m_audio_bptr++; + bufL.put(sampindex + i, stream_buffer::sample_t(s16(big_endianize_int16( audio_cache[ m_audio_bptr ] ))) * sample_scale); m_audio_bptr++; + bufR.put(sampindex + i, stream_buffer::sample_t(s16(big_endianize_int16( audio_cache[ m_audio_bptr ] ))) * sample_scale); m_audio_bptr++; } - samples_wanted -= samples; + sampindex += samples; m_audio_samples -= samples; if (m_audio_samples == 0) diff --git a/src/devices/sound/cdda.h b/src/devices/sound/cdda.h index 6654a7949c1..b0c7b7f81e8 100644 --- a/src/devices/sound/cdda.h +++ b/src/devices/sound/cdda.h @@ -30,10 +30,10 @@ protected: virtual void device_start() override; // sound stream update overrides - 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<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override; private: - void get_audio_data(stream_sample_t *bufL, stream_sample_t *bufR, uint32_t samples_wanted); + void get_audio_data(write_stream_view &bufL, write_stream_view &bufR); cdrom_file * m_disc; |