summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2010-08-12 02:46:57 +0000
committer Aaron Giles <aaron@aarongiles.com>2010-08-12 02:46:57 +0000
commit302396a054d4ff49be011ffbf8ccae678b3dd354 (patch)
treec59b6f379b840caee1335287d2718094938b0c24
parent9199da5ddfb823e9f429c0eda04d372f11a7a549 (diff)
Fix crash when restoring system with OKI6295. Basically, move the
state callback registration earlier for streams so that they are all properly restored before any devices get their callbacks.
-rw-r--r--src/emu/streams.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/emu/streams.c b/src/emu/streams.c
index 2665d3a35aa..e8ed193af7f 100644
--- a/src/emu/streams.c
+++ b/src/emu/streams.c
@@ -231,6 +231,7 @@ void streams_init(running_machine *machine)
/* register global states */
state_save_register_global(machine, strdata->last_update.seconds);
state_save_register_global(machine, strdata->last_update.attoseconds);
+ state_save_register_postload(machine, stream_postload, strdata);
}
@@ -359,7 +360,6 @@ sound_stream *stream_create(device_t *device, int inputs, int outputs, int sampl
/* create a unique tag for saving */
sprintf(statetag, "%d", stream->index);
state_save_register_item(machine, "stream", statetag, 0, stream->sample_rate);
- state_save_register_postload(machine, stream_postload, stream);
/* allocate space for the inputs */
if (inputs > 0)
@@ -692,21 +692,21 @@ void stream_set_output_gain(sound_stream *stream, int output, float gain)
static STATE_POSTLOAD( stream_postload )
{
- streams_private *strdata = machine->streams_data;
- sound_stream *stream = (sound_stream *)param;
- int outputnum;
-
- /* recompute the same rate information */
- recompute_sample_rate_data(machine, stream);
+ streams_private *strdata = reinterpret_cast<streams_private *>(param);
+ for (sound_stream *stream = strdata->stream_head; stream != NULL; stream = stream->next)
+ {
+ /* recompute the same rate information */
+ recompute_sample_rate_data(machine, stream);
- /* make sure our output buffers are fully cleared */
- for (outputnum = 0; outputnum < stream->outputs; outputnum++)
- memset(stream->output[outputnum].buffer, 0, stream->output_bufalloc * sizeof(stream->output[outputnum].buffer[0]));
+ /* make sure our output buffers are fully cleared */
+ for (int outputnum = 0; outputnum < stream->outputs; outputnum++)
+ memset(stream->output[outputnum].buffer, 0, stream->output_bufalloc * sizeof(stream->output[outputnum].buffer[0]));
- /* recompute the sample indexes to make sense */
- stream->output_sampindex = strdata->last_update.attoseconds / stream->attoseconds_per_sample;
- stream->output_update_sampindex = stream->output_sampindex;
- stream->output_base_sampindex = stream->output_sampindex - stream->max_samples_per_update;
+ /* recompute the sample indexes to make sense */
+ stream->output_sampindex = strdata->last_update.attoseconds / stream->attoseconds_per_sample;
+ stream->output_update_sampindex = stream->output_sampindex;
+ stream->output_base_sampindex = stream->output_sampindex - stream->max_samples_per_update;
+ }
}