summaryrefslogtreecommitdiffstats
path: root/gtk/src
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2010-10-14 01:20:32 +0000
committerjstebbins <[email protected]>2010-10-14 01:20:32 +0000
commite27b59a0c54bf20632ea0dd971f033718334db44 (patch)
treeea4e72f62a4c71585da7b9cc5b0669c2d8a9d9ac /gtk/src
parent40ce642aaeeebf87ad5af699f993716a026fd48d (diff)
LinGui: fix infinite recursion issue in audio bitrate handling
adding a bitrate (that isn't in the standard set of bitrates supported by handbrake) to the bitrate combo for a passthru codec caused a cascade of errors. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3601 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'gtk/src')
-rw-r--r--gtk/src/audiohandler.c14
-rw-r--r--gtk/src/hb-backend.c62
2 files changed, 51 insertions, 25 deletions
diff --git a/gtk/src/audiohandler.c b/gtk/src/audiohandler.c
index 7aede1ce9..4a87a2763 100644
--- a/gtk/src/audiohandler.c
+++ b/gtk/src/audiohandler.c
@@ -76,9 +76,9 @@ ghb_adjust_audio_rate_combos(signal_user_data_t *ud)
{
sr = aconfig ? aconfig->in.samplerate : 48000;
}
+ gboolean codec_defined_bitrate = FALSE;
if (ghb_audio_is_passthru (select_acodec))
{
- ghb_set_default_bitrate_opts (ud->builder, 0, -1);
if (aconfig)
{
bitrate = aconfig->in.bitrate / 1000;
@@ -89,6 +89,7 @@ ghb_adjust_audio_rate_combos(signal_user_data_t *ud)
ghb_set_passthru_bitrate_opts (ud->builder, bitrate);
ghb_ui_update(ud, "AudioMixdown", ghb_int64_value(0));
select_acodec &= aconfig->in.codec | HB_ACODEC_PASS_FLAG;
+ codec_defined_bitrate = TRUE;
}
else
{
@@ -117,12 +118,14 @@ ghb_adjust_audio_rate_combos(signal_user_data_t *ud)
{
bitrate = hb_get_best_audio_bitrate(select_acodec, bitrate, sr, mix);
}
+ if (!codec_defined_bitrate)
+ {
+ int low, high;
+ hb_get_audio_bitrate_limits(select_acodec, sr, mix, &low, &high);
+ ghb_set_default_bitrate_opts (ud->builder, low, high);
+ }
ghb_ui_update(ud, "AudioBitrate", ghb_int64_value(bitrate));
- int low, high;
- hb_get_audio_bitrate_limits(select_acodec, sr, mix, &low, &high);
- ghb_set_default_bitrate_opts (ud->builder, low, high);
-
ghb_settings_take_value(ud->settings, "AudioEncoderActual",
ghb_lookup_acodec_value(select_acodec));
ghb_check_dependency(ud, NULL, "AudioEncoderActual");
@@ -496,6 +499,7 @@ audio_widget_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
GValue *asettings;
g_debug("audio_widget_changed_cb ()");
+
ghb_adjust_audio_rate_combos(ud);
ghb_check_dependency(ud, widget, NULL);
asettings = get_selected_asettings(ud);
diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c
index eb6e233f6..de6d503b0 100644
--- a/gtk/src/hb-backend.c
+++ b/gtk/src/hb-backend.c
@@ -1115,6 +1115,9 @@ ghb_find_closest_audio_rate(gint rate)
return result;
}
+hb_rate_t *ghb_audio_bitrates;
+int ghb_audio_bitrates_count;
+
static gint
lookup_audio_bitrate_int(const GValue *rate)
{
@@ -1126,11 +1129,11 @@ lookup_audio_bitrate_int(const GValue *rate)
// Coincidentally, the string "source" will return 0
// which is our flag to use "same as source"
gchar *str = ghb_value_string(rate);
- for (ii = 0; ii < hb_audio_bitrates_count; ii++)
+ for (ii = 0; ii < ghb_audio_bitrates_count; ii++)
{
- if (strcmp(hb_audio_bitrates[ii].string, str) == 0)
+ if (strcmp(ghb_audio_bitrates[ii].string, str) == 0)
{
- result = hb_audio_bitrates[ii].rate;
+ result = ghb_audio_bitrates[ii].rate;
break;
}
}
@@ -1141,11 +1144,11 @@ lookup_audio_bitrate_int(const GValue *rate)
G_VALUE_TYPE(rate) == G_TYPE_DOUBLE)
{
gint val = ghb_value_int(rate);
- for (ii = 0; ii < hb_audio_bitrates_count; ii++)
+ for (ii = 0; ii < ghb_audio_bitrates_count; ii++)
{
- if (hb_audio_bitrates[ii].rate == val)
+ if (ghb_audio_bitrates[ii].rate == val)
{
- result = hb_audio_bitrates[ii].rate;
+ result = ghb_audio_bitrates[ii].rate;
break;
}
}
@@ -1164,11 +1167,11 @@ lookup_audio_bitrate_option(const GValue *rate)
// Coincidentally, the string "source" will return 0
// which is our flag to use "same as source"
gchar *str = ghb_value_string(rate);
- for (ii = 0; ii < hb_audio_bitrates_count; ii++)
+ for (ii = 0; ii < ghb_audio_bitrates_count; ii++)
{
- if (strcmp(hb_audio_bitrates[ii].string, str) == 0)
+ if (strcmp(ghb_audio_bitrates[ii].string, str) == 0)
{
- result = hb_audio_bitrates[ii].string;
+ result = ghb_audio_bitrates[ii].string;
break;
}
}
@@ -1179,11 +1182,11 @@ lookup_audio_bitrate_option(const GValue *rate)
G_VALUE_TYPE(rate) == G_TYPE_DOUBLE)
{
gint val = ghb_value_int(rate);
- for (ii = 0; ii < hb_audio_bitrates_count; ii++)
+ for (ii = 0; ii < ghb_audio_bitrates_count; ii++)
{
- if (hb_audio_bitrates[ii].rate == val)
+ if (ghb_audio_bitrates[ii].rate == val)
{
- result = hb_audio_bitrates[ii].string;
+ result = ghb_audio_bitrates[ii].string;
break;
}
}
@@ -3027,6 +3030,15 @@ audio_bitrate_opts_add(GtkBuilder *builder, const gchar *name, gint rate)
if (rate < 8) return;
+ if (ghb_audio_bitrates[hb_audio_bitrates_count].string)
+ {
+ g_free(ghb_audio_bitrates[hb_audio_bitrates_count].string);
+ }
+ ghb_audio_bitrates[hb_audio_bitrates_count].rate = rate;
+ ghb_audio_bitrates[hb_audio_bitrates_count].string =
+ g_strdup_printf("%d", rate);
+ ghb_audio_bitrates_count = hb_audio_bitrates_count + 1;
+
store = get_combo_box_store(builder, name);
if (!find_combo_item_by_int(GTK_TREE_MODEL(store), rate, &iter))
{
@@ -3035,9 +3047,9 @@ audio_bitrate_opts_add(GtkBuilder *builder, const gchar *name, gint rate)
gtk_list_store_set(store, &iter,
0, str,
1, TRUE,
- 2, str,
+ 2, ghb_audio_bitrates[hb_audio_bitrates_count].string,
3, (gdouble)rate,
- 4, str,
+ 4, ghb_audio_bitrates[hb_audio_bitrates_count].string,
-1);
g_free(str);
}
@@ -3058,6 +3070,8 @@ audio_bitrate_opts_clean(
guint last = (guint)last_rate;
guint first = (guint)first_rate;
+ ghb_audio_bitrates_count = hb_audio_bitrates_count;
+
g_debug("audio_bitrate_opts_clean ()\n");
store = get_combo_box_store(builder, name);
if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL(store), &iter))
@@ -3066,7 +3080,7 @@ audio_bitrate_opts_clean(
{
gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, 3, &ivalue, -1);
if (search_rates(
- hb_audio_bitrates, ivalue, hb_audio_bitrates_count) < 0)
+ ghb_audio_bitrates, ivalue, ghb_audio_bitrates_count) < 0)
{
done = !gtk_list_store_remove(store, &iter);
}
@@ -3094,20 +3108,28 @@ audio_bitrate_opts_set(GtkBuilder *builder, const gchar *name)
gint ii;
gchar *str;
+ ghb_audio_bitrates_count = hb_audio_bitrates_count;
+ ghb_audio_bitrates = calloc(hb_audio_bitrates_count+1, sizeof(hb_rate_t));
+
+ for (ii = 0; ii < hb_audio_bitrates_count; ii++)
+ {
+ ghb_audio_bitrates[ii] = hb_audio_bitrates[ii];
+ }
+
g_debug("audio_bitrate_opts_set ()\n");
store = get_combo_box_store(builder, name);
gtk_list_store_clear(store);
- for (ii = 0; ii < hb_audio_bitrates_count; ii++)
+ for (ii = 0; ii < ghb_audio_bitrates_count; ii++)
{
gtk_list_store_append(store, &iter);
str = g_strdup_printf ("<small>%s</small>",
- hb_audio_bitrates[ii].string);
+ ghb_audio_bitrates[ii].string);
gtk_list_store_set(store, &iter,
0, str,
1, TRUE,
- 2, hb_audio_bitrates[ii].string,
- 3, (gdouble)hb_audio_bitrates[ii].rate,
- 4, hb_audio_bitrates[ii].string,
+ 2, ghb_audio_bitrates[ii].string,
+ 3, (gdouble)ghb_audio_bitrates[ii].rate,
+ 4, ghb_audio_bitrates[ii].string,
-1);
g_free(str);
}