changeset 493:31d21ad70903 trunk

[svn] flac 113 plugin: stability fixes and a new option to disable bitrate update in player window during playback (saves cpu, this is the solution for most people playing flac and reporting high cpu usage)
author giacomo
date Sun, 21 Jan 2007 16:08:19 -0800
parents 0dd1ff7e5ba7
children 631bd25d2380
files ChangeLog src/flac113/configure.c src/flac113/configure.h src/flac113/plugin.c
diffstat 4 files changed, 37 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Jan 21 16:03:30 2007 -0800
+++ b/ChangeLog	Sun Jan 21 16:08:19 2007 -0800
@@ -1,3 +1,12 @@
+2007-01-22 00:03:30 +0000  Giacomo Lozito <james@develia.org>
+  revision [1070]
+  flac 112 plugin: stability fixes and a new option to disable bitrate update in player window during playback (saves cpu, this is the solution for most people playing flac and reporting high cpu usage)
+  trunk/src/flac112/configure.c |   21 ++++++++++++++++++---
+  trunk/src/flac112/configure.h |    1 +
+  trunk/src/flac112/plugin.c    |   15 +++++++++------
+  3 files changed, 28 insertions(+), 9 deletions(-)
+
+
 2007-01-21 23:34:56 +0000  Giacomo Lozito <james@develia.org>
   revision [1068]
   flac 113 plugin: small fixes
--- a/src/flac113/configure.c	Sun Jan 21 16:03:30 2007 -0800
+++ b/src/flac113/configure.c	Sun Jan 21 16:08:19 2007 -0800
@@ -46,7 +46,8 @@
 		FALSE, /* tag_override */
 		NULL, /* tag_format */
 		FALSE, /* convert_char_set */
-		NULL /* user_char_set */
+		NULL, /* user_char_set */
+		FALSE /* disable bitrate update */
 	},
 	/* stream */
 	{
@@ -92,7 +93,7 @@
 static GtkWidget *flac_configurewin = NULL;
 static GtkWidget *vbox, *notebook;
 
-static GtkWidget *title_tag_override, *title_tag_box, *title_tag_entry, *title_desc;
+static GtkWidget *title_tag_override, *title_tag_box, *title_tag_entry, *title_desc, *title_disable_bitrate_update;
 static GtkWidget *convert_char_set, *fileCharacterSetEntry, *userCharacterSetEntry;
 static GtkWidget *replaygain_enable, *replaygain_album_mode;
 static GtkWidget *replaygain_preamp_hscale, *replaygain_preamp_label, *replaygain_hard_limit;
@@ -126,12 +127,14 @@
 
 	(void)widget, (void)data; /* unused arguments */
 	g_free(flac_cfg.title.tag_format);
+	g_free(flac_cfg.title.user_char_set);
 	flac_cfg.title.tag_format = g_strdup(gtk_entry_get_text(GTK_ENTRY(title_tag_entry)));
-	flac_cfg.title.user_char_set = Charset_Get_Name_From_Title(gtk_entry_get_text_1(userCharacterSetEntry));
+	flac_cfg.title.user_char_set = g_strdup(Charset_Get_Name_From_Title(gtk_entry_get_text_1(userCharacterSetEntry)));
 
 	db = bmp_cfg_db_open();
 	/* title */
 	bmp_cfg_db_set_bool(db, "flac", "title.tag_override", flac_cfg.title.tag_override);
+	bmp_cfg_db_set_bool(db, "flac", "title.disable_bitrate_update", flac_cfg.title.disable_bitrate_update);
 	bmp_cfg_db_set_string(db, "flac", "title.tag_format", flac_cfg.title.tag_format);
 	bmp_cfg_db_set_bool(db, "flac", "title.convert_char_set", flac_cfg.title.convert_char_set);
 	bmp_cfg_db_set_string(db, "flac", "title.user_char_set", flac_cfg.title.user_char_set);
@@ -198,6 +201,12 @@
 	gtk_widget_set_sensitive(userCharacterSetEntry, flac_cfg.title.convert_char_set);
 }
 
