summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/sound/dmadac.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/sound/dmadac.cpp')
-rw-r--r--src/devices/sound/dmadac.cpp77
1 files changed, 10 insertions, 67 deletions
diff --git a/src/devices/sound/dmadac.cpp b/src/devices/sound/dmadac.cpp
index 384449fca9b..ae2ebce61ad 100644
--- a/src/devices/sound/dmadac.cpp
+++ b/src/devices/sound/dmadac.cpp
@@ -23,8 +23,6 @@
#define DEFAULT_SAMPLE_RATE (48000)
-#define BUFFER_SIZE 32768
-
/*************************************
*
@@ -38,8 +36,7 @@
void dmadac_sound_device::device_start()
{
- /* reset the state */
- m_volume = 1.0;
+ initialize_state();
/* allocate a stream channel */
m_channel = stream_alloc(0, 1, DEFAULT_SAMPLE_RATE);
@@ -49,11 +46,18 @@ void dmadac_sound_device::device_start()
save_item(NAME(m_bufout));
save_item(NAME(m_volume));
save_item(NAME(m_enabled));
- save_item(NAME(m_frequency));
save_item(NAME(m_buffer));
}
+void dmadac_sound_device::initialize_state()
+{
+ /* reset the state */
+ m_volume = 1.0;
+ m_bufin = m_bufout = 0;
+ m_enabled = 0;
+ std::fill_n(m_buffer.begin(), BUFFER_SIZE, 0);
+}
/*************************************
*
@@ -83,66 +87,6 @@ void dmadac_sound_device::flush()
m_channel->update();
}
-void dmadac_sound_device::transfer(int channel, offs_t channel_spacing, offs_t frame_spacing, offs_t total_frames, int16_t *data)
-{
- int j;
-
- /* loop over all channels and accumulate the data */
- constexpr stream_buffer::sample_t sample_scale = 1.0 / 32768.0;
- if (m_enabled)
- {
- int maxin = (m_bufout + BUFFER_SIZE - 1) % BUFFER_SIZE;
- int16_t *src = data + channel * channel_spacing;
- int curin = m_bufin;
-
- /* copy the data */
- for (j = 0; j < total_frames && curin != maxin; j++)
- {
- m_buffer[curin] = stream_buffer::sample_t(*src) * sample_scale;
- curin = (curin + 1) % BUFFER_SIZE;
- src += frame_spacing;
- }
- m_bufin = curin;
-
- /* log overruns */
- if (j != total_frames)
- logerror("dmadac_transfer: buffer overrun (short %d frames)\n", total_frames - j);
- }
-
- // FIXME: this line has rotted and can no longer compile - it should be fixed and uncommented or removed
- //LOG("dmadac_transfer - %d samples, %d effective, %d in buffer\n", total_frames, int(total_frames * double(DEFAULT_SAMPLE_RATE) / dmadac[first_channel].frequency), dmadac[first_channel].curinpos - dmadac[first_channel].curoutpos);
-}
-
-void dmadac_sound_device::transfer(int channel, offs_t channel_spacing, offs_t frame_spacing, offs_t total_frames, stream_buffer::sample_t *data)
-{
- int j;
-
- /* loop over all channels and accumulate the data */
- if (m_enabled)
- {
- int maxin = (m_bufout + BUFFER_SIZE - 1) % BUFFER_SIZE;
- stream_buffer::sample_t *src = data + channel * channel_spacing;
- int curin = m_bufin;
-
- /* copy the data */
- for (j = 0; j < total_frames && curin != maxin; j++)
- {
- m_buffer[curin] = *src;
- curin = (curin + 1) % BUFFER_SIZE;
- src += frame_spacing;
- }
- m_bufin = curin;
-
- /* log overruns */
- if (j != total_frames)
- logerror("dmadac_transfer: buffer overrun (short %d frames)\n", total_frames - j);
- }
-
- // FIXME: this line has rotted and can no longer compile - it should be fixed and uncommented or removed
- //LOG("dmadac_transfer - %d samples, %d effective, %d in buffer\n", total_frames, int(total_frames * double(DEFAULT_SAMPLE_RATE) / dmadac[first_channel].frequency), dmadac[first_channel].curinpos - dmadac[first_channel].curoutpos);
-}
-
-
/*************************************
*
@@ -226,8 +170,7 @@ dmadac_sound_device::dmadac_sound_device(const machine_config &mconfig, const ch
m_bufin(0),
m_bufout(0),
m_volume(0),
- m_enabled(0),
- m_frequency(0)
+ m_enabled(0)
{
}