~ubuntu-branches/debian/sid/mame/sid

« back to all changes in this revision

Viewing changes to src/emu/disound.c

  • Committer: Package Import Robot
  • Author(s): Jordi Mallach, Emmanuel Kasper, Jordi Mallach
  • Date: 2012-06-05 20:02:23 UTC
  • mfrom: (0.3.1) (0.1.4)
  • Revision ID: package-import@ubuntu.com-20120605200223-gnlpogjrg6oqe9md
Tags: 0.146-1
[ Emmanuel Kasper ]
* New upstream release
* Drop patch to fix man pages section and patches to link with flac 
  and jpeg system lib: all this has been pushed upstream by Cesare Falco
* Add DM-Upload-Allowed: yes field.

[ Jordi Mallach ]
* Create a "gnu" TARGETOS stanza that defines NO_AFFINITY_NP.
* Stop setting TARGETOS to "unix" in d/rules. It should be autodetected,
  and set to the appropriate value.
* mame_manpage_section.patch: Change mame's manpage section to 6 (games),
  in the TH declaration.

Show diffs side-by-side

added added

removed removed

Lines of Context:
71
71
//  a new route to the device
72
72
//-------------------------------------------------
73
73
 
74
 
void device_sound_interface::static_add_route(device_t &device, UINT32 output, const char *target, double gain, UINT32 input)
 
74
device_sound_interface::sound_route &device_sound_interface::static_add_route(device_t &device, UINT32 output, const char *target, double gain, UINT32 input, UINT32 mixoutput)
75
75
{
76
76
        // find our sound interface
77
77
        device_sound_interface *sound;
79
79
                throw emu_fatalerror("MCFG_SOUND_ROUTE called on device '%s' with no sound interface", device.tag());
80
80
 
81
81
        // append a new route to the list
82
 
        astring devtag;
83
 
        device.siblingtag(devtag, target);
84
 
        sound->m_route_list.append(*global_alloc(sound_route(output, input, gain, devtag.cstr())));
 
82
        return sound->m_route_list.append(*global_alloc(sound_route(output, input, gain, target, mixoutput)));
85
83
}
86
84
 
87
85
 
200
198
 
201
199
 
202
200
//-------------------------------------------------
 
201
//  set_input_gain - set the gain on the given
 
202
//  input index of the device
 
203
//-------------------------------------------------
 
204
 
 
205
void device_sound_interface::set_input_gain(int inputnum, float gain)
 
206
{
 
207
        int stream_inputnum;
 
208
        sound_stream *stream = input_to_stream_input(inputnum, stream_inputnum);
 
209
        if (stream != NULL)
 
210
                stream->set_input_gain(stream_inputnum, gain);
 
211
}
 
212
 
 
213
 
 
214
//-------------------------------------------------
203
215
//  set_output_gain - set the gain on the given
204
216
//  output index of the device
205
217
//-------------------------------------------------
227
239
 
228
240
 
229
241
//-------------------------------------------------
 
242
//  inputnum_from_device - return the input number
 
243
//  that is connected to the given device's output
 
244
//-------------------------------------------------
 
245
 
 
246
int device_sound_interface::inputnum_from_device(device_t &source_device, int outputnum) const
 
247
{
 
248
        int overall = 0;
 
249
        for (sound_stream *stream = m_device.machine().sound().first_stream(); stream != NULL; stream = stream->next())
 
250
                if (&stream->device() == &device())
 
251
                        for (int inputnum = 0; inputnum < stream->input_count(); inputnum++, overall++)
 
252
                                if (stream->input_source_device(inputnum) == &source_device && stream->input_source_outputnum(inputnum) == outputnum)
 
253
                                        return overall;
 
254
        return -1;
 
255
}
 
256
 
 
257
 
 
258
//-------------------------------------------------
230
259
//  interface_validity_check - validation for a
231
260
//  device after the configuration has been
232
261
//  constructed
265
294
                for (const sound_route *route = sound->first_route(); route != NULL; route = route->next())
266
295
                {
267
296
                        // see if we are the target of this route; if we are, make sure the source device is started
268
 
                        device_t *target_device = m_device.machine().device(route->m_target);
 
297
                        device_t *target_device = sound->device().siblingdevice(route->m_target);
269
298
                        if (target_device == &m_device && !sound->device().started())
270
299
                                throw device_missing_dependencies();
271
300
                }
279
308
                for (const sound_route *route = sound->first_route(); route != NULL; route = route->next())
