[gnac/devel] Code cleanup
- From: BenoÃt Dupasquier <bdupasqu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnac/devel] Code cleanup
- Date: Fri, 4 Nov 2011 16:23:37 +0000 (UTC)
commit 41da3aa0cbe748bb296e40488a0fc0c7c1b587c1
Author: BenoÃt Dupasquier <bdupasqu src gnome org>
Date: Fri Nov 4 13:15:30 2011 +0000
Code cleanup
src/gnac-utils.c | 2 +-
src/profiles/formats/gnac-profiles-aac.c | 23 +++--
src/profiles/formats/gnac-profiles-flac.c | 23 +++--
src/profiles/formats/gnac-profiles-lame.c | 109 +++++++++++------------
src/profiles/formats/gnac-profiles-speex.c | 122 ++++++++++++++------------
src/profiles/formats/gnac-profiles-unknown.c | 32 ++++---
src/profiles/formats/gnac-profiles-vorbis.c | 48 ++++------
src/profiles/formats/gnac-profiles-wav.c | 9 +-
src/profiles/formats/gnac-profiles-wavpack.c | 64 ++++++--------
9 files changed, 217 insertions(+), 215 deletions(-)
---
diff --git a/src/gnac-utils.c b/src/gnac-utils.c
index b5a41eb..13f16ef 100644
--- a/src/gnac-utils.c
+++ b/src/gnac-utils.c
@@ -323,7 +323,7 @@ gnac_utils_create_gtk_builder(const gchar *filename)
gboolean
gnac_utils_string_is_null_or_empty(const gchar *string)
{
- return !string || g_str_equal(string, "");
+ return !string || gnac_utils_str_equal(string, "");
}
diff --git a/src/profiles/formats/gnac-profiles-aac.c b/src/profiles/formats/gnac-profiles-aac.c
index ea8b2be..a397dd8 100755
--- a/src/profiles/formats/gnac-profiles-aac.c
+++ b/src/profiles/formats/gnac-profiles-aac.c
@@ -60,7 +60,7 @@ static const gchar *
gnac_profiles_aac_init(UpdateTextBufferFunc call_back);
static void
-gnac_profiles_aac_generate_pipeline(GtkWidget *w);
+gnac_profiles_aac_generate_pipeline(GtkWidget *widget);
static AudioProfileAAC *
gnac_profiles_aac_generate_audio_profile(GError **error);
@@ -112,6 +112,7 @@ gnac_profiles_aac_get_funcs(void)
gnac_profiles_aac_get_combo_format_name,
gnac_profiles_aac_get_plugin_name
};
+
return funcs;
}
@@ -152,7 +153,6 @@ gnac_profiles_aac_init(UpdateTextBufferFunc call_back)
G_CALLBACK(gnac_profiles_aac_generate_pipeline),
"combo-outputformat", "//variable[ id='outputformat']/*");
- /* Cleanup */
gnac_profiles_xml_engine_free_doc_xpath(aac_bfi.doc);
aac_bfi.doc = NULL;
@@ -161,15 +161,13 @@ gnac_profiles_aac_init(UpdateTextBufferFunc call_back)
static void
-gnac_profiles_aac_generate_pipeline(GtkWidget *w)
+gnac_profiles_aac_generate_pipeline(GtkWidget *widget G_GNUC_UNUSED)
{
gchar *pipeline;
pipeline = gnac_profiles_default_generate_pipeline(&aac_bfi);
-
pipeline = gnac_profiles_utils_add_properties_combo(pipeline, &aac_bfi,
"combo-bitrate", "combo-outputformat", "combo-profile", NULL);
-
pipeline = gnac_profiles_utils_add_properties_check(pipeline, &aac_bfi,
"checkbutton-tns", NULL);
@@ -184,7 +182,7 @@ gnac_profiles_aac_generate_pipeline(GtkWidget *w)
static void
gnac_profiles_aac_fullfill_fields(AudioProfileAAC *profile)
{
- if (profile == NULL) {
+ if (!profile) {
gnac_profiles_default_fullfill_fields(NULL, &aac_bfi);
gnac_profiles_utils_reinit_values_combo(&aac_bfi,
"combo-bitrate", "combo-outputformat", "combo-profile", NULL);
@@ -228,11 +226,13 @@ gnac_profiles_aac_free_audio_profile(AudioProfileAAC *profile)
static AudioProfileAAC *
gnac_profiles_aac_generate_audio_profile(GError **error)
{
- AudioProfileAAC *profile;
+ AudioProfileAAC *profile;
AudioProfileGeneric *generic;
generic = gnac_profiles_default_generate_audio_profile(&aac_bfi);
profile = g_malloc(sizeof(AudioProfileAAC));
+ if (!profile) return NULL;
+
profile->generic = generic;
gnac_profiles_utils_get_values_combo_and_set(&aac_bfi,
@@ -252,9 +252,10 @@ gnac_profiles_aac_generate_audio_profile(GError **error)
static GtkWidget *
gnac_profiles_aac_get_widget(AudioProfileAAC *profile)
{
- if (profile != NULL) {
+ if (profile) {
gnac_profiles_aac_fullfill_fields(profile);
}
+
return gnac_profiles_default_get_properties_alignment(&aac_bfi);
}
@@ -271,19 +272,21 @@ gnac_profiles_aac_save_profile(AudioProfileAAC *profile)
"profile", profile->profile,
"tns", profile->tns,
NULL);
-
gnac_profiles_xml_engine_save_doc(doc, profile->generic->name);
+
gnac_profiles_xml_engine_free_doc_xpath(doc);
}
-static AudioProfileAAC*
+static AudioProfileAAC *
gnac_profiles_aac_load_specific_properties(XMLDoc *doc,
AudioProfileGeneric *generic)
{
AudioProfileAAC *profile;
profile = g_malloc(sizeof(AudioProfileAAC));
+ if (!profile) return NULL;
+
profile->generic = generic;
gnac_profiles_utils_load_saved_profile(doc,
"/audio-profile/format-specific/",
diff --git a/src/profiles/formats/gnac-profiles-flac.c b/src/profiles/formats/gnac-profiles-flac.c
index f3ec8a5..def99b9 100755
--- a/src/profiles/formats/gnac-profiles-flac.c
+++ b/src/profiles/formats/gnac-profiles-flac.c
@@ -57,7 +57,7 @@ static const gchar *
gnac_profiles_flac_init(UpdateTextBufferFunc call_back);
static void
-gnac_profiles_flac_generate_pipeline(GtkWidget *w);
+gnac_profiles_flac_generate_pipeline(GtkWidget *widget);
static AudioProfileFlac *
gnac_profiles_flac_generate_audio_profile(GError **error);
@@ -109,6 +109,7 @@ gnac_profiles_flac_get_funcs(void)
gnac_profiles_flac_get_combo_format_name,
gnac_profiles_flac_get_plugin_name
};
+
return funcs;
}
@@ -125,7 +126,6 @@ gnac_profiles_flac_init(UpdateTextBufferFunc call_back)
G_CALLBACK(gnac_profiles_flac_generate_pipeline),
"slider-compression", "//variable[ id='compression']/*");
- /* Cleanup */
gnac_profiles_xml_engine_free_doc_xpath(flac_bfi.doc);
flac_bfi.doc = NULL;
@@ -134,15 +134,13 @@ gnac_profiles_flac_init(UpdateTextBufferFunc call_back)
static void
-gnac_profiles_flac_generate_pipeline(GtkWidget *w)
+gnac_profiles_flac_generate_pipeline(GtkWidget *widget G_GNUC_UNUSED)
{
gchar *pipeline;
pipeline = gnac_profiles_default_generate_pipeline(&flac_bfi);
-
pipeline = gnac_profiles_utils_add_properties_slider(pipeline, &flac_bfi,
"slider-compression", NULL);
-
update_text_buffer_call_back(pipeline);
g_free(flac_bfi.pipeline);
@@ -154,7 +152,7 @@ gnac_profiles_flac_generate_pipeline(GtkWidget *w)
static void
gnac_profiles_flac_fullfill_fields(AudioProfileFlac *profile)
{
- if (profile == NULL) {
+ if (!profile) {
gnac_profiles_default_fullfill_fields(NULL, &flac_bfi);
gnac_profiles_utils_reinit_values_slider(&flac_bfi,
"slider-compression", NULL);
@@ -185,11 +183,13 @@ gnac_profiles_flac_free_audio_profile(AudioProfileFlac *profile)
static AudioProfileFlac *
gnac_profiles_flac_generate_audio_profile(GError **error)
{
- AudioProfileFlac *profile;
+ AudioProfileFlac *profile;
AudioProfileGeneric *generic;
generic = gnac_profiles_default_generate_audio_profile(&flac_bfi);
profile = g_malloc(sizeof(AudioProfileFlac));
+ if (!profile) return NULL;
+
profile->generic = generic;
gnac_profiles_utils_get_values_slider_and_set(&flac_bfi,
@@ -202,9 +202,10 @@ gnac_profiles_flac_generate_audio_profile(GError **error)
static GtkWidget *
gnac_profiles_flac_get_widget(AudioProfileFlac *profile)
{
- if (profile != NULL) {
+ if (profile) {
gnac_profiles_flac_fullfill_fields(profile);
}
+
return gnac_profiles_default_get_properties_alignment(&flac_bfi);
}
@@ -231,15 +232,17 @@ gnac_profiles_flac_load_specific_properties(XMLDoc *doc,
AudioProfileGeneric *generic)
{
AudioProfileFlac *profile;
- gchar *quality_str;
+ gchar *quality_str;
profile = g_malloc(sizeof(AudioProfileFlac));
+ if (!profile) return NULL;
+
profile->generic = generic;
gnac_profiles_utils_load_saved_profile(doc,
"/audio-profile/format-specific/",
"quality", &quality_str, NULL);
- if (quality_str != NULL) {
+ if (quality_str) {
profile->quality = gnac_profiles_utils_gchararray_to_gdouble(quality_str);
g_free(quality_str);
}
diff --git a/src/profiles/formats/gnac-profiles-lame.c b/src/profiles/formats/gnac-profiles-lame.c
index 415813f..d59f280 100755
--- a/src/profiles/formats/gnac-profiles-lame.c
+++ b/src/profiles/formats/gnac-profiles-lame.c
@@ -74,7 +74,7 @@ static const gchar *
gnac_profiles_lame_init(UpdateTextBufferFunc call_back);
static void
-gnac_profiles_lame_generate_pipeline(GtkWidget *w);
+gnac_profiles_lame_generate_pipeline(GtkWidget *widget);
static AudioProfileLame *
gnac_profiles_lame_generate_audio_profile(GError **error);
@@ -136,6 +136,7 @@ gnac_profiles_lame_get_funcs(void)
gnac_profiles_lame_get_combo_format_name,
gnac_profiles_lame_get_plugin_name
};
+
return funcs;
}
@@ -219,7 +220,6 @@ gnac_profiles_lame_init(UpdateTextBufferFunc call_back)
gnac_profiles_lame_vbr_on_changed(GTK_COMBO_BOX(widget));
- /* Cleanup */
gnac_profiles_xml_engine_free_doc_xpath(lame_bfi.doc);
lame_bfi.doc = NULL;
@@ -272,12 +272,11 @@ gnac_profiles_lame_vbr_on_changed(GtkComboBox *widget)
static void
gnac_profiles_lame_generate_pipeline(GtkWidget *w)
{
- GtkWidget *widget;
- gchar *pipeline;
- EncodingMode encoding_mode;
+ EncodingMode encoding_mode;
+ gchar *pipeline;
+ GtkWidget *widget;
pipeline = gnac_profiles_default_generate_pipeline(&lame_bfi);
-
widget = gnac_profiles_utils_get_widget(&lame_bfi, "combo-encoding-mode");
if (w == widget) {
@@ -302,8 +301,6 @@ gnac_profiles_lame_generate_pipeline(GtkWidget *w)
"combo-encoding-mode", NULL);
pipeline = gnac_profiles_utils_add_properties_slider(pipeline, &lame_bfi,
"slider-mean-abr", NULL);
-
- // min bitrate max bitrate
pipeline = gnac_profiles_utils_add_properties_checked_combo(pipeline,
&lame_bfi,
"combo-min-vbr", "checkbutton-min-bitrate",
@@ -316,12 +313,8 @@ gnac_profiles_lame_generate_pipeline(GtkWidget *w)
"combo-encoding-mode", NULL);
pipeline = gnac_profiles_utils_add_properties_slider(pipeline, &lame_bfi,
"slider-vbr-quality", NULL);
-
- // mean bitrate
pipeline = gnac_profiles_utils_add_properties_checked_slider(pipeline,
&lame_bfi, "slider-mean-vbr", "checkbutton-mean-bitrate", NULL);
-
- // min bitrate max bitrate
pipeline = gnac_profiles_utils_add_properties_checked_combo(pipeline,
&lame_bfi,
"combo-min-vbr", "checkbutton-min-bitrate",
@@ -365,7 +358,7 @@ gnac_profiles_lame_advanced_bitrate_on_toggle(GtkToggleButton *togglebutton,
static void
gnac_profiles_lame_fullfill_fields(AudioProfileLame *profile)
{
- if (profile == NULL) {
+ if (!profile) {
gnac_profiles_utils_reinit_values_combo(&lame_bfi,
"combo-mode",
"combo-bitrate",
@@ -391,27 +384,29 @@ gnac_profiles_lame_fullfill_fields(AudioProfileLame *profile)
"combo-mode", profile->mode,
NULL);
- if (profile->bitrate != NULL) {
+ if (profile->bitrate)
+ {
gnac_profiles_utils_set_values_combo(&lame_bfi,
"combo-bitrate", profile->bitrate, NULL);
- } else if (profile->preset != NULL) {
+ }
+ else if (profile->preset)
+ {
gnac_profiles_utils_set_values_combo(&lame_bfi,
"combo-preset", profile->preset, NULL);
- } else if (profile->mean_abr != -1) {
-
+ }
+ else if (profile->mean_abr != -1)
+ {
gnac_profiles_utils_set_values_slider(&lame_bfi,
"slider-mean-abr", profile->mean_abr, NULL);
-
gnac_profiles_utils_set_values_checked_combo(&lame_bfi,
"combo-min-vbr", "checkbutton-min-bitrate", profile->min_bitrate,
"combo-max-vbr", "checkbutton-max-bitrate", profile->max_bitrate,
NULL );
-
- } else if (profile->quality != -1) {
-
+ }
+ else if (profile->quality != -1)
+ {
gnac_profiles_utils_set_values_slider(&lame_bfi,
"slider-vbr-quality", profile->quality, NULL);
-
gnac_profiles_utils_set_values_checked_combo(&lame_bfi,
"combo-min-vbr", "checkbutton-min-bitrate", profile->min_bitrate,
"combo-max-vbr", "checkbutton-max-bitrate", profile->max_bitrate,
@@ -419,7 +414,9 @@ gnac_profiles_lame_fullfill_fields(AudioProfileLame *profile)
gnac_profiles_utils_set_values_checked_slider(&lame_bfi,
"slider-mean-vbr", "checkbutton-mean-bitrate", profile->mean_bitrate,
NULL);
- } else if (profile->compression_ratio != -1) {
+ }
+ else if (profile->compression_ratio != -1)
+ {
gnac_profiles_utils_set_values_slider(&lame_bfi,
"slider-compression-ratio", profile->compression_ratio, NULL);
}
@@ -440,6 +437,7 @@ gnac_profiles_lame_allocate_audio_profile(void)
AudioProfileLame *profile;
profile = g_malloc(sizeof(AudioProfileLame));
+ if (!profile) return NULL;
profile->encoding_mode = NULL;
profile->mode = NULL;
@@ -477,11 +475,10 @@ static AudioProfileLame *
gnac_profiles_lame_generate_audio_profile(GError **error)
{
AudioProfileGeneric *generic;
- AudioProfileLame *profile;
- GtkWidget *widget;
+ AudioProfileLame *profile;
+ GtkWidget *widget;
generic = gnac_profiles_default_generate_audio_profile(&lame_bfi);
-
profile = gnac_profiles_lame_allocate_audio_profile();
profile->generic = generic;
@@ -502,8 +499,6 @@ gnac_profiles_lame_generate_audio_profile(GError **error)
case AVERAGE_BITRATE:
gnac_profiles_utils_get_values_slider_and_set(&lame_bfi,
"slider-mean-abr", &profile->mean_abr, NULL);
-
- // min bitrate max bitrate
gnac_profiles_utils_get_values_checked_combo_and_set(&lame_bfi,
"combo-min-vbr", "checkbutton-min-bitrate", &profile->min_bitrate,
"combo-max-vbr", "checkbutton-max-bitrate", &profile->max_bitrate,
@@ -513,13 +508,9 @@ gnac_profiles_lame_generate_audio_profile(GError **error)
case VARIABLE_BITRATE:
gnac_profiles_utils_get_values_slider_and_set(&lame_bfi,
"slider-vbr-quality", &profile->quality, NULL);
-
- // mean bitrate
gnac_profiles_utils_get_values_checked_slider_and_set(&lame_bfi,
"slider-mean-vbr", "checkbutton-mean-bitrate", &profile->mean_bitrate,
NULL);
-
- // min bitrate max bitrate
gnac_profiles_utils_get_values_checked_combo_and_set(&lame_bfi,
"combo-min-vbr", "checkbutton-min-bitrate", &profile->min_bitrate,
"combo-max-vbr", "checkbutton-max-bitrate", &profile->max_bitrate,
@@ -547,9 +538,10 @@ gnac_profiles_lame_generate_audio_profile(GError **error)
static GtkWidget *
gnac_profiles_lame_get_widget(AudioProfileLame *profile)
{
- if (profile != NULL) {
+ if (profile) {
gnac_profiles_lame_fullfill_fields(profile);
}
+
return gnac_profiles_default_get_properties_alignment(&lame_bfi);
}
@@ -558,21 +550,25 @@ static void
gnac_profiles_lame_save_profile(AudioProfileLame *profile)
{
XMLDoc *doc;
- gchar *quality_str = NULL;
- gchar *mean_bitrate_str = NULL;
- gchar *mean_abr_str = NULL;
- gchar *compression_ratio_str = NULL;
+ gchar *quality_str = NULL;
+ gchar *mean_bitrate_str = NULL;
+ gchar *mean_abr_str = NULL;
+ gchar *compression_ratio_str = NULL;
- if (profile->quality != -1) {
+ if (profile->quality != -1)
+ {
quality_str = gnac_profiles_utils_gdouble_to_gchararray(profile->quality);
if (profile->mean_bitrate != -1) {
mean_bitrate_str = gnac_profiles_utils_gdouble_to_gchararray(
profile->mean_bitrate);
}
- } else if (profile->mean_abr != -1) {
+ }
+ else if (profile->mean_abr != -1)
+ {
mean_abr_str = gnac_profiles_utils_gdouble_to_gchararray(profile->mean_abr);
- } else if (profile->compression_ratio != -1) {
+ }
+ else if (profile->compression_ratio != -1) {
compression_ratio_str = gnac_profiles_utils_gdouble_to_gchararray(
profile->compression_ratio);
}
@@ -580,20 +576,19 @@ gnac_profiles_lame_save_profile(AudioProfileLame *profile)
doc = gnac_profiles_default_save_profile(profile->generic, &lame_bfi);
gnac_profiles_utils_save_specific_properties_in_file(doc,
"encoding-mode", profile->encoding_mode,
- "bitrate", profile->bitrate ? profile->bitrate : "",
- "quality", quality_str ? quality_str : "",
- "compression-ratio", compression_ratio_str ? compression_ratio_str : "",
- "preset", profile->preset ? profile->preset : "",
- "mean-abr", mean_abr_str ? mean_abr_str : "",
- "mean-bitrate", mean_bitrate_str ? mean_bitrate_str : "",
- "min-bitrate", profile->min_bitrate ? profile->min_bitrate : "",
- "max-bitrate", profile->max_bitrate ? profile->max_bitrate : "",
+ "bitrate", profile->bitrate,
+ "quality", quality_str,
+ "compression-ratio", compression_ratio_str,
+ "preset", profile->preset,
+ "mean-abr", mean_abr_str,
+ "mean-bitrate", mean_bitrate_str,
+ "min-bitrate", profile->min_bitrate,
+ "max-bitrate", profile->max_bitrate,
"mode", profile->mode,
NULL);
gnac_profiles_xml_engine_save_doc(doc, profile->generic->name);
- /* Cleanup */
gnac_profiles_xml_engine_free_doc_xpath(doc);
g_free(quality_str);
g_free(mean_bitrate_str);
@@ -606,10 +601,10 @@ gnac_profiles_lame_load_specific_properties(XMLDoc *doc,
AudioProfileGeneric *generic)
{
AudioProfileLame *profile;
- gchar *quality_str = NULL;
- gchar *mean_bitrate_str = NULL;
- gchar *mean_abr_str = NULL;
- gchar *compression_ratio_str = NULL;
+ gchar *quality_str = NULL;
+ gchar *mean_bitrate_str = NULL;
+ gchar *mean_abr_str = NULL;
+ gchar *compression_ratio_str = NULL;
profile = gnac_profiles_lame_allocate_audio_profile();
profile->generic = generic;
@@ -627,19 +622,19 @@ gnac_profiles_lame_load_specific_properties(XMLDoc *doc,
"mode", &profile->mode,
NULL);
- if (quality_str != NULL) {
+ if (quality_str) {
profile->quality = gnac_profiles_utils_gchararray_to_gdouble(quality_str);
g_free(quality_str);
- if (mean_bitrate_str != NULL) {
+ if (mean_bitrate_str) {
profile->mean_bitrate = gnac_profiles_utils_gchararray_to_gdouble(
mean_bitrate_str);
g_free(mean_bitrate_str);
}
- } else if (mean_abr_str != NULL){
+ } else if (mean_abr_str) {
profile->mean_abr = gnac_profiles_utils_gchararray_to_gdouble(mean_abr_str);
g_free(mean_abr_str);
- } else if (compression_ratio_str != NULL) {
+ } else if (compression_ratio_str) {
profile->compression_ratio = gnac_profiles_utils_gchararray_to_gdouble(
compression_ratio_str);
g_free(compression_ratio_str);
diff --git a/src/profiles/formats/gnac-profiles-speex.c b/src/profiles/formats/gnac-profiles-speex.c
index f9816ff..396fe30 100644
--- a/src/profiles/formats/gnac-profiles-speex.c
+++ b/src/profiles/formats/gnac-profiles-speex.c
@@ -71,7 +71,7 @@ static const gchar *
gnac_profiles_speex_init(UpdateTextBufferFunc call_back);
static void
-gnac_profiles_speex_generate_pipeline(GtkWidget *w);
+gnac_profiles_speex_generate_pipeline(GtkWidget *widget);
static AudioProfileSpeex *
gnac_profiles_speex_generate_audio_profile(GError **error);
@@ -140,6 +140,7 @@ gnac_profiles_speex_get_funcs(void)
gnac_profiles_speex_get_combo_format_name,
gnac_profiles_speex_get_plugin_name
};
+
return funcs;
}
@@ -228,7 +229,6 @@ gnac_profiles_speex_init(UpdateTextBufferFunc call_back)
gnac_profiles_speex_bitrate_on_changed(GTK_COMBO_BOX(widget));
- /* Cleanup */
gnac_profiles_xml_engine_free_doc_xpath(speex_bfi.doc);
speex_bfi.doc = NULL;
@@ -239,12 +239,7 @@ gnac_profiles_speex_init(UpdateTextBufferFunc call_back)
static void
gnac_profiles_speex_bitrate_on_changed(GtkComboBox *widget)
{
- guint i;
- BitrateMode bitrate_mode;
- guint start_index_of_abr_widgets = 4;
- guint start_index_of_vbr_widgets = 6;
-
GtkWidget *widgets_tab[] = {
gnac_profiles_utils_get_widget(&speex_bfi, "checkbutton-bitrate-cbr"),
gnac_profiles_utils_get_widget(&speex_bfi, "slider-bitrate-cbr"),
@@ -256,9 +251,13 @@ gnac_profiles_speex_bitrate_on_changed(GtkComboBox *widget)
gnac_profiles_utils_get_widget(&speex_bfi, "hbox-quality-vbr"),
};
- bitrate_mode = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
+ guint start_index_of_abr_widgets = 4;
+ guint start_index_of_vbr_widgets = 6;
- for (i = 0; i < G_N_ELEMENTS(widgets_tab); ++i) {
+ BitrateMode bitrate_mode = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
+
+ guint i;
+ for (i = 0; i < G_N_ELEMENTS(widgets_tab); i++) {
switch (bitrate_mode) {
case CONSTANT_BITRATE:
@@ -322,28 +321,29 @@ gnac_profiles_speex_display_vad(BitrateMode bitrate_mode)
static void
gnac_profiles_speex_generate_pipeline(GtkWidget *w)
{
+ gchar *pipeline;
GtkWidget *widget;
- BitrateMode bitrate_mode;
- gchar *pipeline;
pipeline = gnac_profiles_default_generate_pipeline(&speex_bfi);
-
widget = gnac_profiles_utils_get_widget(&speex_bfi, "combo-bitrate-mode");
if (w == widget) {
gnac_profiles_speex_bitrate_on_changed(GTK_COMBO_BOX(w));
}
- bitrate_mode = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
+ BitrateMode bitrate_mode = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
switch (bitrate_mode)
{
case CONSTANT_BITRATE:
pipeline = gnac_profiles_utils_add_properties_slider(pipeline,
&speex_bfi, "slider-quality-cbr", NULL);
- widget = gnac_profiles_utils_get_widget(&speex_bfi, "checkbutton-bitrate-cbr");
+ widget = gnac_profiles_utils_get_widget(&speex_bfi,
+ "checkbutton-bitrate-cbr");
+
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
- widget = gnac_profiles_utils_get_widget(&speex_bfi, "slider-bitrate-cbr");
+ widget = gnac_profiles_utils_get_widget(&speex_bfi,
+ "slider-bitrate-cbr");
pipeline = gnac_profiles_utils_add_property_slider(pipeline,
"%.0f", 1024, widget);
}
@@ -378,10 +378,8 @@ gnac_profiles_speex_generate_pipeline(GtkWidget *w)
pipeline = gnac_profiles_utils_add_properties_checked_slider(pipeline,
&speex_bfi, "slider-complexity", "checkbutton-complexity", NULL);
-
pipeline = gnac_profiles_utils_add_properties_combo(pipeline, &speex_bfi,
"combo-mode", NULL);
-
pipeline = gnac_profiles_utils_add_pipe(pipeline,
speex_bfi.pipeline_multiplexers);
@@ -423,7 +421,7 @@ gnac_profiles_speex_fullfill_fields(AudioProfileSpeex *profile)
{
GtkWidget *widget;
- if (profile == NULL) {
+ if (!profile) {
gnac_profiles_default_fullfill_fields(NULL, &speex_bfi);
gnac_profiles_utils_reinit_values_combo(&speex_bfi,
"combo-bitrate-mode",
@@ -440,14 +438,10 @@ gnac_profiles_speex_fullfill_fields(AudioProfileSpeex *profile)
"checkbutton-vad",
"checkbutton-dtx",
NULL);
-
gnac_profiles_utils_set_active_toggle_button(&speex_bfi, FALSE,
"checkbutton-complexity", "checkbutton-bitrate-cbr", NULL);
-
} else {
-
gnac_profiles_default_fullfill_fields(profile->generic, &speex_bfi);
-
gnac_profiles_utils_set_values_checked_slider(&speex_bfi,
"slider-complexity", "checkbutton-complexity", profile->complexity,
NULL);
@@ -458,23 +452,30 @@ gnac_profiles_speex_fullfill_fields(AudioProfileSpeex *profile)
widget = gnac_profiles_utils_get_widget(&speex_bfi, "combo-bitrate-mode");
- if (profile->quality_cbr != -1) {
+ if (profile->quality_cbr != -1)
+ {
gnac_profiles_utils_set_values_slider(&speex_bfi, "slider-bitrate-cbr",
profile->bitrate_cbr, NULL);
+
if (profile->bitrate_cbr != 1) {
gnac_profiles_utils_set_values_checked_slider(&speex_bfi,
"slider-bitrate-cbr", "checkbutton-bitrate-cbr",
profile->bitrate_cbr,
NULL);
}
+
gtk_combo_box_set_active(GTK_COMBO_BOX(widget), CONSTANT_BITRATE);
- } else if (profile->quality_vbr != -1) {
+ }
+ else if (profile->quality_vbr != -1)
+ {
gnac_profiles_utils_set_active_toggle_button(&speex_bfi, TRUE,
"checkbutton-vbr", NULL);
gnac_profiles_utils_set_values_slider(&speex_bfi,
"slider-quality-vbr", profile->quality_vbr, NULL);
gtk_combo_box_set_active(GTK_COMBO_BOX(widget), VARIABLE_BITRATE);
- } else {
+ }
+ else
+ {
gnac_profiles_utils_set_values_slider(&speex_bfi,
"slider-bitrate-abr", profile->bitrate_abr, NULL);
gtk_combo_box_set_active(GTK_COMBO_BOX(widget), AVERAGE_BITRATE);
@@ -496,6 +497,7 @@ gnac_profiles_speex_allocate_audio_profile(void)
AudioProfileSpeex *profile;
profile = g_malloc(sizeof(AudioProfileSpeex));
+ if (!profile) return NULL;
profile->quality_cbr = -1;
profile->quality_vbr = -1;
@@ -528,21 +530,18 @@ static AudioProfileSpeex *
gnac_profiles_speex_generate_audio_profile(GError **error)
{
AudioProfileGeneric *generic;
- AudioProfileSpeex *profile;
- GtkWidget *widget;
- BitrateMode bitrate_mode;
+ AudioProfileSpeex *profile;
+ GtkWidget *widget;
+ BitrateMode bitrate_mode;
generic = gnac_profiles_default_generate_audio_profile(&speex_bfi);
-
profile = gnac_profiles_speex_allocate_audio_profile();
profile->generic = generic;
-
widget = gnac_profiles_utils_get_widget(&speex_bfi, "combo-bitrate-mode");
bitrate_mode = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
gnac_profiles_utils_get_values_combo_and_set(&speex_bfi,
"combo-mode", &profile->mode, NULL);
-
gnac_profiles_utils_get_values_checked_slider_and_set(&speex_bfi,
"slider-complexity", "checkbutton-complexity", &profile->complexity,
NULL);
@@ -583,9 +582,10 @@ gnac_profiles_speex_generate_audio_profile(GError **error)
static GtkWidget *
gnac_profiles_speex_get_widget(AudioProfileSpeex *profile)
{
- if (profile != NULL) {
+ if (profile) {
gnac_profiles_speex_fullfill_fields(profile);
}
+
return gnac_profiles_default_get_properties_alignment(&speex_bfi);
}
@@ -594,23 +594,29 @@ static void
gnac_profiles_speex_save_profile(AudioProfileSpeex *profile)
{
XMLDoc *doc;
- gchar *quality_cbr_str = NULL;
- gchar *bitrate_cbr_str = NULL;
- gchar *bitrate_abr_str = NULL;
- gchar *quality_vbr_str = NULL;
- gchar *complexity_str = NULL;
+ gchar *quality_cbr_str = NULL;
+ gchar *bitrate_cbr_str = NULL;
+ gchar *bitrate_abr_str = NULL;
+ gchar *quality_vbr_str = NULL;
+ gchar *complexity_str = NULL;
- if (profile->quality_cbr != -1) {
+ if (profile->quality_cbr != -1)
+ {
quality_cbr_str = gnac_profiles_utils_gdouble_to_gchararray(
profile->quality_cbr);
+
if (profile->bitrate_cbr != -1) {
bitrate_cbr_str = gnac_profiles_utils_gdouble_to_gchararray(
profile->bitrate_cbr);
}
- } else if (profile->quality_vbr != -1) {
+ }
+ else if (profile->quality_vbr != -1)
+ {
quality_vbr_str = gnac_profiles_utils_gdouble_to_gchararray_format(
profile->quality_vbr, "%.2f");
- } else {
+ }
+ else
+ {
bitrate_abr_str = gnac_profiles_utils_gdouble_to_gchararray(
profile->bitrate_abr);
}
@@ -622,19 +628,18 @@ gnac_profiles_speex_save_profile(AudioProfileSpeex *profile)
doc = gnac_profiles_default_save_profile(profile->generic, &speex_bfi);
gnac_profiles_utils_save_specific_properties_in_file(doc,
- "bitrate-cbr", bitrate_cbr_str ? bitrate_cbr_str : "",
- "quality-cbr", quality_cbr_str ? quality_cbr_str : "",
- "bitrate-abr", bitrate_abr_str ? bitrate_abr_str : "",
- "quality-vbr", quality_vbr_str ? quality_vbr_str : "",
+ "bitrate-cbr", bitrate_cbr_str,
+ "quality-cbr", quality_cbr_str,
+ "bitrate-abr", bitrate_abr_str,
+ "quality-vbr", quality_vbr_str,
"mode", profile->mode,
- "complexity", complexity_str ? complexity_str : "",
+ "complexity", complexity_str,
"vad", profile->vad,
"dtx", profile->dtx,
NULL);
gnac_profiles_xml_engine_save_doc(doc, profile->generic->name);
- /* Cleanup */
gnac_profiles_xml_engine_free_doc_xpath(doc);
g_free(quality_cbr_str);
g_free(quality_vbr_str);
@@ -649,11 +654,11 @@ gnac_profiles_speex_load_specific_properties(XMLDoc *doc,
AudioProfileGeneric *generic)
{
AudioProfileSpeex *profile;
- gchar *quality_cbr_str;
- gchar *bitrate_cbr_str;
- gchar *bitrate_abr_str;
- gchar *quality_vbr_str;
- gchar *complexity_str;
+ gchar *quality_cbr_str;
+ gchar *bitrate_cbr_str;
+ gchar *bitrate_abr_str;
+ gchar *quality_vbr_str;
+ gchar *complexity_str;
profile = gnac_profiles_speex_allocate_audio_profile();
profile->generic = generic;
@@ -669,28 +674,33 @@ gnac_profiles_speex_load_specific_properties(XMLDoc *doc,
"dtx", &profile->dtx,
NULL);
- if (complexity_str != NULL) {
+ if (complexity_str) {
profile->complexity = gnac_profiles_utils_gchararray_to_gdouble(
complexity_str);
g_free(complexity_str);
}
- if (quality_cbr_str != NULL) {
+ if (quality_cbr_str)
+ {
profile->quality_cbr = gnac_profiles_utils_gchararray_to_gdouble(
quality_cbr_str);
- if (bitrate_cbr_str != NULL) {
+ if (bitrate_cbr_str) {
profile->bitrate_cbr = gnac_profiles_utils_gchararray_to_gdouble(
bitrate_cbr_str);
g_free(bitrate_cbr_str);
}
g_free(quality_cbr_str);
- } else if (quality_vbr_str != NULL) {
+ }
+ else if (quality_vbr_str)
+ {
profile->quality_vbr = gnac_profiles_utils_gchararray_to_gdouble(
quality_vbr_str);
g_free(quality_vbr_str);
- } else {
+ }
+ else
+ {
profile->bitrate_abr = gnac_profiles_utils_gchararray_to_gdouble(
bitrate_abr_str);
g_free(bitrate_abr_str);
diff --git a/src/profiles/formats/gnac-profiles-unknown.c b/src/profiles/formats/gnac-profiles-unknown.c
index 0fd63f3..a92d290 100644
--- a/src/profiles/formats/gnac-profiles-unknown.c
+++ b/src/profiles/formats/gnac-profiles-unknown.c
@@ -50,7 +50,8 @@ const gchar *base_pipeline =
"audioconvert ! audio/x-raw-float, rate=44100, channels=2 ! audioconvert !";
static GtkTextView *pipeline_text_view;
-static GtkWidget *pipeline_box;
+static GtkWidget *pipeline_box;
+
static gulong text_view_handler_id = 0;
static const gchar *
@@ -117,6 +118,7 @@ gnac_profiles_unknown_get_funcs(void)
gnac_profiles_unknown_get_combo_format_name,
gnac_profiles_unknown_get_plugin_name
};
+
return funcs;
}
@@ -150,7 +152,7 @@ gnac_profiles_unknown_generate_pipeline(GtkWidget *widget)
static void
gnac_profiles_unknown_fullfill_fields(AudioProfileGeneric *profile)
{
- GtkWidget *widget;
+ GtkWidget *widget;
GtkTextBuffer *text_buffer;
widget = gnac_profiles_utils_get_widget(&unknown_bfi, "entry-extension");
@@ -189,26 +191,28 @@ static AudioProfileGeneric *
gnac_profiles_unknown_generate_audio_profile(GError **error)
{
AudioProfileGeneric *profile;
- GtkWidget *widget;
- const gchar *extension;
+ const gchar *extension;
+ GtkWidget *widget;
widget = gnac_profiles_utils_get_widget(&unknown_bfi, "entry-extension");
extension = gtk_entry_get_text(GTK_ENTRY(widget));
+
if (gnac_utils_string_is_null_or_empty(extension)) {
- if (error && *error == NULL) {
+ if (error && !*error) {
*error = g_error_new(g_quark_from_static_string("gnac"), 0,
_("The extension field must be non-empty"));
}
return NULL;
- } else {
- profile = gnac_profiles_utils_allocate_audio_profile_generic();
- profile->extension = g_strdup(extension);
- profile->format_id = g_strdup(unknown_bfi.format_id);
- profile->format_name = g_strdup(unknown_bfi.format_name);
- profile->channels = g_strdup("-1");
- profile->rate = g_strdup("-1");
- return profile;
}
+
+ profile = gnac_profiles_utils_allocate_audio_profile_generic();
+ profile->extension = g_strdup(extension);
+ profile->format_id = g_strdup(unknown_bfi.format_id);
+ profile->format_name = g_strdup(unknown_bfi.format_name);
+ profile->channels = g_strdup("-1");
+ profile->rate = g_strdup("-1");
+
+ return profile;
}
@@ -252,9 +256,11 @@ static void
gnac_profiles_unknown_save_profile(AudioProfileGeneric *profile)
{
XMLDoc *doc;
+
doc = gnac_profiles_default_save_profile((AudioProfileGeneric*) profile,
&unknown_bfi);
gnac_profiles_xml_engine_save_doc(doc, profile->generic->name);
+
gnac_profiles_xml_engine_free_doc_xpath(doc);
}
diff --git a/src/profiles/formats/gnac-profiles-vorbis.c b/src/profiles/formats/gnac-profiles-vorbis.c
index 763e575..254f38c 100755
--- a/src/profiles/formats/gnac-profiles-vorbis.c
+++ b/src/profiles/formats/gnac-profiles-vorbis.c
@@ -65,7 +65,7 @@ static const gchar *
gnac_profiles_vorbis_init(UpdateTextBufferFunc call_back);
static void
-gnac_profiles_vorbis_generate_pipeline(GtkWidget *w);
+gnac_profiles_vorbis_generate_pipeline(GtkWidget *widget);
static AudioProfileVorbis *
gnac_profiles_vorbis_generate_audio_profile(GError **error);
@@ -127,6 +127,7 @@ gnac_profiles_vorbis_get_funcs(void)
gnac_profiles_vorbis_get_combo_format_name,
gnac_profiles_vorbis_get_plugin_name
};
+
return funcs;
}
@@ -177,7 +178,6 @@ gnac_profiles_vorbis_init(UpdateTextBufferFunc call_back)
gnac_profiles_vorbis_vbr_on_changed(GTK_COMBO_BOX(widget));
- /* Cleanup */
gnac_profiles_xml_engine_free_doc_xpath(vorbis_bfi.doc);
vorbis_bfi.doc = NULL;
@@ -188,9 +188,6 @@ gnac_profiles_vorbis_init(UpdateTextBufferFunc call_back)
static void
gnac_profiles_vorbis_vbr_on_changed(GtkComboBox *widget)
{
- guint i;
- EncodingMode encoding_mode;
-
GtkWidget *widgets_tab[] = {
gnac_profiles_utils_get_widget(&vorbis_bfi, "label-quality"),
gnac_profiles_utils_get_widget(&vorbis_bfi, "hbox-quality"),
@@ -202,8 +199,9 @@ gnac_profiles_vorbis_vbr_on_changed(GtkComboBox *widget)
gnac_profiles_utils_get_widget(&vorbis_bfi, "combo-min-vbr")
};
- encoding_mode = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
+ EncodingMode encoding_mode = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
+ guint i;
for (i = 0; i < G_N_ELEMENTS(widgets_tab); ++i) {
if ((encoding_mode == VARIABLE_BITRATE && (i >= 4 || i <= 1)) ||
(encoding_mode == CONSTANT_BITRATE && (i == 2 || i == 3)))
@@ -220,18 +218,16 @@ static void
gnac_profiles_vorbis_generate_pipeline(GtkWidget *w)
{
GtkWidget *widget;
- gchar *pipeline;
- EncodingMode encoding_mode;
+ gchar *pipeline;
pipeline = gnac_profiles_default_generate_pipeline(&vorbis_bfi);
-
widget = gnac_profiles_utils_get_widget(&vorbis_bfi, "combo-encoding-mode");
if (w == widget) {
gnac_profiles_vorbis_vbr_on_changed(GTK_COMBO_BOX(w));
}
- encoding_mode = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
+ EncodingMode encoding_mode = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
if (encoding_mode == CONSTANT_BITRATE) {
pipeline = gnac_profiles_utils_add_properties_combo(pipeline,
@@ -239,7 +235,6 @@ gnac_profiles_vorbis_generate_pipeline(GtkWidget *w)
} else if (encoding_mode == VARIABLE_BITRATE) {
pipeline = gnac_profiles_utils_add_properties_slider_format(pipeline,
&vorbis_bfi, "%.1f", "slider-quality", NULL);
-
pipeline = gnac_profiles_utils_add_properties_checked_combo(pipeline,
&vorbis_bfi,
"combo-min-vbr", "checkbutton-min-bitrate",
@@ -271,7 +266,7 @@ gnac_profiles_vorbis_fullfill_fields(AudioProfileVorbis *profile)
{
GtkWidget *widget;
- if (profile == NULL) {
+ if (!profile) {
gnac_profiles_default_fullfill_fields(NULL, &vorbis_bfi);
gnac_profiles_utils_reinit_values_combo(&vorbis_bfi,
"combo-encoding-mode",
@@ -282,15 +277,14 @@ gnac_profiles_vorbis_fullfill_fields(AudioProfileVorbis *profile)
gnac_profiles_utils_reinit_values_slider(&vorbis_bfi,
"slider-quality",
NULL);
-
gnac_profiles_utils_set_active_toggle_button(&vorbis_bfi, FALSE,
"checkbutton-min-bitrate",
"checkbutton-max-bitrate",
NULL);
-
} else {
widget = gnac_profiles_utils_get_widget(&vorbis_bfi, "combo-encoding-mode");
gnac_profiles_default_fullfill_fields(profile->generic, &vorbis_bfi);
+
if (profile->quality == -1) {
gnac_profiles_utils_set_values_combo(&vorbis_bfi,
"combo-bitrate", profile->bitrate, NULL);
@@ -321,6 +315,7 @@ gnac_profiles_vorbis_allocate_audio_profile(void)
AudioProfileVorbis *profile;
profile = g_malloc(sizeof(AudioProfileVorbis));
+ if (!profile) return NULL;
profile->quality = -1;
profile->bitrate = NULL;
@@ -349,15 +344,13 @@ static AudioProfileVorbis *
gnac_profiles_vorbis_generate_audio_profile(GError **error)
{
AudioProfileGeneric *generic;
- AudioProfileVorbis *profile;
- GtkWidget *widget;
- EncodingMode encoding_mode;
+ AudioProfileVorbis *profile;
+ GtkWidget *widget;
+ EncodingMode encoding_mode;
generic = gnac_profiles_default_generate_audio_profile(&vorbis_bfi);
-
profile = gnac_profiles_vorbis_allocate_audio_profile();
profile->generic = generic;
-
widget = gnac_profiles_utils_get_widget(&vorbis_bfi, "combo-encoding-mode");
encoding_mode = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
@@ -367,7 +360,6 @@ gnac_profiles_vorbis_generate_audio_profile(GError **error)
} else {
gnac_profiles_utils_get_values_slider_and_set(&vorbis_bfi,
"slider-quality", &profile->quality, NULL);
-
gnac_profiles_utils_get_values_checked_combo_and_set(&vorbis_bfi,
"combo-min-vbr", "checkbutton-min-bitrate", &profile->min_bitrate,
"combo-max-vbr", "checkbutton-max-bitrate", &profile->max_bitrate,
@@ -381,9 +373,10 @@ gnac_profiles_vorbis_generate_audio_profile(GError **error)
static GtkWidget *
gnac_profiles_vorbis_get_widget(AudioProfileVorbis *profile)
{
- if (profile != NULL) {
+ if (profile) {
gnac_profiles_vorbis_fullfill_fields(profile);
}
+
return gnac_profiles_default_get_properties_alignment(&vorbis_bfi);
}
@@ -392,19 +385,18 @@ static void
gnac_profiles_vorbis_save_profile(AudioProfileVorbis *profile)
{
XMLDoc *doc;
- gchar *quality_str;
+ gchar *quality_str;
quality_str = gnac_profiles_utils_gdouble_to_gchararray_format(
profile->quality, "%.1f");
doc = gnac_profiles_default_save_profile(profile->generic, &vorbis_bfi);
gnac_profiles_utils_save_specific_properties_in_file(doc,
"quality", quality_str,
- "bitrate", profile->bitrate ? profile->bitrate : "",
- "min-bitrate", profile->min_bitrate ? profile->min_bitrate : "",
- "max-bitrate", profile->max_bitrate ? profile->max_bitrate : "",
+ "bitrate", profile->bitrate,
+ "min-bitrate", profile->min_bitrate,
+ "max-bitrate", profile->max_bitrate,
NULL);
- /* Cleanup */
gnac_profiles_xml_engine_save_doc(doc, profile->generic->name);
gnac_profiles_xml_engine_free_doc_xpath(doc);
g_free(quality_str);
@@ -416,7 +408,7 @@ gnac_profiles_vorbis_load_specific_properties(XMLDoc *doc,
AudioProfileGeneric *generic)
{
AudioProfileVorbis *profile;
- gchar *quality_str;
+ gchar *quality_str;
profile = gnac_profiles_vorbis_allocate_audio_profile();
profile->generic = generic;
@@ -428,7 +420,7 @@ gnac_profiles_vorbis_load_specific_properties(XMLDoc *doc,
"max-bitrate", &profile->max_bitrate,
NULL);
- if (quality_str != NULL) {
+ if (quality_str) {
profile->quality = gnac_profiles_utils_gchararray_to_gdouble(quality_str);
g_free(quality_str);
}
diff --git a/src/profiles/formats/gnac-profiles-wav.c b/src/profiles/formats/gnac-profiles-wav.c
index 3103cba..dd953ca 100755
--- a/src/profiles/formats/gnac-profiles-wav.c
+++ b/src/profiles/formats/gnac-profiles-wav.c
@@ -49,7 +49,7 @@ static const gchar *
gnac_profiles_wav_init(UpdateTextBufferFunc call_back);
static void
-gnac_profiles_wav_generate_pipeline(GtkWidget *w);
+gnac_profiles_wav_generate_pipeline(GtkWidget *widget);
static void
gnac_profiles_wav_fullfill_fields(AudioProfileGeneric *profile);
@@ -101,6 +101,7 @@ gnac_profiles_wav_get_funcs(void)
gnac_profiles_wav_get_combo_format_name,
gnac_profiles_wav_get_plugin_name
};
+
return funcs;
}
@@ -113,7 +114,6 @@ gnac_profiles_wav_init(UpdateTextBufferFunc call_back)
gnac_profiles_default_init(&wav_bfi,
G_CALLBACK(gnac_profiles_wav_generate_pipeline));
- /* Cleanup */
gnac_profiles_xml_engine_free_doc_xpath(wav_bfi.doc);
wav_bfi.doc = NULL;
@@ -122,12 +122,11 @@ gnac_profiles_wav_init(UpdateTextBufferFunc call_back)
static void
-gnac_profiles_wav_generate_pipeline(GtkWidget *w)
+gnac_profiles_wav_generate_pipeline(GtkWidget *widget G_GNUC_UNUSED)
{
gchar *pipeline;
pipeline = gnac_profiles_default_generate_pipeline(&wav_bfi);
-
update_text_buffer_call_back(pipeline);
g_free(wav_bfi.pipeline);
@@ -137,7 +136,7 @@ gnac_profiles_wav_generate_pipeline(GtkWidget *w)
static void
-gnac_profiles_wav_fullfill_fields(AudioProfileGeneric *profile)
+gnac_profiles_wav_fullfill_fields(AudioProfileGeneric *profile G_GNUC_UNUSED)
{
}
diff --git a/src/profiles/formats/gnac-profiles-wavpack.c b/src/profiles/formats/gnac-profiles-wavpack.c
index 6e60428..6dd93b6 100644
--- a/src/profiles/formats/gnac-profiles-wavpack.c
+++ b/src/profiles/formats/gnac-profiles-wavpack.c
@@ -67,7 +67,7 @@ static const gchar *
gnac_profiles_wavpack_init(UpdateTextBufferFunc call_back);
static void
-gnac_profiles_wavpack_generate_pipeline(GtkWidget *w);
+gnac_profiles_wavpack_generate_pipeline(GtkWidget *widget);
static AudioProfileWavpack *
gnac_profiles_wavpack_generate_audio_profile(GError **error);
@@ -133,6 +133,7 @@ gnac_profiles_wavpack_get_funcs(void)
gnac_profiles_wavpack_get_combo_format_name,
gnac_profiles_wavpack_get_plugin_name
};
+
return funcs;
}
@@ -199,7 +200,6 @@ gnac_profiles_wavpack_init(UpdateTextBufferFunc call_back)
gnac_profiles_wavpack_bitrate_control_on_toggle(GTK_TOGGLE_BUTTON(widget2),
widget);
- /* Cleanup */
gnac_profiles_xml_engine_free_doc_xpath(wavpack_bfi.doc);
wavpack_bfi.doc = NULL;
@@ -210,11 +210,6 @@ gnac_profiles_wavpack_init(UpdateTextBufferFunc call_back)
static void
gnac_profiles_wavpack_bitrate_control_on_changed(GtkComboBox *widget)
{
- guint i;
- ControlMethod control_method;
- gboolean bitrate_ctrl_enabled;
- GtkToggleButton *bitrate_ctrl_btn;
-
GtkWidget *widgets_tab[] = {
gnac_profiles_utils_get_widget(&wavpack_bfi, "label-bitrate"),
gnac_profiles_utils_get_widget(&wavpack_bfi, "slider-bitrate"),
@@ -222,11 +217,12 @@ gnac_profiles_wavpack_bitrate_control_on_changed(GtkComboBox *widget)
gnac_profiles_utils_get_widget(&wavpack_bfi, "slider-bits-per-sample"),
};
- bitrate_ctrl_btn = GTK_TOGGLE_BUTTON(
+ GtkToggleButton *bitrate_ctrl_btn = GTK_TOGGLE_BUTTON(
gnac_profiles_utils_get_widget(&wavpack_bfi, "checkbutton-bitrate-control"));
- bitrate_ctrl_enabled = gtk_toggle_button_get_active(bitrate_ctrl_btn);
- control_method = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
+ gboolean bitrate_ctrl_enabled = gtk_toggle_button_get_active(bitrate_ctrl_btn);
+ ControlMethod control_method = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
+ guint i;
for (i = 0; i < G_N_ELEMENTS(widgets_tab); ++i) {
if (bitrate_ctrl_enabled &&
((control_method == AVERAGE_BITRATE && i < 2) ||
@@ -245,11 +241,10 @@ gnac_profiles_wavpack_generate_pipeline(GtkWidget *w)
{
GtkWidget *widget;
GtkWidget *check;
- gchar *pipeline;
+ gchar *pipeline;
ControlMethod control_method;
pipeline = gnac_profiles_default_generate_pipeline(&wavpack_bfi);
-
widget = gnac_profiles_utils_get_widget(&wavpack_bfi, "combo-bitrate-control");
if (w == widget) {
@@ -266,11 +261,11 @@ gnac_profiles_wavpack_generate_pipeline(GtkWidget *w)
NULL);
pipeline = gnac_profiles_utils_add_properties_check(pipeline, &wavpack_bfi,
"checkbutton-md5", NULL);
-
check = gnac_profiles_utils_get_widget(&wavpack_bfi, "checkbutton-bitrate-control");
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check))) {
control_method = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
+
if (control_method == AVERAGE_BITRATE) {
widget = gnac_profiles_utils_get_widget(&wavpack_bfi, "slider-bitrate");
pipeline = gnac_profiles_utils_add_property_slider(pipeline,
@@ -327,7 +322,7 @@ gnac_profiles_wavpack_fullfill_fields(AudioProfileWavpack *profile)
GtkWidget *widget;
GtkWidget *check;
- if (profile == NULL) {
+ if (!profile) {
gnac_profiles_default_fullfill_fields(NULL, &wavpack_bfi);
gnac_profiles_utils_reinit_values_combo(&wavpack_bfi,
"combo-mode",
@@ -342,10 +337,8 @@ gnac_profiles_wavpack_fullfill_fields(AudioProfileWavpack *profile)
"slider-bits-per-sample",
"slider-extra-processing",
NULL);
-
gnac_profiles_utils_set_active_toggle_button(&wavpack_bfi, FALSE,
"checkbutton-bitrate-control", NULL);
-
} else {
gnac_profiles_utils_set_values_combo(&wavpack_bfi,
"combo-mode", profile->mode,
@@ -390,6 +383,7 @@ gnac_profiles_wavpack_allocate_audio_profile(void)
AudioProfileWavpack *profile;
profile = g_malloc(sizeof(AudioProfileWavpack));
+ if (!profile) return NULL;
profile->mode = NULL;
profile->bitrate = -1;
@@ -421,12 +415,11 @@ gnac_profiles_wavpack_generate_audio_profile(GError **error)
{
AudioProfileGeneric *generic;
AudioProfileWavpack *profile;
- GtkWidget *widget;
- GtkWidget *check;
- ControlMethod control_method;
+ GtkWidget *widget;
+ GtkWidget *check;
+ ControlMethod control_method;
generic = gnac_profiles_default_generate_audio_profile(&wavpack_bfi);
-
profile = gnac_profiles_wavpack_allocate_audio_profile();
profile->generic = generic;
@@ -440,7 +433,6 @@ gnac_profiles_wavpack_generate_audio_profile(GError **error)
gnac_profiles_utils_get_values_slider_and_set(&wavpack_bfi,
"slider-extra-processing", &profile->extra_processing,
NULL);
-
gnac_profiles_utils_get_values_check_and_set(&wavpack_bfi,
"checkbutton-md5", &profile->md5, NULL);
@@ -449,6 +441,7 @@ gnac_profiles_wavpack_generate_audio_profile(GError **error)
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(check))) {
control_method = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));
+
if (control_method == AVERAGE_BITRATE) {
gnac_profiles_utils_get_values_slider_and_set(&wavpack_bfi,
"slider-bitrate", &profile->bitrate, NULL);
@@ -465,9 +458,10 @@ gnac_profiles_wavpack_generate_audio_profile(GError **error)
static GtkWidget *
gnac_profiles_wavpack_get_widget(AudioProfileWavpack *profile)
{
- if (profile != NULL) {
+ if (profile) {
gnac_profiles_wavpack_fullfill_fields(profile);
}
+
return gnac_profiles_default_get_properties_alignment(&wavpack_bfi);
}
@@ -476,9 +470,9 @@ static void
gnac_profiles_wavpack_save_profile(AudioProfileWavpack *profile)
{
XMLDoc *doc;
- gchar *bitrate_str = NULL;
- gchar *bits_per_sample_str = NULL;
- gchar *extra_processing_str;
+ gchar *bitrate_str = NULL;
+ gchar *bits_per_sample_str = NULL;
+ gchar *extra_processing_str;
if (profile->bitrate != -1) {
bitrate_str = gnac_profiles_utils_gdouble_to_gchararray(profile->bitrate);
@@ -486,22 +480,21 @@ gnac_profiles_wavpack_save_profile(AudioProfileWavpack *profile)
bits_per_sample_str = gnac_profiles_utils_gdouble_to_gchararray(
profile->bits_per_sample);
}
+
extra_processing_str = gnac_profiles_utils_gdouble_to_gchararray(
profile->extra_processing);
doc = gnac_profiles_default_save_profile(profile->generic, &wavpack_bfi);
gnac_profiles_utils_save_specific_properties_in_file(doc,
"mode", profile->mode,
- "bitrate", bitrate_str ? bitrate_str : "",
- "bits-per-sample", bits_per_sample_str ? bits_per_sample_str : "",
+ "bitrate", bitrate_str,
+ "bits-per-sample", bits_per_sample_str,
"extra-processing", extra_processing_str,
- "joint-stereo-mode",
- profile->joint_stereo_mode ? profile->joint_stereo_mode : "",
+ "joint-stereo-mode", profile->joint_stereo_mode,
"md5", profile->md5,
NULL);
gnac_profiles_xml_engine_save_doc(doc, profile->generic->name);
- /* Cleanup */
gnac_profiles_xml_engine_free_doc_xpath(doc);
g_free(bitrate_str);
g_free(bits_per_sample_str);
@@ -514,9 +507,9 @@ gnac_profiles_wavpack_load_specific_properties(XMLDoc *doc,
AudioProfileGeneric *generic)
{
AudioProfileWavpack *profile;
- gchar *bitrate_str;
- gchar *bits_per_sample_str;
- gchar *extra_processing_str;
+ gchar *bitrate_str;
+ gchar *bits_per_sample_str;
+ gchar *extra_processing_str;
profile = gnac_profiles_wavpack_allocate_audio_profile();
profile->generic = generic;
@@ -532,12 +525,13 @@ gnac_profiles_wavpack_load_specific_properties(XMLDoc *doc,
profile->extra_processing = gnac_profiles_utils_gchararray_to_gdouble(
extra_processing_str);
+
g_free(extra_processing_str);
- if (bitrate_str != NULL) {
+ if (bitrate_str) {
profile->bitrate = gnac_profiles_utils_gchararray_to_gdouble(bitrate_str);
g_free(bitrate_str);
- } else if (bits_per_sample_str != NULL) {
+ } else if (bits_per_sample_str) {
profile->bits_per_sample = gnac_profiles_utils_gchararray_to_gdouble(
bits_per_sample_str);
g_free(bits_per_sample_str);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]