+static void disable_bitrate_update_cb(GtkWidget *widget, gpointer data)
+{
+	(void)widget, (void)data; /* unused arguments */
+	flac_cfg.title.disable_bitrate_update = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(title_disable_bitrate_update));
+}
+
 static void replaygain_enable_cb(GtkWidget *widget, gpointer data)
 {
 	(void)widget, (void)data; /* unused arguments */
@@ -378,6 +387,12 @@
 	gtk_widget_set_sensitive(title_desc, flac_cfg.title.tag_override);
 	gtk_box_pack_start(GTK_BOX(title_tag_vbox), title_desc, FALSE, FALSE, 0);
 
+	gtk_box_pack_start(GTK_BOX(title_tag_vbox), gtk_hseparator_new(), FALSE, FALSE, 0);
+	title_disable_bitrate_update = gtk_check_button_new_with_label(_("Disable bitrate update during playback (saves cpu)"));
+	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(title_disable_bitrate_update), flac_cfg.title.disable_bitrate_update);
+	gtk_signal_connect(GTK_OBJECT(title_disable_bitrate_update), "clicked", (GCallback)disable_bitrate_update_cb, NULL);
+	gtk_box_pack_start(GTK_BOX(title_tag_vbox), title_disable_bitrate_update, FALSE, FALSE, 0);
+
 	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), title_frame, gtk_label_new(_("Title")));
 
 	/* Output config.. */
--- a/src/flac113/configure.h	Sun Jan 21 16:03:30 2007 -0800
+++ b/src/flac113/configure.h	Sun Jan 21 16:08:19 2007 -0800
@@ -29,6 +29,7 @@
 		gchar *tag_format;
 		gboolean convert_char_set;
 		gchar *user_char_set;
+		gboolean disable_bitrate_update;
 	} title;
 
 	struct {
--- a/src/flac113/plugin.c	Sun Jan 21 16:03:30 2007 -0800
+++ b/src/flac113/plugin.c	Sun Jan 21 16:08:19 2007 -0800
@@ -213,6 +213,8 @@
 
 	bmp_cfg_db_get_bool(db, "flac", "title.tag_override", &flac_cfg.title.tag_override);
 
+	bmp_cfg_db_get_bool(db, "flac", "title.disable_bitrate_update", &flac_cfg.title.disable_bitrate_update);
+
 	if(!bmp_cfg_db_get_string(db, "flac", "title.tag_format", &flac_cfg.title.tag_format))
 		flac_cfg.title.tag_format = g_strdup("%p - %t");
 
@@ -419,28 +421,28 @@
     flac_ip.description = NULL;
 
     if (flac_cfg.title.tag_format) {
-        free(flac_cfg.title.tag_format);
+        g_free(flac_cfg.title.tag_format);
         flac_cfg.title.tag_format = NULL;
     }
 
     if (flac_cfg.title.user_char_set) {
-        free(flac_cfg.title.user_char_set);
+        g_free(flac_cfg.title.user_char_set);
         flac_cfg.title.user_char_set = NULL;
     }
 
     if (flac_cfg.stream.proxy_host) {
-        free(flac_cfg.stream.proxy_host);
+        g_free(flac_cfg.stream.proxy_host);
         flac_cfg.stream.proxy_host = NULL;
     }
 
     if (flac_cfg.stream.proxy_user) {
-        free(flac_cfg.stream.proxy_user);
+        g_free(flac_cfg.stream.proxy_user);
         flac_cfg.stream.proxy_user = NULL;
 
     }
 
     if (flac_cfg.stream.proxy_pass) {
-        free(flac_cfg.stream.proxy_pass);
+        g_free(flac_cfg.stream.proxy_pass);
         flac_cfg.stream.proxy_pass = NULL;
     }
 
@@ -581,7 +583,8 @@
 			}
 			stream_data_.seek_to_in_sec = -1;
 		}
-		else {
+		else if ( !flac_cfg.title.disable_bitrate_update )
+		{
 			/* display the right bitrate from history */
 			unsigned bh_index_o = flac_ip.output->output_time() / BITRATE_HIST_SEGMENT_MSEC % BITRATE_HIST_SIZE;
 			if(bh_index_o != bh_index_last_o && bh_index_o != bh_index_last_w && bh_index_o != (bh_index_last_w + 1) % BITRATE_HIST_SIZE) {