mirror of https://github.com/snes9xgit/snes9x.git
GTK: SoundSync is now handled in the drivers.
This commit is contained in:
parent
b1039e7c65
commit
2ba6553c14
|
@ -327,23 +327,6 @@ event_hw_accel_changed (GtkComboBox *widget, gpointer data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
event_frameskip_combo_changed (GtkComboBox *widget, gpointer user_data)
|
|
||||||
{
|
|
||||||
Snes9xPreferences *window = (Snes9xPreferences *) user_data;
|
|
||||||
|
|
||||||
if (window->get_combo ("frameskip_combo") == THROTTLE_SOUND_SYNC)
|
|
||||||
{
|
|
||||||
window->set_check ("dynamic_rate_control", 0);
|
|
||||||
window->enable_widget ("dynamic_rate_control", 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
window->enable_widget ("dynamic_rate_control", 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
event_scale_method_changed (GtkComboBox *widget, gpointer user_data)
|
event_scale_method_changed (GtkComboBox *widget, gpointer user_data)
|
||||||
{
|
{
|
||||||
|
@ -532,7 +515,6 @@ Snes9xPreferences::Snes9xPreferences (Snes9xConfig *config) :
|
||||||
{ "game_data_clear", G_CALLBACK (event_game_data_clear) },
|
{ "game_data_clear", G_CALLBACK (event_game_data_clear) },
|
||||||
{ "about_clicked", G_CALLBACK (event_about_clicked) },
|
{ "about_clicked", G_CALLBACK (event_about_clicked) },
|
||||||
{ "auto_input_rate_toggled", G_CALLBACK (event_auto_input_rate_toggled) },
|
{ "auto_input_rate_toggled", G_CALLBACK (event_auto_input_rate_toggled) },
|
||||||
{ "frameskip_combo_changed", G_CALLBACK (event_frameskip_combo_changed) },
|
|
||||||
{ "calibrate", G_CALLBACK (event_calibrate) },
|
{ "calibrate", G_CALLBACK (event_calibrate) },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
@ -650,8 +632,6 @@ Snes9xPreferences::move_settings_to_dialog ()
|
||||||
config->auto_input_rate ? false : true);
|
config->auto_input_rate ? false : true);
|
||||||
set_spin ("sound_buffer_size", config->sound_buffer_size);
|
set_spin ("sound_buffer_size", config->sound_buffer_size);
|
||||||
|
|
||||||
if (Settings.SkipFrames == THROTTLE_SOUND_SYNC)
|
|
||||||
Settings.DynamicRateControl = 0;
|
|
||||||
set_check ("dynamic_rate_control", Settings.DynamicRateControl);
|
set_check ("dynamic_rate_control", Settings.DynamicRateControl);
|
||||||
set_spin ("dynamic_rate_limit", Settings.DynamicRateLimit / 1000.0);
|
set_spin ("dynamic_rate_limit", Settings.DynamicRateLimit / 1000.0);
|
||||||
set_spin ("rewind_buffer_size", config->rewind_buffer_size);
|
set_spin ("rewind_buffer_size", config->rewind_buffer_size);
|
||||||
|
@ -701,7 +681,6 @@ Snes9xPreferences::move_settings_to_dialog ()
|
||||||
set_combo ("scanline_filter_intensity", config->scanline_filter_intensity);
|
set_combo ("scanline_filter_intensity", config->scanline_filter_intensity);
|
||||||
|
|
||||||
set_combo ("frameskip_combo", Settings.SkipFrames);
|
set_combo ("frameskip_combo", Settings.SkipFrames);
|
||||||
enable_widget ("dynamic_rate_control", Settings.SkipFrames != THROTTLE_SOUND_SYNC);
|
|
||||||
set_check ("bilinear_filter", Settings.BilinearFilter);
|
set_check ("bilinear_filter", Settings.BilinearFilter);
|
||||||
|
|
||||||
#ifdef USE_OPENGL
|
#ifdef USE_OPENGL
|
||||||
|
|
|
@ -501,28 +501,11 @@ static void S9xThrottle ()
|
||||||
frame_clock = now;
|
frame_clock = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Settings.SkipFrames == THROTTLE_SOUND_SYNC &&
|
if (Settings.SkipFrames == THROTTLE_SOUND_SYNC ||
|
||||||
!Settings.DynamicRateControl)
|
Settings.SkipFrames == THROTTLE_NONE)
|
||||||
{
|
{
|
||||||
while (!S9xSyncSound())
|
|
||||||
{
|
|
||||||
usleep (100);
|
|
||||||
|
|
||||||
/* If we can't sync sound within a half-second, we're probably deadlocked */
|
|
||||||
if (g_get_monotonic_time() - now > 500000)
|
|
||||||
{
|
|
||||||
S9xClearSamples();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
frame_clock = now;
|
frame_clock = now;
|
||||||
IPPU.SkippedFrames = 0;
|
IPPU.SkippedFrames = 0;
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (Settings.SkipFrames == THROTTLE_NONE)
|
|
||||||
{
|
|
||||||
frame_clock = now;
|
|
||||||
}
|
}
|
||||||
else // THROTTLE_TIMER or THROTTLE_TIMER_FRAMESKIP
|
else // THROTTLE_TIMER or THROTTLE_TIMER_FRAMESKIP
|
||||||
{
|
{
|
||||||
|
|
|
@ -164,39 +164,51 @@ void S9xAlsaSoundDriver::samples_available()
|
||||||
|
|
||||||
frames = snd_pcm_avail(pcm);
|
frames = snd_pcm_avail(pcm);
|
||||||
|
|
||||||
if (Settings.DynamicRateControl)
|
|
||||||
{
|
|
||||||
S9xUpdateDynamicRate(snd_pcm_frames_to_bytes(pcm, frames),
|
|
||||||
output_buffer_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (frames < 0)
|
if (frames < 0)
|
||||||
{
|
{
|
||||||
frames = snd_pcm_recover(pcm, frames, 1);
|
frames = snd_pcm_recover(pcm, frames, 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
S9xFinalizeSamples();
|
|
||||||
|
|
||||||
if (Settings.DynamicRateControl)
|
if (Settings.DynamicRateControl)
|
||||||
|
{
|
||||||
|
S9xUpdateDynamicRate(snd_pcm_frames_to_bytes(pcm, frames),
|
||||||
|
output_buffer_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
S9xFinalizeSamples();
|
||||||
|
int snes_frames_available = S9xGetSampleCount() >> 1;
|
||||||
|
|
||||||
|
if (Settings.DynamicRateControl && !Settings.SoundSync)
|
||||||
{
|
{
|
||||||
// Using rate control, we should always keep the emulator's sound buffers empty to
|
// Using rate control, we should always keep the emulator's sound buffers empty to
|
||||||
// maintain an accurate measurement.
|
// maintain an accurate measurement.
|
||||||
if (frames < (S9xGetSampleCount() >> 1))
|
if (frames < snes_frames_available)
|
||||||
{
|
{
|
||||||
S9xClearSamples();
|
S9xClearSamples();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
frames = MIN(frames, S9xGetSampleCount() >> 1);
|
if (Settings.SoundSync && !Settings.TurboMode && !Settings.Mute)
|
||||||
|
{
|
||||||
|
while (frames < snes_frames_available)
|
||||||
|
{
|
||||||
|
usleep(100);
|
||||||
|
frames = snd_pcm_avail(pcm);
|
||||||
|
if (frames < 0)
|
||||||
|
{
|
||||||
|
frames = snd_pcm_recover(pcm, frames, 1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
frames = MIN(frames, snes_frames_available);
|
||||||
|
|
||||||
bytes = snd_pcm_frames_to_bytes(pcm, frames);
|
bytes = snd_pcm_frames_to_bytes(pcm, frames);
|
||||||
|
|
||||||
if (bytes <= 0)
|
if (bytes <= 0)
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (sound_buffer_size < bytes || sound_buffer == NULL)
|
if (sound_buffer_size < bytes || sound_buffer == NULL)
|
||||||
{
|
{
|
||||||
|
|
|
@ -168,7 +168,7 @@ void S9xOSSSoundDriver::samples_available()
|
||||||
|
|
||||||
samples_to_write = S9xGetSampleCount();
|
samples_to_write = S9xGetSampleCount();
|
||||||
|
|
||||||
if (Settings.DynamicRateControl)
|
if (Settings.DynamicRateControl && !Settings.SoundSync)
|
||||||
{
|
{
|
||||||
// Using rate control, we should always keep the emulator's sound buffers empty to
|
// Using rate control, we should always keep the emulator's sound buffers empty to
|
||||||
// maintain an accurate measurement.
|
// maintain an accurate measurement.
|
||||||
|
@ -179,6 +179,15 @@ void S9xOSSSoundDriver::samples_available()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Settings.SoundSync && !Settings.TurboMode && !Settings.Mute)
|
||||||
|
{
|
||||||
|
while (info.bytes >> 1 < samples_to_write)
|
||||||
|
{
|
||||||
|
usleep(100);
|
||||||
|
ioctl(filedes, SNDCTL_DSP_GETOSPACE, &info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
samples_to_write = MIN(info.bytes >> 1, samples_to_write) & ~1;
|
samples_to_write = MIN(info.bytes >> 1, samples_to_write) & ~1;
|
||||||
|
|
||||||
if (samples_to_write < 0)
|
if (samples_to_write < 0)
|
||||||
|
|
|
@ -188,8 +188,9 @@ void S9xPortAudioSoundDriver::samples_available()
|
||||||
}
|
}
|
||||||
|
|
||||||
S9xFinalizeSamples();
|
S9xFinalizeSamples();
|
||||||
|
int snes_frames_available = S9xGetSampleCount() >> 1;
|
||||||
|
|
||||||
if (Settings.DynamicRateControl)
|
if (Settings.DynamicRateControl && !Settings.SoundSync)
|
||||||
{
|
{
|
||||||
// Using rate control, we should always keep the emulator's sound buffers empty to
|
// Using rate control, we should always keep the emulator's sound buffers empty to
|
||||||
// maintain an accurate measurement.
|
// maintain an accurate measurement.
|
||||||
|
@ -200,7 +201,16 @@ void S9xPortAudioSoundDriver::samples_available()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
frames = MIN(frames, S9xGetSampleCount() >> 1);
|
if (Settings.SoundSync && !Settings.TurboMode && !Settings.Mute)
|
||||||
|
{
|
||||||
|
while (frames < snes_frames_available)
|
||||||
|
{
|
||||||
|
usleep(100);
|
||||||
|
frames = Pa_GetStreamWriteAvailable(audio_stream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
frames = MIN(frames, snes_frames_available);
|
||||||
bytes = frames_to_bytes(frames);
|
bytes = frames_to_bytes(frames);
|
||||||
|
|
||||||
if (sound_buffer_size < bytes || sound_buffer == NULL)
|
if (sound_buffer_size < bytes || sound_buffer == NULL)
|
||||||
|
|
|
@ -228,7 +228,7 @@ void S9xPulseSoundDriver::samples_available()
|
||||||
|
|
||||||
samples = S9xGetSampleCount();
|
samples = S9xGetSampleCount();
|
||||||
|
|
||||||
if (Settings.DynamicRateControl)
|
if (Settings.DynamicRateControl && !Settings.SoundSync)
|
||||||
{
|
{
|
||||||
if ((int)bytes < (samples * 2))
|
if ((int)bytes < (samples * 2))
|
||||||
{
|
{
|
||||||
|
@ -237,6 +237,17 @@ void S9xPulseSoundDriver::samples_available()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Settings.SoundSync && !Settings.TurboMode && !Settings.Mute)
|
||||||
|
{
|
||||||
|
while ((int)bytes < samples * 2)
|
||||||
|
{
|
||||||
|
usleep(100);
|
||||||
|
lock();
|
||||||
|
bytes = pa_stream_writable_size(stream);
|
||||||
|
unlock();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bytes = MIN((int)bytes, samples * 2) & ~1;
|
bytes = MIN((int)bytes, samples * 2) & ~1;
|
||||||
|
|
||||||
if (!bytes)
|
if (!bytes)
|
||||||
|
|
Loading…
Reference in New Issue