280
309
                {
281
310
                        // see if we are the target of this route
282
 
                        device_t *target_device = m_device.machine().device(route->m_target);
 
311
                        device_t *target_device = sound->device().siblingdevice(route->m_target);
283
312
                        if (target_device == &m_device && route->m_input == AUTO_ALLOC_INPUT)
284
313
                        {
285
314
                                const_cast<sound_route *>(route)->m_input = m_auto_allocated_inputs;
305
334
                for (const sound_route *route = sound->first_route(); route != NULL; route = route->next())
306
335
                {
307
336
                        // if we are the target of this route, hook it up
308
 
                        device_t *target_device = m_device.machine().device(route->m_target);
 
337
                        device_t *target_device = sound->device().siblingdevice(route->m_target);
309
338
                        if (target_device == &m_device)
310
339
                        {
311
340
                                // iterate over all outputs, matching any that apply
358
387
//  sound_route - constructor
359
388
//-------------------------------------------------
360
389
 
361
 
device_sound_interface::sound_route::sound_route(int output, int input, float gain, const char *target)
 
390
device_sound_interface::sound_route::sound_route(int output, int input, float gain, const char *target, UINT32 mixoutput)
362
391
        : m_next(NULL),
363
392
          m_output(output),
364
393
          m_input(input),
 
394
          m_mixoutput(mixoutput),
365
395
          m_gain(gain),
366
396
          m_target(target)
367
397
{
368
398
}
 
399
 
 
400
 
 
401
 
 
402
//**************************************************************************
 
403
//  SIMPLE DERIVED MIXER INTERFACE
 
404
//**************************************************************************
 
405
 
 
406
//-------------------------------------------------
 
407
//  device_mixer_interface - constructor
 
408
//-------------------------------------------------
 
409
 
 
410
device_mixer_interface::device_mixer_interface(const machine_config &mconfig, device_t &device, int outputs)
 
411
        : device_sound_interface(mconfig, device),
 
412
          m_outputs(outputs),
 
413
          m_mixer_stream(NULL)
 
414
{
 
415
}
 
416
 
 
417
 
 
418
//-------------------------------------------------
 
419
//  ~device_mixer_interface - destructor
 
420
//-------------------------------------------------
 
421
 
 
422
device_mixer_interface::~device_mixer_interface()
 
423
{
 
424
}
 
425
 
 
426
 
 
427
//-------------------------------------------------
 
428
//  interface_pre_start - perform startup prior
 
429
//  to the device startup
 
430
//-------------------------------------------------
 
431
 
 
432
void device_mixer_interface::interface_pre_start()
 
433
{
 
434
        // call our parent
 
435
        device_sound_interface::interface_pre_start();
 
436
 
 
437
        // no inputs? that's weird
 
438
        if (m_auto_allocated_inputs == 0)
 
439
        {
 
440
                logerror("Warning: mixer \"%s\" has no inputs\n", device().tag());
 
441
                return;
 
442
        }
 
443
 
 
444
        // generate the output map
 
445
        m_outputmap.resize(m_auto_allocated_inputs);
 
446
 
 
447
        // iterate through all routes that point to us and note their mixer output
 
448
        sound_interface_iterator iter(m_device.machine().root_device());
 
449
        for (device_sound_interface *sound = iter.first(); sound != NULL; sound = iter.next())
 
450
                for (const sound_route *route = sound->first_route(); route != NULL; route = route->next())
 
451
                {
 
452
                        // see if we are the target of this route
 
453
                        device_t *target_device = sound->device().siblingdevice(route->m_target);
 
454
                        if (target_device == &device() && route->m_input < m_auto_allocated_inputs)
 
455
                        {
 
456
                                int count = (route->m_output == ALL_OUTPUTS) ? sound->outputs() : 1;
 
457
                                for (int output = 0; output < count; output++)
 
458
                                        m_outputmap[route->m_input + output] = route->m_mixoutput;
 
459
                        }
 
460
                }
 
461
 
 
462
        // allocate the mixer stream
 
463
        m_mixer_stream = stream_alloc(m_auto_allocated_inputs, m_outputs, device().machine().sample_rate());
 
464
}
 
465
 
 
466
 
 
467
//-------------------------------------------------
 
468
//  interface_post_load - after we load a save
 
469
//  state be sure to update the mixer stream's
 
470
//  output sample rate
 
471
//-------------------------------------------------
 
472
 
 
473
void device_mixer_interface::interface_post_load()
 
474
{
 
475
        m_mixer_stream->set_sample_rate(device().machine().sample_rate());
 
476
 
 
477
        // call our parent
 
478
        device_sound_interface::interface_post_load();
 
479
}
 
480
 
 
481
 
 
482
//-------------------------------------------------
 
483
//  mixer_update - mix all inputs to one output
 
484
//-------------------------------------------------
 
485
 
 
486
void device_mixer_interface::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples)
 
487
{
 
488
        // clear output buffers
 
489
        for (int output = 0; output < m_outputs; output++)
 
490
                memset(outputs[output], 0, samples * sizeof(outputs[0][0]));
 
491
 
 
492
        // loop over samples
 
493
        const UINT8 *outmap = &m_outputmap[0];
 
494
        for (int pos = 0; pos < samples; pos++)
 
495
        {
 
496
                // for each input, add it to the appropriate output
 
497
                for (int inp = 0; inp < m_auto_allocated_inputs; inp++)
 
498
                        outputs[outmap[inp]][pos] += inputs[inp][pos];
 
499
        }
 
500
}