summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Wilbert Pol <wilbertpol@users.noreply.github.com>2015-07-31 23:58:59 +0200
committer Wilbert Pol <wilbertpol@users.noreply.github.com>2015-07-31 23:58:59 +0200
commitd51aed9333c6ed14f0399f09d6048b78ba72fefb (patch)
tree9c93c1e8b4f420a5feac3fa87ba7d5d07540176b
parent4936d595461a87d44fe5ad03112257b1a482f7cb (diff)
wave.c: reduce tagmap lookups (nw)
-rw-r--r--src/emu/sound/wave.c16
-rw-r--r--src/emu/sound/wave.h3
2 files changed, 10 insertions, 9 deletions
diff --git a/src/emu/sound/wave.c b/src/emu/sound/wave.c
index 6728b7cafab..76f9bdda8d6 100644
--- a/src/emu/sound/wave.c
+++ b/src/emu/sound/wave.c
@@ -16,7 +16,6 @@
****************************************************************************/
#include "emu.h"
-#include "imagedev/cassette.h"
#include "wave.h"
#define ALWAYS_PLAY_SOUND 0
@@ -60,6 +59,7 @@ void wave_device::device_start()
machine().sound().stream_alloc(*this, 0, 2, machine().sample_rate());
else
machine().sound().stream_alloc(*this, 0, 1, machine().sample_rate());
+ m_cass = machine().device<cassette_image_device>(m_cassette_tag);
}
//-------------------------------------------------
@@ -68,8 +68,6 @@ void wave_device::device_start()
void wave_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
{
- cassette_image_device *cass = machine().device<cassette_image_device>(m_cassette_tag);
- cassette_image *cassette;
cassette_state state;
double time_index;
double duration;
@@ -77,20 +75,20 @@ void wave_device::sound_stream_update(sound_stream &stream, stream_sample_t **in
stream_sample_t *right_buffer = NULL;
int i;
- speaker_device_iterator spkiter(cass->machine().root_device());
+ speaker_device_iterator spkiter(m_cass->machine().root_device());
int speakers = spkiter.count();
if (speakers>1)
right_buffer = outputs[1];
- state = cass->get_state();
+ state = m_cass->get_state();
state = (cassette_state)(state & (CASSETTE_MASK_UISTATE | CASSETTE_MASK_MOTOR | CASSETTE_MASK_SPEAKER));
- if (cass->exists() && (ALWAYS_PLAY_SOUND || (state == (CASSETTE_PLAY | CASSETTE_MOTOR_ENABLED | CASSETTE_SPEAKER_ENABLED))))
+ if (m_cass->exists() && (ALWAYS_PLAY_SOUND || (state == (CASSETTE_PLAY | CASSETTE_MOTOR_ENABLED | CASSETTE_SPEAKER_ENABLED))))
{
- cassette = cass->get_image();
- time_index = cass->get_position();
- duration = ((double) samples) / cass->machine().sample_rate();
+ cassette_image *cassette = m_cass->get_image();
+ time_index = m_cass->get_position();
+ duration = ((double) samples) / m_cass->machine().sample_rate();
cassette_get_samples(cassette, 0, time_index, duration, samples, 2, left_buffer, CASSETTE_WAVEFORM_16BIT);
if (speakers > 1)
diff --git a/src/emu/sound/wave.h b/src/emu/sound/wave.h
index 77d78d95328..d4ff4865551 100644
--- a/src/emu/sound/wave.h
+++ b/src/emu/sound/wave.h
@@ -5,6 +5,8 @@
#ifndef __WAVE_H__
#define __WAVE_H__
+#include "imagedev/cassette.h"
+
/*****************************************************************************
* CassetteWave interface
@@ -28,6 +30,7 @@ protected:
private:
const char *m_cassette_tag;
+ cassette_image_device *m_cass;
};
extern const device_type WAVE;