--- uae/src/audio.c 2018/04/24 16:41:58 1.1.1.2 +++ uae/src/audio.c 2018/04/24 16:44:39 1.1.1.4 @@ -427,6 +427,7 @@ static __inline__ int sound_prefs_change { return (changed_prefs.produce_sound != currprefs.produce_sound || changed_prefs.stereo != currprefs.stereo + || changed_prefs.sound_freq != currprefs.sound_freq || changed_prefs.sound_bits != currprefs.sound_bits); } @@ -436,24 +437,27 @@ void check_prefs_changed_audio (void) return; close_sound (); + currprefs.produce_sound = changed_prefs.produce_sound; currprefs.stereo = changed_prefs.stereo; currprefs.sound_bits = changed_prefs.sound_bits; + currprefs.sound_freq = changed_prefs.sound_freq; - if (currprefs.produce_sound >= 1) { - if (! init_sound ()) { - if (currprefs.produce_sound == -1) { - fprintf (stderr, "Sound is not supported.\n"); - } else { - fprintf (stderr, "Sorry, can't initialize sound.\n"); - currprefs.produce_sound = 0; - } - } else { - last_cycles = cycles - 1; - next_sample_evtime = sample_evtime; - } + if (currprefs.produce_sound < 2) + return; + + if (init_sound ()) { + last_cycles = cycles - 1; + next_sample_evtime = sample_evtime; + return; + } + if (! sound_available) { + fprintf (stderr, "Sound is not supported.\n"); } else { - printf ("Sound system shut down.\n"); + fprintf (stderr, "Sorry, can't initialize sound.\n"); + currprefs.produce_sound = 0; + /* So we don't do this every frame */ + changed_prefs.produce_sound = 0; } } @@ -461,7 +465,7 @@ void update_audio (void) { unsigned long int n_cycles; - if (currprefs.produce_sound == 0) + if (currprefs.produce_sound < 2) return; n_cycles = cycles - last_cycles; @@ -488,7 +492,7 @@ void update_audio (void) audio_channel[2].evtime -= best_evtime; audio_channel[3].evtime -= best_evtime; n_cycles -= best_evtime; - if (next_sample_evtime == 0) { + if (next_sample_evtime == 0 && currprefs.produce_sound > 1) { next_sample_evtime = sample_evtime; (*sample_handler) (); }