#include "preview.h"
#include "audiohandler.h"
+static void ghb_add_audio(signal_user_data_t *ud, GValue *settings);
+
void
ghb_adjust_audio_rate_combos(signal_user_data_t *ud)
{
ghb_ui_update(ud, "AudioBitrate", ghb_int64_value(384));
ghb_ui_update(ud, "AudioSamplerate", ghb_int64_value(0));
ghb_ui_update(ud, "AudioMixdown", ghb_int64_value(0));
+ acodec = HB_ACODEC_AC3;
}
ghb_ui_update(ud, "AudioTrackDRCSlider", ghb_double_value(0));
}
acodec = 0;
if (acodec != 0)
{
- // Add to audio list
- g_signal_emit_by_name(button, "clicked", ud);
- list_count++;
- ghb_ui_update(ud, "AudioTrack", ghb_int64_value(track));
- ghb_ui_update(ud, "AudioEncoder", ghb_int64_value(acodec));
- if (!ghb_audio_is_passthru (acodec))
- {
- // This gets set autimatically if the codec is passthru
- ghb_ui_update(ud, "AudioBitrate", ghb_int64_value(bitrate));
- ghb_ui_update(ud, "AudioSamplerate", ghb_double_value(rate));
- mix = ghb_get_best_mix( titleindex, track, acodec, mix);
- ghb_ui_update(ud, "AudioMixdown", ghb_int64_value(mix));
- }
+ GValue *settings = ghb_dict_value_new();
+ ghb_settings_set_int(settings, "AudioTrack", track);
+ ghb_settings_set_int(settings, "AudioEncoder", acodec);
+ ghb_settings_set_value(settings, "AudioEncoderActual",
+ ghb_settings_get_value(ud->settings, "AudioEncoderActual"));
+ // This gets set autimatically if the codec is passthru
+ ghb_settings_set_int(settings, "AudioBitrate", bitrate);
+ ghb_settings_set_double(settings, "AudioSamplerate", rate);
+ mix = ghb_get_best_mix( titleindex, track, acodec, mix);
+ ghb_settings_set_int(settings, "AudioMixdown", mix);
+ ghb_settings_set_value(settings, "AudioTrackDRCSlider", drc);
+ ghb_add_audio(ud, settings);
ghb_adjust_audio_rate_combos(ud);
- ghb_ui_update(ud, "AudioTrackDRCSlider", drc);
}
}
g_free(source_lang);
if (gtk_tree_selection_get_selected(selection, &store, &iter))
{
const gchar *track, *codec, *br, *sr, *mix;
- gchar *actual_codec, *s_drc, *s_track, *s_codec, *s_br, *s_sr, *s_mix;
+ gchar *s_drc;
gint itrack, icodec;
gdouble drc;
// Get the row number
sr = ghb_settings_combo_option(asettings, "AudioSamplerate");
mix = ghb_settings_combo_option(asettings, "AudioMixdown");
- s_track = ghb_settings_get_string(asettings, "AudioTrack");
- s_codec = ghb_settings_get_string(asettings, "AudioEncoder");
- actual_codec = ghb_settings_get_string(asettings, "AudioEncoderActual");
- s_br = ghb_settings_get_string(asettings, "AudioBitrate");
- s_sr = ghb_settings_get_string(asettings, "AudioSamplerate");
- s_mix = ghb_settings_get_string(asettings, "AudioMixdown");
drc = ghb_settings_get_double(asettings, "AudioTrackDRCSlider");
if (drc < 1.0)
s_drc = g_strdup("Off");
3, sr,
4, mix,
5, s_drc,
- // These are used to set combo values when a list item is selected
- 6, s_track,
- 7, s_codec,
- 8, s_br,
- 9, s_sr,
- 10, s_mix,
- 11, drc,
- 12, actual_codec,
-1);
g_free(s_drc);
- g_free(s_track);
- g_free(s_codec);
- g_free(actual_codec);
- g_free(s_br);
- g_free(s_sr);
- g_free(s_mix);
}
}
if (asettings != NULL)
{
ghb_widget_to_setting(asettings, widget);
+ ghb_settings_set_value(asettings, "AudioEncoderActual", ghb_settings_get_value(ud->settings, "AudioEncoderActual"));
ghb_audio_list_refresh_selected(ud);
}
ghb_update_destination_extension(ud);
ghb_live_reset(ud);
}
-// subtitles differ from other settings in that
-// the selection is updated automaitcally when the title
-// changes. I don't want the preset selection changed as
-// would happen for regular settings.
-G_MODULE_EXPORT void
-subtitle_changed_cb(GtkWidget *widget, signal_user_data_t *ud)
-{
- const gchar *name = ghb_get_setting_key(widget);
- g_debug("subtitle_changed_cb () %s", name);
- ghb_widget_to_setting(ud->settings, widget);
- ghb_check_dependency(ud, widget, NULL);
- ghb_live_reset(ud);
-}
-
void
ghb_clear_audio_list(signal_user_data_t *ud)
{
GtkListStore *store;
GtkTreeSelection *selection;
const gchar *track, *codec, *br, *sr, *mix;
- gchar *s_drc, *s_track, *s_codec, *s_br, *s_sr, *s_mix, *actual_codec;
+ gchar *s_drc;
gint icodec, itrack;
gdouble drc;
sr = ghb_settings_combo_option(settings, "AudioSamplerate");
mix = ghb_settings_combo_option(settings, "AudioMixdown");
- s_track = ghb_settings_get_string(settings, "AudioTrack");
- s_codec = ghb_settings_get_string(settings, "AudioEncoder");
- actual_codec = ghb_settings_get_string(settings, "AudioEncoderActual");
- s_br = ghb_settings_get_string(settings, "AudioBitrate");
- s_sr = ghb_settings_get_string(settings, "AudioSamplerate");
- s_mix = ghb_settings_get_string(settings, "AudioMixdown");
drc = ghb_settings_get_double(settings, "AudioTrackDRCSlider");
if (drc < 1.0)
s_drc = g_strdup("Off");
3, sr,
4, mix,
5, s_drc,
- // These are used to set combo box values when a list item is selected
- 6, s_track,
- 7, s_codec,
- 8, s_br,
- 9, s_sr,
- 10, s_mix,
- 11, drc,
- 12, actual_codec,
-1);
gtk_tree_selection_select_iter(selection, &iter);
g_free(s_drc);
- g_free(s_track);
- g_free(s_codec);
- g_free(actual_codec);
- g_free(s_br);
- g_free(s_sr);
- g_free(s_mix);
}
G_MODULE_EXPORT void
GtkTreeIter iter;
GtkWidget *widget;
+ GtkTreePath *treepath;
+ gint *indices;
+ gint row;
+ GValue *asettings = NULL;
+
+ const GValue *audio_list;
g_debug("audio_list_selection_changed_cb ()");
if (gtk_tree_selection_get_selected(selection, &store, &iter))
{
- const gchar *actual_codec, *track, *codec, *bitrate, *sample_rate, *mix;
- gdouble drc;
+ //const gchar *actual_codec, *track, *codec, *bitrate, *sample_rate, *mix;
+ //gdouble drc;
+
+ // Get the row number
+ treepath = gtk_tree_model_get_path (store, &iter);
+ indices = gtk_tree_path_get_indices (treepath);
+ row = indices[0];
+ gtk_tree_path_free(treepath);
+ // find audio settings
+ if (row < 0) return;
+ audio_list = ghb_settings_get_value(ud->settings, "audio_list");
+ if (row >= ghb_array_len(audio_list))
+ return;
+ asettings = ghb_array_get_nth(audio_list, row);
- gtk_tree_model_get(store, &iter,
- 6, &track,
- 7, &codec,
- 8, &bitrate,
- 9, &sample_rate,
- 10, &mix,
- 11, &drc,
- 12, &actual_codec,
- -1);
- ghb_ui_update(ud, "AudioTrack", ghb_string_value(track));
- ghb_ui_update(ud, "AudioEncoder", ghb_string_value(codec));
- ghb_settings_set_string(ud->settings, "AudioEncoderActual", actual_codec);
+ ghb_ui_update(ud, "AudioTrack", ghb_settings_get_value(asettings, "AudioTrack"));
+ ghb_ui_update(ud, "AudioEncoder", ghb_settings_get_value(asettings, "AudioEncoder"));
+ ghb_settings_set_value(ud->settings, "AudioEncoderActual", ghb_settings_get_value(asettings, "AudioEncoderActual"));
ghb_check_dependency(ud, NULL, "AudioEncoderActual");
- ghb_ui_update(ud, "AudioBitrate", ghb_string_value(bitrate));
- ghb_ui_update(ud, "AudioSamplerate", ghb_string_value(sample_rate));
- ghb_ui_update(ud, "AudioMixdown", ghb_string_value(mix));
- ghb_ui_update(ud, "AudioTrackDRCSlider", ghb_double_value(drc));
+ ghb_ui_update(ud, "AudioBitrate", ghb_settings_get_value(asettings, "AudioBitrate"));
+ ghb_ui_update(ud, "AudioSamplerate", ghb_settings_get_value(asettings, "AudioSamplerate"));
+ ghb_ui_update(ud, "AudioMixdown", ghb_settings_get_value(asettings, "AudioMixdown"));
+ ghb_ui_update(ud, "AudioTrackDRCSlider", ghb_settings_get_value(asettings, "AudioTrackDRCSlider"));
widget = GHB_WIDGET (ud->builder, "audio_remove");
gtk_widget_set_sensitive(widget, TRUE);
}
}
}
+static void
+ghb_add_audio(signal_user_data_t *ud, GValue *settings)
+{
+ GValue *audio_list;
+ int count;
+ const gchar * track;
+
+ track = ghb_settings_combo_option(settings, "AudioTrack");
+ ghb_settings_set_string(settings, "AudioTrackDescription", track);
+
+ audio_list = ghb_settings_get_value(ud->settings, "audio_list");
+ if (audio_list == NULL)
+ {
+ audio_list = ghb_array_value_new(8);
+ ghb_settings_set_value(ud->settings, "audio_list", audio_list);
+ }
+ ghb_array_append(audio_list, settings);
+ add_to_audio_list(ud, settings);
+ count = ghb_array_len(audio_list);
+ if (count >= 99)
+ {
+ GtkWidget * widget = GHB_WIDGET(ud->builder, "audio_add");
+ gtk_widget_set_sensitive(widget, FALSE);
+ }
+ ghb_update_destination_extension(ud);
+}
+
G_MODULE_EXPORT void
audio_add_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
{
// Add the current audio settings to the list.
GValue *asettings;
GtkWidget *widget;
- gint count;
- GValue *audio_list;
- const gchar *track;
g_debug("audio_add_clicked_cb ()");
asettings = ghb_dict_value_new();
ghb_settings_take_value(asettings, "AudioMixdown", ghb_widget_value(widget));
widget = GHB_WIDGET(ud->builder, "AudioTrackDRCSlider");
ghb_settings_take_value(asettings, "AudioTrackDRCSlider", ghb_widget_value(widget));
- track = ghb_settings_combo_option(asettings, "AudioTrack");
- ghb_settings_set_string(asettings, "AudioTrackDescription", track);
- audio_list = ghb_settings_get_value(ud->settings, "audio_list");
- if (audio_list == NULL)
- {
- audio_list = ghb_array_value_new(8);
- ghb_settings_set_value(ud->settings, "audio_list", audio_list);
- }
- ghb_array_append(audio_list, asettings);
- add_to_audio_list(ud, asettings);
- count = ghb_array_len(audio_list);
- if (count >= 99)
- {
- gtk_widget_set_sensitive(xwidget, FALSE);
- }
- ghb_update_destination_extension(ud);
+ ghb_add_audio(ud, asettings);
}
G_MODULE_EXPORT void
if (acodec_code != 0)
{
- // Add to audio list
- g_signal_emit_by_name(button, "clicked", ud);
- ghb_ui_update(ud, "AudioTrack", track);
- ghb_ui_update(ud, "AudioEncoder", acodec);
- if (!ghb_audio_is_passthru (acodec_code))
- {
- // This gets set autimatically if the codec is passthru
- ghb_ui_update(ud, "AudioBitrate", bitrate);
- ghb_ui_update(ud, "AudioSamplerate", rate);
- ghb_ui_update(ud, "AudioMixdown", mix);
- }
- ghb_ui_update(ud, "AudioTrackDRCSlider", drc);
+ GValue *settings = ghb_dict_value_new();
+ ghb_settings_set_value(settings, "AudioTrack", track);
+ ghb_settings_set_value(settings, "AudioEncoder", acodec);
+ ghb_settings_set_value(settings, "AudioEncoderActual",
+ ghb_settings_get_value(ud->settings, "AudioEncoderActual"));
+ // This gets set autimatically if the codec is passthru
+ ghb_settings_set_value(settings, "AudioBitrate", bitrate);
+ ghb_settings_set_value(settings, "AudioSamplerate", rate);
+ ghb_settings_set_value(settings, "AudioMixdown", mix);
+ ghb_settings_set_value(settings, "AudioTrackDRCSlider", drc);
+ ghb_add_audio(ud, settings);
ghb_adjust_audio_rate_combos(ud);
}
}
}
}
+gint
+find_combo_entry(combo_opts_t *opts, const GValue *gval)
+{
+ gint ii;
+
+ if (G_VALUE_TYPE(gval) == G_TYPE_STRING)
+ {
+ gchar *str;
+ str = ghb_value_string(gval);
+ for (ii = 0; ii < opts->count; ii++)
+ {
+ if (strcmp(opts->map[ii].shortOpt, str) == 0)
+ {
+ break;
+ }
+ }
+ g_free(str);
+ return ii;
+ }
+ else if (G_VALUE_TYPE(gval) == G_TYPE_DOUBLE)
+ {
+ gdouble val;
+ val = ghb_value_double(gval);
+ for (ii = 0; ii < opts->count; ii++)
+ {
+ if (opts->map[ii].ivalue == val)
+ {
+ break;
+ }
+ }
+ return ii;
+ }
+ else if (G_VALUE_TYPE(gval) == G_TYPE_INT ||
+ G_VALUE_TYPE(gval) == G_TYPE_BOOLEAN ||
+ G_VALUE_TYPE(gval) == G_TYPE_INT64)
+ {
+ gint64 val;
+ val = ghb_value_int64(gval);
+ for (ii = 0; ii < opts->count; ii++)
+ {
+ if ((gint64)opts->map[ii].ivalue == val)
+ {
+ break;
+ }
+ }
+ return ii;
+ }
+ return opts->count;
+}
+
static const gchar*
lookup_generic_string(combo_opts_t *opts, const GValue *gval)
{
gint ii;
- gchar *str;
const gchar *result = "";
- str = ghb_value_string(gval);
- for (ii = 0; ii < opts->count; ii++)
+ ii = find_combo_entry(opts, gval);
+ if (ii < opts->count)
{
- if (strcmp(opts->map[ii].shortOpt, str) == 0)
- {
- result = opts->map[ii].svalue;
- break;
- }
+ result = opts->map[ii].svalue;
}
- g_free(str);
return result;
}
lookup_generic_int(combo_opts_t *opts, const GValue *gval)
{
gint ii;
- gchar *str;
gint result = -1;
- str = ghb_value_string(gval);
- for (ii = 0; ii < opts->count; ii++)
+ ii = find_combo_entry(opts, gval);
+ if (ii < opts->count)
{
- if (strcmp(opts->map[ii].shortOpt, str) == 0)
- {
- result = opts->map[ii].ivalue;
- break;
- }
+ result = opts->map[ii].ivalue;
}
- g_free(str);
return result;
}
lookup_generic_double(combo_opts_t *opts, const GValue *gval)
{
gint ii;
- gchar *str;
gdouble result = -1;
- str = ghb_value_string(gval);
- for (ii = 0; ii < opts->count; ii++)
+ ii = find_combo_entry(opts, gval);
+ if (ii < opts->count)
{
- if (strcmp(opts->map[ii].shortOpt, str) == 0)
- {
- result = opts->map[ii].ivalue;
- break;
- }
+ result = opts->map[ii].ivalue;
}
- g_free(str);
return result;
}
lookup_generic_option(combo_opts_t *opts, const GValue *gval)
{
gint ii;
- gchar *str;
const gchar *result = "";
- str = ghb_value_string(gval);
- for (ii = 0; ii < opts->count; ii++)
+ ii = find_combo_entry(opts, gval);
+ if (ii < opts->count)
{
- if (strcmp(opts->map[ii].shortOpt, str) == 0)
- {
- result = opts->map[ii].option;
- break;
- }
+ result = opts->map[ii].option;
}
- g_free(str);
return result;
}
gint try_acodec;
gint passthru_acodec;
gboolean passthru;
+ gint channels;
g_debug("find_audio_track ()\n");
if (h_scan == NULL) return -1;
{
for (ii = 0; ii < count; ii++)
{
- gint channels;
-
audio = (hb_audio_config_t*)hb_list_audio_config_item(
title->list_audio, ii );
passthru_acodec = (HB_ACODEC_AC3 | HB_ACODEC_DCA) & audio->in.codec;
return track;
}
// Try to find an item that matches the preferred language
+ max_chan = 0;
used = get_track_used(try_acodec, track_indices, count);
for (ii = 0; ii < count; ii++)
{
if (passthru_used[ii])
continue;
}
+ channels = HB_INPUT_CH_LAYOUT_GET_DISCRETE_COUNT(
+ audio->in.channel_layout);
// Find a track that is not visually impaired or dirctor's commentary
if ((audio->lang.type < 2) &&
((strcmp(lang, audio->lang.iso639_2) == 0) ||
(strcmp(lang, "und") == 0)))
{
- track = ii;
- break;
+ if (channels > max_chan)
+ {
+ track = ii;
+ max_chan = channels;
+ }
}
}
if (track > -1)
}
// Try to fine an item that does not match the preferred language and
// matches the passthru codec type
+ max_chan = 0;
if (passthru)
{
for (ii = 0; ii < count; ii++)
return track;
}
// Try to fine an item that does not match the preferred language
+ max_chan = 0;
used = get_track_used(try_acodec, track_indices, count);
for (ii = 0; ii < count; ii++)
{
// Find a track that is not visually impaired or dirctor's commentary
if (audio->lang.type < 2)
{
- track = ii;
- break;
+ if (channels > max_chan)
+ {
+ track = ii;
+ max_chan = channels;
+ }
}
}
if (track > -1)