static void sound_exit(running_machine *machine) { int sndnum; if (wavfile) wav_close(wavfile); #ifdef MAME_DEBUG { int spknum; /* log the maximum sample values for all speakers */ for (spknum = 0; spknum < totalspeakers; spknum++) if (speaker[spknum].max_sample > 0) { speaker_info *spk = &speaker[spknum]; mame_printf_debug("Speaker \"%s\" - max = %d (gain *= %f) - %d%% samples clipped\n", spk->speaker->tag, spk->max_sample, 32767.0 / (spk->max_sample ? spk->max_sample : 1), (int)((double)spk->clipped_samples * 100.0 / spk->total_samples)); } } #endif /* MAME_DEBUG */ /* stop all the sound chips */ for (sndnum = 0; sndnum < MAX_SOUND; sndnum++) if (Machine->drv->sound[sndnum].sound_type != 0) sndintrf_exit_sound(sndnum); /* stop the OSD code */ osd_stop_audio_stream(); /* reset variables */ totalspeakers = 0; totalsnd = 0; memset(&speaker, 0, sizeof(speaker)); memset(&sound, 0, sizeof(sound)); }
void osd_sound_enable (int enable_it) { if (sound_stream && enable_it) { sound_enabled = 1; xmame_func_set(sound_enabled); /* for QUASI88 */ if (!sound_dsp) { if (!(sound_dsp = sysdep_dsp_create(NULL, sound_dsp_device, &options_samplerate, &type, sound_bufsize * (1 / Machine__drv__frames_per_second), SYSDEP_DSP_EMULATE_TYPE | SYSDEP_DSP_O_NONBLOCK))) { sound_enabled = 0; xmame_func_set(sound_enabled); /* for QUASI88 */ } else { sound_stream_destroy(sound_stream); if (!(sound_stream = sound_stream_create(sound_dsp, type, sound_samples_per_frame, 3))) { osd_stop_audio_stream(); sound_enabled = 0; xmame_func_set(sound_enabled); /* for QUASI88 */ } } } } else { if (sound_dsp) { sysdep_dsp_destroy(sound_dsp); sound_dsp = NULL; } sound_enabled = 0; xmame_func_set(sound_enabled); /* for QUASI88 */ } }
/* * xmame-0.71.1/src/unix/sound.c */ int osd_start_audio_stream(int stereo) { type = SYSDEP_DSP_16BIT | (stereo? SYSDEP_DSP_STEREO:SYSDEP_DSP_MONO); /* create dsp */ if(sound_enabled) { if(!(sound_dsp = sysdep_dsp_create( &options_samplerate, &type, sound_bufsize * (1 / Machine__drv__frames_per_second) ))) { osd_stop_audio_stream(); sound_enabled = 0; xmame_func_set(sound_enabled); } } /* create sound_stream */ if(sound_enabled) { /* calculate samples_per_frame */ sound_samples_per_frame = (int)(Machine__sample_rate / Machine__drv__frames_per_second); /* mean 22050Hz/55.4Hz */ } /* if sound is not enabled, set the samplerate of the core to 0 */ if(!sound_enabled) { sound_samples_per_frame = 0; } /* return the samples to play the first frame */ return sound_samples_per_frame; }
void osd_sound_enable (int enable_it) { if (sound_stream && enable_it) { sound_enabled = 1; if (!sound_dsp) { if (!(sound_dsp = sysdep_dsp_create(NULL, sound_dsp_device, &options.samplerate, &type, sound_bufsize * (1 / Machine->drv->frames_per_second), SYSDEP_DSP_EMULATE_TYPE | SYSDEP_DSP_O_NONBLOCK))) sound_enabled = 0; else { sound_stream_destroy(sound_stream); if (!(sound_stream = sound_stream_create(sound_dsp, type, sound_samples_per_frame, 3))) { osd_stop_audio_stream(); sound_enabled = 0; } } } } else { if (sound_dsp) { sysdep_dsp_destroy(sound_dsp); sound_dsp = NULL; } sound_enabled = 0; } }
int osd_start_audio_stream(int stereo) { type = SYSDEP_DSP_16BIT | (stereo? SYSDEP_DSP_STEREO:SYSDEP_DSP_MONO); sound_stream = NULL; /* create dsp */ if(sound_enabled) { if(!(sound_dsp = sysdep_dsp_create(NULL, sound_dsp_device, &options_samplerate, &type, sound_bufsize * (1 / Machine__drv__frames_per_second), SYSDEP_DSP_EMULATE_TYPE | SYSDEP_DSP_O_NONBLOCK))) { osd_stop_audio_stream(); sound_enabled = 0; xmame_func_set(sound_enabled); /* for QUASI88 */ } } /* create sound_stream */ if(sound_enabled) { #if 0 /* forQUASI88 */ /* sysdep_dsp_open may have changed the samplerate */ Machine->sample_rate = options.samplerate; #endif /* forQUASI88 */ /* calculate samples_per_frame */ sound_samples_per_frame = Machine__sample_rate / Machine__drv__frames_per_second; #ifdef SOUND_DEBUG fprintf(stderr, "debug: sound: samples_per_frame = %d\n", sound_samples_per_frame); #endif if(!(sound_stream = sound_stream_create(sound_dsp, type, sound_samples_per_frame, 3))) { osd_stop_audio_stream(); sound_enabled = 0; xmame_func_set(sound_enabled); /* for QUASI88 */ } } /* if sound is not enabled, set the samplerate of the core to 0 */ if(!sound_enabled) { #if 0 /* forQUASI88 */ if(sound_fake) Machine->sample_rate = options.samplerate = 8000; else Machine->sample_rate = options.samplerate = 0; #else /* forQUASI88 */ if(sound_fake) Machine__sample_rate = 8000; else Machine__sample_rate = 0; #endif /* forQUASI88 */ /* calculate samples_per_frame */ sound_samples_per_frame = Machine__sample_rate / Machine__drv__frames_per_second; return sound_samples_per_frame; } /* create a mixer instance */ sound_mixer = sysdep_mixer_create(NULL, sound_mixer_device, SYSDEP_MIXER_RESTORE_SETTINS_ON_EXIT); /* check if the user specified a volume, and ifso set it */ if(sound_mixer && rc_get_priority2(sound_opts, "volume")) osd_set_mastervolume(sound_attenuation); return sound_samples_per_frame; }
void mixer_sh_stop(void) { osd_stop_audio_stream(); }