static void route_sound(running_machine *machine) { /* iterate again over all the sound chips */ device_sound_interface *sound = NULL; for (bool gotone = machine->m_devicelist.first(sound); gotone; gotone = sound->next(sound)) { int numoutputs = stream_get_device_outputs(*sound); /* iterate over all routes */ for (const device_config_sound_interface::sound_route *route = sound->sound_config().m_route_list; route != NULL; route = route->m_next) { device_t *target_device = machine->device(route->m_target); if (target_device->type() == SPEAKER) continue; int inputnum = route->m_input; /* iterate over all outputs, matching any that apply */ for (int outputnum = 0; outputnum < numoutputs; outputnum++) if (route->m_output == outputnum || route->m_output == ALL_OUTPUTS) { sound_stream *inputstream, *stream; int streaminput, streamoutput; if (stream_device_input_to_stream_input(target_device, inputnum++, &inputstream, &streaminput)) if (stream_device_output_to_stream_output(*sound, outputnum, &stream, &streamoutput)) stream_set_input(inputstream, streaminput, stream, streamoutput, route->m_gain); } } } }
void device_sound_interface::interface_post_start() { // count the outputs for (int outputnum = 0; outputnum < MAX_OUTPUTS; outputnum++) { // stop when we run out of streams sound_stream *stream = stream_find_by_device(&m_device, outputnum); if (stream == NULL) break; // accumulate the number of outputs from this stream int numoutputs = stream_get_outputs(stream); assert(m_outputs + numoutputs < MAX_OUTPUTS); // fill in the array for (int curoutput = 0; curoutput < numoutputs; curoutput++) { sound_output *output = &m_output[m_outputs++]; output->stream = stream; output->output = curoutput; } } // iterate over all the sound devices device_sound_interface *sound = NULL; for (bool gotone = m_device.machine->m_devicelist.first(sound); gotone; gotone = sound->next(sound)) { // scan each route on the device for (const device_config_sound_interface::sound_route *route = sound->sound_config().m_route_list; route != NULL; route = route->m_next) { // if we are the target of this route, hook it up device_t *target_device = m_device.machine->device(route->m_target); if (target_device == &m_device) { // iterate over all outputs, matching any that apply int inputnum = route->m_input; int numoutputs = stream_get_device_outputs(*sound); for (int outputnum = 0; outputnum < numoutputs; outputnum++) if (route->m_output == outputnum || route->m_output == ALL_OUTPUTS) { sound_stream *inputstream, *stream; int streaminput, streamoutput; // get the input and output streams and wire them together if (stream_device_input_to_stream_input(target_device, inputnum++, &inputstream, &streaminput)) if (stream_device_output_to_stream_output(*sound, outputnum, &stream, &streamoutput)) stream_set_input(inputstream, streaminput, stream, streamoutput, route->m_gain); } } } } }
void speaker_device::device_start() { // scan all the sound devices and count our inputs int inputs = 0; device_sound_interface *sound = NULL; for (bool gotone = machine->m_devicelist.first(sound); gotone; gotone = sound->next(sound)) { // scan each route on the device for (const device_config_sound_interface::sound_route *route = sound->sound_config().m_route_list; route != NULL; route = route->m_next) { // if we are the target of this route, accumulate inputs device_t *target_device = machine->device(route->m_target); if (target_device == this) { // if the sound device is not yet started, bail however -- we need the its stream if (!sound->device().started()) throw device_missing_dependencies(); // accumulate inputs inputs += (route->m_output == ALL_OUTPUTS) ? stream_get_device_outputs(*sound) : 1; } } } // no inputs? that's weird if (inputs == 0) { logerror("Warning: speaker \"%s\" has no inputs\n", tag()); return; } // now we know how many inputs; allocate the mixers and input data m_mixer_stream = stream_create(this, inputs, 1, machine->sample_rate, NULL, static_mixer_update); m_input = auto_alloc_array(machine, speaker_input, inputs); m_inputs = 0; // iterate again over all the sound devices for (bool gotone = machine->m_devicelist.first(sound); gotone; gotone = sound->next(sound)) { // scan each route on the device for (const device_config_sound_interface::sound_route *route = sound->sound_config().m_route_list; route != NULL; route = route->m_next) { // if we are the target of this route, hook it up device_t *target_device = machine->device(route->m_target); if (target_device == this) { // iterate over all outputs, matching any that apply int numoutputs = stream_get_device_outputs(*sound); for (int outputnum = 0; outputnum < numoutputs; outputnum++) if (route->m_output == outputnum || route->m_output == ALL_OUTPUTS) { // fill in the input data on this speaker m_input[m_inputs].m_gain = route->m_gain; m_input[m_inputs].m_default_gain = route->m_gain; m_input[m_inputs].m_name.printf("Speaker '%s': %s '%s'", tag(), sound->device().name(), sound->device().tag()); if (numoutputs > 1) m_input[m_inputs].m_name.catprintf(" Ch.%d", outputnum); // connect the output to the input sound_stream *stream; int streamoutput; if (stream_device_output_to_stream_output(*sound, outputnum, &stream, &streamoutput)) stream_set_input(m_mixer_stream, m_inputs++, stream, streamoutput, route->m_gain); } } } } }