[Xfce4-commits] <parole:gst1.0> Revert "Enhanced audio cover image loading, scale proportionally, store at the largest used image size."
Sean Davis
noreply at xfce.org
Sun Jan 13 04:04:01 CET 2013
Updating branch refs/heads/gst1.0
to 694efbec50d7e7ad4a5fd20ea00c33b429a7ce7c (commit)
from 9dcfad1d54c334a41de562bdcb35c016a88a7a01 (commit)
commit 694efbec50d7e7ad4a5fd20ea00c33b429a7ce7c
Author: Sean Davis <smd.seandavis at gmail.com>
Date: Sat Jan 12 21:34:07 2013 -0500
Revert "Enhanced audio cover image loading, scale proportionally, store at the largest used image size."
This reverts commit 4ab76cf0adabd644355fb9a7270374f9233f325f.
src/gst/parole-gst.c | 173 ++++++++++++++++++++------------------------------
src/parole-player.c | 6 +-
2 files changed, 72 insertions(+), 107 deletions(-)
diff --git a/src/gst/parole-gst.c b/src/gst/parole-gst.c
index ecb416c..65bbc75 100644
--- a/src/gst/parole-gst.c
+++ b/src/gst/parole-gst.c
@@ -69,9 +69,7 @@ static void parole_gst_change_state (ParoleGst *gst,
static void parole_gst_terminate_internal (ParoleGst *gst,
gboolean fade_sound);
-static GdkPixbuf * parole_gst_tag_list_get_cover_external (ParoleGst *gst);
-
-static GdkPixbuf * parole_gst_tag_list_get_cover_embedded (ParoleGst *gst, GstTagList *tag_list);
+static gchar * parole_gst_tag_list_get_cover_external (ParoleGst *gst);
static GdkPixbuf * parole_gst_tag_list_get_cover (ParoleGst *gst, GstTagList *tag_list);
@@ -1108,11 +1106,9 @@ parole_gst_buffer_to_pixbuf (GstBuffer *buffer)
return pixbuf;
}
-GdkPixbuf *
+gchar *
parole_gst_tag_list_get_cover_external (ParoleGst *gst)
{
- GdkPixbuf *pixbuf;
- GError *err = NULL;
gchar *uri;
gchar *filename;
gchar *directory;
@@ -1163,129 +1159,96 @@ parole_gst_tag_list_get_cover_external (ParoleGst *gst)
g_free(directory);
g_free(file_dir);
g_free(lower);
-
- if (!cover_filename)
- return NULL;
-
- pixbuf = gdk_pixbuf_new_from_file(cover_filename, &err);
- g_free(cover_filename);
- if (err)
- {
- g_object_unref(pixbuf);
- g_error_free(err);
- return NULL;
- }
- return pixbuf;
+ return cover_filename;
}
-GdkPixbuf *
-parole_gst_tag_list_get_cover_embedded (ParoleGst *gst, GstTagList *tag_list)
+static const GValue *
+parole_gst_tag_list_get_cover_real (GstTagList *tag_list)
{
- GdkPixbuf *pixbuf;
- const GValue *cover_value = NULL;
- guint i;
+ const GValue *cover_value = NULL;
+ guint i;
- for (i = 0; ; i++) {
- const GValue *value;
+ for (i = 0; ; i++) {
+ const GValue *value;
#if GST_CHECK_VERSION(1, 0, 0)
- GstSample *sample;
+ GstSample *sample;
#else
- GstBuffer *buffer;
+ GstBuffer *buffer;
#endif
- GstStructure *caps_struct;
- int type;
+ GstStructure *caps_struct;
+ int type;
- value = gst_tag_list_get_value_index (tag_list,
- GST_TAG_IMAGE,
- i);
- if (value == NULL)
- break;
+ value = gst_tag_list_get_value_index (tag_list,
+ GST_TAG_IMAGE,
+ i);
+ if (value == NULL)
+ break;
#if GST_CHECK_VERSION(1, 0, 0)
- sample = gst_value_get_sample (value);
- caps_struct = gst_caps_get_structure (gst_sample_get_caps(sample), 0);
+ sample = gst_value_get_sample (value);
+ caps_struct = gst_caps_get_structure (gst_sample_get_caps(sample), 0);
#else
- buffer = gst_value_get_buffer (value);
- caps_struct = gst_caps_get_structure (buffer->caps, 0);
+ buffer = gst_value_get_buffer (value);
+ caps_struct = gst_caps_get_structure (buffer->caps, 0);
#endif
- gst_structure_get_enum (caps_struct,
- "image-type",
- GST_TYPE_TAG_IMAGE_TYPE,
- &type);
- if (type == GST_TAG_IMAGE_TYPE_UNDEFINED) {
- if (cover_value == NULL)
- cover_value = value;
- } else if (type == GST_TAG_IMAGE_TYPE_FRONT_COVER) {
- cover_value = value;
- break;
- }
- }
-
- if (!cover_value) {
- cover_value = gst_tag_list_get_value_index (tag_list,
- GST_TAG_PREVIEW_IMAGE,
- 0);
+ gst_structure_get_enum (caps_struct,
+ "image-type",
+ GST_TYPE_TAG_IMAGE_TYPE,
+ &type);
+ if (type == GST_TAG_IMAGE_TYPE_UNDEFINED) {
+ if (cover_value == NULL)
+ cover_value = value;
+ } else if (type == GST_TAG_IMAGE_TYPE_FRONT_COVER) {
+ cover_value = value;
+ break;
}
+ }
- if (cover_value) {
-#if GST_CHECK_VERSION(1, 0, 0)
- GstSample *sample;
- sample = gst_value_get_sample (cover_value);
- pixbuf = parole_gst_buffer_to_pixbuf (gst_sample_get_buffer (sample));
-#else
- GstBuffer *buffer;
- buffer = gst_value_get_buffer (cover_value);
- pixbuf = parole_gst_buffer_to_pixbuf (buffer);
-#endif
- return pixbuf;
- }
- return NULL;
+ return cover_value;
}
GdkPixbuf *
parole_gst_tag_list_get_cover (ParoleGst *gst, GstTagList *tag_list)
{
- GdkPixbuf *pixbuf;
- GdkPixbuf *scaled;
- gint height, width;
- gfloat multiplier;
+ gchar *cover_filename;
+ const GValue *cover_value;
- g_return_val_if_fail (tag_list != NULL, FALSE);
-
- pixbuf = parole_gst_tag_list_get_cover_external(gst);
- if (!pixbuf)
- {
- pixbuf = parole_gst_tag_list_get_cover_embedded(gst, tag_list);
- if (!pixbuf)
- return NULL;
- }
+ g_return_val_if_fail (tag_list != NULL, FALSE);
+
+ cover_filename = parole_gst_tag_list_get_cover_external(gst);
+ if (cover_filename)
+ {
+ GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file_at_size(cover_filename, 256, 256, NULL);
+ if (pixbuf)
+ return pixbuf;
+ }
- if (gdk_pixbuf_get_width(pixbuf) == gdk_pixbuf_get_height(pixbuf))
- {
- height = 256;
- width = 256;
- }
- else if (gdk_pixbuf_get_width(pixbuf) < gdk_pixbuf_get_height(pixbuf))
- {
- multiplier = gdk_pixbuf_get_height(pixbuf)/256.0;
- height = 256;
- width = gdk_pixbuf_get_width(pixbuf) / multiplier;
- }
- else
- {
- multiplier = gdk_pixbuf_get_width(pixbuf)/256.0;
- height = gdk_pixbuf_get_height(pixbuf)/multiplier;
- width = 256;
- }
+ cover_value = parole_gst_tag_list_get_cover_real (tag_list);
+ /* Fallback to preview */
+ if (!cover_value) {
+ cover_value = gst_tag_list_get_value_index (tag_list,
+ GST_TAG_PREVIEW_IMAGE,
+ 0);
+ }
+
+ if (cover_value) {
+ GdkPixbuf *pixbuf;
- scaled = gdk_pixbuf_scale_simple (pixbuf,
- width,
- height,
- GDK_INTERP_HYPER);
+#if GST_CHECK_VERSION(1, 0, 0)
+ GstSample *sample;
+ sample = gst_value_get_sample (cover_value);
+ pixbuf = parole_gst_buffer_to_pixbuf (gst_sample_get_buffer (sample));
+#else
+ GstBuffer *buffer;
+ buffer = gst_value_get_buffer (cover_value);
+ pixbuf = parole_gst_buffer_to_pixbuf (buffer);
+#endif
+
+ return pixbuf;
+ }
- g_object_unref(pixbuf);
- return scaled;
+ return NULL;
}
static void
diff --git a/src/parole-player.c b/src/parole-player.c
index de90e7c..9f59e8f 100644
--- a/src/parole-player.c
+++ b/src/parole-player.c
@@ -1683,7 +1683,7 @@ parole_player_media_tag_cb (ParoleGst *gst, const ParoleStream *stream, ParolePl
gchar *album;
gchar *artist;
gchar *year;
- GdkPixbuf *image = NULL;
+ GdkPixbuf *image = NULL, *cover = NULL;
if ( player->priv->row )
{
@@ -1730,7 +1730,9 @@ parole_player_media_tag_cb (ParoleGst *gst, const ParoleStream *stream, ParolePl
image = parole_stream_get_image(G_OBJECT(stream));
if (image)
{
- gtk_image_set_from_pixbuf(GTK_IMAGE(player->priv->audiobox_cover), image);
+ cover = gdk_pixbuf_scale_simple(image, 256, 256, GDK_INTERP_BILINEAR);
+ gtk_image_set_from_pixbuf(GTK_IMAGE(player->priv->audiobox_cover), cover);
+ g_object_unref(cover);
g_object_unref(image);
}
else
More information about the Xfce4-commits
mailing list