From 811605fcb53c9e7eb03ec597e76a80a54ec4b200 Mon Sep 17 00:00:00 2001 From: Jonathan Li Date: Sat, 4 Aug 2018 14:15:56 +0100 Subject: [PATCH] spu2-x:linux: Reduce non-timestretch minimum latency to 3ms This matches the Windows GUI behaviour. --- plugins/spu2-x/src/Linux/Config.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/plugins/spu2-x/src/Linux/Config.cpp b/plugins/spu2-x/src/Linux/Config.cpp index 8f1239d51d..db49cf622e 100644 --- a/plugins/spu2-x/src/Linux/Config.cpp +++ b/plugins/spu2-x/src/Linux/Config.cpp @@ -30,7 +30,8 @@ static const int LATENCY_MAX = 3000; static const int LATENCY_MAX = 750; #endif -static const int LATENCY_MIN = 15; +static const int LATENCY_MIN = 3; +static const int LATENCY_MIN_TIMESTRETCH = 15; int AutoDMAPlayRate[2] = {0, 0}; @@ -219,6 +220,15 @@ void debug_dialog() } #if defined(__unix__) + +static void cb_adjust_latency(GtkComboBox *widget, gpointer data) +{ + GtkRange *range = static_cast(data); + // Minimum latency for timestretch is 15ms. Everything else is 3ms. + const int min_latency = gtk_combo_box_get_active(widget) == 0 ? LATENCY_MIN_TIMESTRETCH : LATENCY_MIN; + gtk_range_set_range(range, min_latency, LATENCY_MAX); +} + void DisplayDialog() { int return_value; @@ -298,10 +308,11 @@ void DisplayDialog() #endif latency_label = gtk_label_new("Latency:"); + const int min_latency = SynchMode == 0 ? LATENCY_MIN_TIMESTRETCH : LATENCY_MIN; #if GTK_MAJOR_VERSION < 3 - latency_slide = gtk_hscale_new_with_range(LATENCY_MIN, LATENCY_MAX, 5); + latency_slide = gtk_hscale_new_with_range(min_latency, LATENCY_MAX, 5); #else - latency_slide = gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, LATENCY_MIN, LATENCY_MAX, 5); + latency_slide = gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, min_latency, LATENCY_MAX, 5); #endif gtk_range_set_value(GTK_RANGE(latency_slide), SndOutLatencyMS); @@ -358,6 +369,7 @@ void DisplayDialog() gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), main_frame); gtk_widget_show_all(dialog); + g_signal_connect(sync_box, "changed", G_CALLBACK(cb_adjust_latency), latency_slide); g_signal_connect_swapped(advanced_button, "clicked", G_CALLBACK(advanced_dialog), advanced_button); g_signal_connect_swapped(debug_button, "clicked", G_CALLBACK(debug_dialog), debug_button);