]> granicus.if.org Git - handbrake/commitdiff
LinGui: disable invalid audio samplerates
authorJohn Stebbins <jstebbins.hb@gmail.com>
Thu, 25 Aug 2016 17:43:53 +0000 (10:43 -0700)
committerBradley Sepos <bradley@bradleysepos.com>
Fri, 2 Sep 2016 07:33:06 +0000 (03:33 -0400)
opus only supports a limited set of samplerates.  disable those that do
not apply.

gtk/src/audiohandler.c
gtk/src/hb-backend.c
gtk/src/hb-backend.h

index 8e434964f5b634828d76b07cd1d135c190585ef3..ba35ef97223fea4f2d3a560694adb199af8dfc11 100644 (file)
@@ -199,6 +199,10 @@ ghb_adjust_audio_rate_combos(signal_user_data_t *ud, GhbValue *asettings)
 
         GtkWidget *w = GHB_WIDGET(ud->builder, "AudioBitrate");
         ghb_audio_bitrate_opts_filter(GTK_COMBO_BOX(w), low, high);
+        w = GHB_WIDGET(ud->builder, "AudioMixdown");
+        ghb_mix_opts_filter(GTK_COMBO_BOX(w), acodec);
+        w = GHB_WIDGET(ud->builder, "AudioSamplerate");
+        ghb_audio_samplerate_opts_filter(GTK_COMBO_BOX(w), acodec);
 
         ghb_ui_update(ud, "AudioEncoder",
                       ghb_dict_get_value(asettings, "Encoder"));
@@ -2138,6 +2142,8 @@ void audio_def_set_limits(signal_user_data_t *ud, GtkWidget *widget, gboolean se
     ghb_audio_bitrate_opts_filter(GTK_COMBO_BOX(w), low, high);
     w = find_widget(GTK_WIDGET(row), "AudioMixdown");
     ghb_mix_opts_filter(GTK_COMBO_BOX(w), enc);
+    w = find_widget(GTK_WIDGET(row), "AudioSamplerate");
+    ghb_audio_samplerate_opts_filter(GTK_COMBO_BOX(w), enc);
 }
 
 void audio_def_set_all_limits_cb(GtkWidget *widget, gpointer data)
index 1df18e7031596795a00e1b12bef2430f5762cf8b..3eef1fede577712f0f9492078a0ba0ace95557ae 100644 (file)
@@ -1355,6 +1355,28 @@ audio_samplerate_opts_set(signal_user_data_t *ud, const gchar *name,
     ghb_audio_samplerate_opts_set(combo);
 }
 
+void
+ghb_audio_samplerate_opts_filter(GtkComboBox *combo, gint acodec)
+{
+    GtkTreeIter iter;
+    GtkListStore *store;
+    gdouble irate;
+
+    store = GTK_LIST_STORE(gtk_combo_box_get_model(combo));
+    if (!gtk_tree_model_get_iter_first( GTK_TREE_MODEL(store), &iter))
+        return;
+
+    do
+    {
+        gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, 3, &irate, -1);
+        // If irate == 0.0, the item is the "Same as Source" item,
+        // so set to TRUE. Otherwise, ask libhb
+        gtk_list_store_set(store, &iter, 1, irate == 0.0 ? TRUE :
+                hb_audio_samplerate_is_supported(irate, acodec), -1);
+    } while (gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter));
+}
+
+
 const hb_rate_t sas_rate =
 {
     .name = N_("Same as source"),
index 4c321e823d0359642e403655abc76426e136a015..050b6e1181f63cfe83bb6d9ab80eecf8ce3fb470 100644 (file)
@@ -172,6 +172,7 @@ void ghb_audio_bitrate_opts_filter(GtkComboBox *combo, gint first_rate, gint las
 void ghb_mix_opts_set(GtkComboBox *combo);
 void ghb_mix_opts_filter(GtkComboBox *combo, gint acodec);
 void ghb_audio_samplerate_opts_set(GtkComboBox *combo);
+void ghb_audio_samplerate_opts_filter(GtkComboBox *combo, gint acodec);
 
 int ghb_lookup_lang(const GhbValue *glang);
 const iso639_lang_t* ghb_iso639_lookup_by_int(int idx);