diff options
Diffstat (limited to 'src/emu/sound.cpp')
-rw-r--r-- | src/emu/sound.cpp | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/src/emu/sound.cpp b/src/emu/sound.cpp index 805a6920fed..c876431c41b 100644 --- a/src/emu/sound.cpp +++ b/src/emu/sound.cpp @@ -410,7 +410,7 @@ void sound_stream::update_with_accounting(bool second_tick) { // if we have samples to move, do so for each output if (output_bufindex > 0) - for (auto & output : m_output) + for (auto &output : m_output) { memmove(&output.m_buffer[0], &output.m_buffer[samples_to_lose], sizeof(output.m_buffer[0]) * (output_bufindex - samples_to_lose)); } @@ -457,8 +457,8 @@ void sound_stream::apply_sample_rate_changes() // clear out the buffer if (m_max_samples_per_update) - for (auto & elem : m_output) - memset(&elem.m_buffer[0], 0, m_max_samples_per_update * sizeof(elem.m_buffer[0])); + for (auto &elem : m_output) + std::fill_n(&elem.m_buffer[0], m_max_samples_per_update, 0); } @@ -474,7 +474,7 @@ void sound_stream::recompute_sample_rate_data() { m_sample_rate = 0; // When synchronous, pick the sample rate for the inputs, if any - for (auto & input : m_input) + for (auto &input : m_input) { if (input.m_source != nullptr) { @@ -506,7 +506,7 @@ void sound_stream::recompute_sample_rate_data() allocate_output_buffers(); // iterate over each input - for (auto & input : m_input) + for (auto &input : m_input) { // if we have a source, see if its sample rate changed @@ -569,11 +569,8 @@ void sound_stream::allocate_resample_buffers() m_resample_bufalloc = bufsize; // iterate over outputs and realloc their buffers - for (auto & elem : m_input) { - unsigned int old_size = elem.m_resample.size(); - elem.m_resample.resize(m_resample_bufalloc); - memset(&elem.m_resample[old_size], 0, (m_resample_bufalloc - old_size)*sizeof(elem.m_resample[0])); - } + for (auto &elem : m_input) + elem.m_resample.resize(m_resample_bufalloc, 0); } } @@ -593,11 +590,8 @@ void sound_stream::allocate_output_buffers() m_output_bufalloc = bufsize; // iterate over outputs and realloc their buffers - for (auto & elem : m_output) { - unsigned int old_size = elem.m_buffer.size(); - elem.m_buffer.resize(m_output_bufalloc); - memset(&elem.m_buffer[old_size], 0, (m_output_bufalloc - old_size)*sizeof(elem.m_buffer[0])); - } + for (auto &elem : m_output) + elem.m_buffer.resize(m_output_bufalloc, 0); } } @@ -612,8 +606,8 @@ void sound_stream::postload() recompute_sample_rate_data(); // make sure our output buffers are fully cleared - for (auto & elem : m_output) - memset(&elem.m_buffer[0], 0, m_output_bufalloc * sizeof(elem.m_buffer[0])); + for (auto &elem : m_output) + std::fill_n(&elem.m_buffer[0], m_output_bufalloc, 0); // recompute the sample indexes to make sense m_output_sampindex = m_attoseconds_per_sample ? m_device.machine().sound().last_update().attoseconds() / m_attoseconds_per_sample : 0; @@ -684,7 +678,7 @@ stream_sample_t *sound_stream::generate_resampled_data(stream_input &input, u32 stream_sample_t *dest = &input.m_resample[0]; if (input.m_source == nullptr || input.m_source->m_stream->m_attoseconds_per_sample == 0) { - memset(dest, 0, numsamples * sizeof(*dest)); + std::fill_n(dest, numsamples, 0); return &input.m_resample[0]; } |