From 302396a054d4ff49be011ffbf8ccae678b3dd354 Mon Sep 17 00:00:00 2001 From: Aaron Giles Date: Thu, 12 Aug 2010 02:46:57 +0000 Subject: [PATCH] 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. --- src/emu/streams.c | 28 ++++++++++++++-------------- 1 file 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; + streams_private *strdata = reinterpret_cast(param); + for (sound_stream *stream = strdata->stream_head; stream != NULL; stream = stream->next) + { + /* recompute the same rate information */ + recompute_sample_rate_data(machine, stream); - /* recompute the same rate information */ - recompute_sample_rate_data(machine, stream); + /* 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])); - /* 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])); - - /* 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; + } }