--- Begin Message ---
- To: submit@bugs.debian.org
- Subject: Please apply vorbis tag encoding patch
- From: Takuo KITAME <kitame@debian.org>
- Date: Tue, 08 Feb 2005 18:39:55 +0900
- Message-id: <1107855595.3951.7.camel@localhost>
Package: beep-media-player
Severity: wishlist
tags: patch
The attached patch is similar to mpg123's id3tag_encoding support.
Please apply it.
Regards.
--
Takuo KITAME
diff -Nur beep-media-player-0.9.7/Input/vorbis/configure.c beep-media-player-0.9.7.p/Input/vorbis/configure.c
--- beep-media-player-0.9.7/Input/vorbis/configure.c 2005-02-08 18:14:26.000000000 +0900
+++ beep-media-player-0.9.7.p/Input/vorbis/configure.c 2005-02-08 18:00:52.000000000 +0900
@@ -36,6 +36,9 @@
*title_desc;
static GtkWidget *rg_switch, *rg_clip_switch, *rg_booster_switch,
*rg_track_gain;
+/* Encoding patch */
+static GtkWidget *title_encoding_hbox, *title_encoding_enabled, *title_encoding, *title_encoding_label;
+/* Encoding patch */
vorbis_config_t vorbis_cfg;
@@ -102,7 +105,10 @@
vorbis_cfg.replaygain_mode = REPLAYGAIN_MODE_TRACK;
else
vorbis_cfg.replaygain_mode = REPLAYGAIN_MODE_ALBUM;
-
+ /* Encoding patch */
+ vorbis_cfg.title_encoding_enabled = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(title_encoding_enabled));
+ vorbis_cfg.title_encoding = g_strdup(gtk_entry_get_text(GTK_ENTRY(title_encoding)));
+ /* Encoding patch */
db = bmp_cfg_db_open();
@@ -140,6 +146,10 @@
bmp_cfg_db_set_int(db, "vorbis", "replaygain_mode",
vorbis_cfg.replaygain_mode);
bmp_cfg_db_set_bool(db, "vorbis", "use_booster", vorbis_cfg.use_booster);
+ /* Encoding patch */
+ bmp_cfg_db_set_bool(db, "vorbis", "title_encoding_enabled", vorbis_cfg.title_encoding_enabled);
+ bmp_cfg_db_set_string(db, "vorbis", "title_encoding", vorbis_cfg.title_encoding);
+ /* Encoding patch */
bmp_cfg_db_close(db);
gtk_widget_destroy(vorbis_configurewin);
}
@@ -230,6 +240,17 @@
gtk_widget_set_sensitive(title_desc, override);
}
+/* Encoding patch */
+static void
+title_encoding_enabled_cb(GtkWidget * w, gpointer data)
+{
+ gboolean encoding_enabled;
+ encoding_enabled =
+ gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(title_encoding_enabled));
+ gtk_widget_set_sensitive(title_encoding_hbox, encoding_enabled);
+}
+/* Encoding patch */
+
static void
rg_switch_cb(GtkWidget * w, gpointer data)
{
@@ -468,6 +489,31 @@
gtk_container_border_width(GTK_CONTAINER(title_tag_vbox), 5);
gtk_container_add(GTK_CONTAINER(title_frame), title_tag_vbox);
+ /* Encoding patch */
+ title_encoding_enabled =
+ gtk_check_button_new_with_label(_("Convert non-UTF8 Vorbis tags to UTF8"));
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(title_encoding_enabled),
+ vorbis_cfg.title_encoding_enabled);
+ g_signal_connect(G_OBJECT(title_encoding_enabled), "clicked",
+ G_CALLBACK(title_encoding_enabled_cb), NULL);
+ gtk_box_pack_start(GTK_BOX(title_tag_vbox), title_encoding_enabled, FALSE,
+ FALSE, 0);
+
+ title_encoding_hbox = gtk_hbox_new(FALSE, 5);
+ gtk_widget_set_sensitive(title_encoding_hbox, vorbis_cfg.title_encoding_enabled);
+ gtk_box_pack_start(GTK_BOX(title_tag_vbox), title_encoding_hbox, FALSE,
+ FALSE, 0);
+
+ title_encoding_label = gtk_label_new(_("Vorbis encoding:"));
+ gtk_box_pack_start(GTK_BOX(title_encoding_hbox), title_encoding_label, FALSE,
+ FALSE, 0);
+
+ title_encoding = gtk_entry_new();
+ gtk_entry_set_text(GTK_ENTRY(title_encoding), vorbis_cfg.title_encoding);
+ gtk_box_pack_start(GTK_BOX(title_encoding_hbox), title_encoding, TRUE, TRUE,
+ 0);
+ /* Encoding patch */
+
title_tag_override =
gtk_check_button_new_with_label(_("Override generic titles"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(title_tag_override),
diff -Nur beep-media-player-0.9.7/Input/vorbis/vorbis.c beep-media-player-0.9.7.p/Input/vorbis/vorbis.c
--- beep-media-player-0.9.7/Input/vorbis/vorbis.c 2005-02-08 18:14:26.000000000 +0900
+++ beep-media-player-0.9.7.p/Input/vorbis/vorbis.c 2005-02-08 18:21:23.000000000 +0900
@@ -127,6 +127,7 @@
GMutex *vf_mutex;
static gboolean output_error;
+gchar **vorbis_tag_encoding_list = NULL;
InputPlugin *
get_iplugin_info(void)
@@ -547,6 +548,30 @@
return vorbis_ip.output->output_time();
}
+static gchar *
+convert_tag_title(gchar * title)
+{
+ gchar **encoding = vorbis_tag_encoding_list;
+ gchar *new_title = NULL;
+
+ if (g_utf8_validate(title, -1, NULL))
+ return title;
+
+ while (*encoding && !new_title) {
+ new_title = g_convert(title, strlen(title), "UTF-8", *encoding++,
+ NULL, NULL, NULL);
+ }
+
+ if (new_title) {
+ g_free(title);
+ return new_title;
+ }
+
+ /* FIXME: We're relying on BMP core to provide fallback
+ * conversion */
+ return title;
+}
+
static void
vorbis_seek(int time)
{
@@ -586,7 +611,6 @@
*title = NULL;
*title = vorbis_generate_title(&vf, filename);
-
/*
* once the ov_open succeeds, the stream belongs to
* vorbisfile.a. ov_clear will fclose it
@@ -598,6 +622,10 @@
/* streaming song info */
*length = -1;
*title = (char *) vorbis_http_get_title(filename);
+/* Encoding patch */
+ if (vorbis_cfg.title_encoding_enabled)
+ *title = convert_tag_title(*title);
+/* Encoding patch */
}
}
@@ -769,6 +797,10 @@
g_free(input->genre);
g_free(input->comment);
g_free(input);
+/* Encoding patch */
+ if (vorbis_cfg.title_encoding_enabled)
+ displaytitle = convert_tag_title(displaytitle);
+/* Encoding patch */
return displaytitle;
}
@@ -823,6 +855,10 @@
vorbis_cfg.use_replaygain = FALSE;
vorbis_cfg.replaygain_mode = REPLAYGAIN_MODE_TRACK;
vorbis_cfg.use_booster = FALSE;
+/* Encoding patch */
+ vorbis_cfg.title_encoding_enabled = FALSE;
+ vorbis_cfg.title_encoding = NULL;
+/* Encoding patch */
db = bmp_cfg_db_open();
bmp_cfg_db_get_int(db, "vorbis", "http_buffer_size",
@@ -856,6 +892,13 @@
bmp_cfg_db_get_int(db, "vorbis", "replaygain_mode",
&vorbis_cfg.replaygain_mode);
bmp_cfg_db_get_bool(db, "vorbis", "use_booster", &vorbis_cfg.use_booster);
+ /* Encoding patch */
+ bmp_cfg_db_get_bool(db, "vorbis", "title_encoding_enabled", &vorbis_cfg.title_encoding_enabled);
+ bmp_cfg_db_get_string(db, "vorbis", "title_encoding", &vorbis_cfg.title_encoding);
+ if (vorbis_cfg.title_encoding_enabled)
+ vorbis_tag_encoding_list = g_strsplit_set(vorbis_cfg.title_encoding, ENCODING_SEPARATOR, 0);
+
+ /* Encoding patch */
bmp_cfg_db_close(db);
vf_mutex = g_mutex_new();
@@ -864,6 +907,7 @@
static void
vorbis_cleanup(void)
{
+ g_strfreev(vorbis_tag_encoding_list);
g_mutex_free(vf_mutex);
}
diff -Nur beep-media-player-0.9.7/Input/vorbis/vorbis.h beep-media-player-0.9.7.p/Input/vorbis/vorbis.h
--- beep-media-player-0.9.7/Input/vorbis/vorbis.h 2005-02-08 18:14:26.000000000 +0900
+++ beep-media-player-0.9.7.p/Input/vorbis/vorbis.h 2005-02-08 18:15:11.000000000 +0900
@@ -30,6 +30,8 @@
gboolean use_replaygain;
gint replaygain_mode;
gboolean use_booster;
+ gboolean title_encoding_enabled;
+ gchar *title_encoding;
} vorbis_config_t;
enum {
@@ -38,4 +40,6 @@
REPLAYGAIN_MODE_LAST
};
+#define ENCODING_SEPARATOR " ,:;|/"
+
#endif /* __VORBIS_H__ */
--- End Message ---