/* thumbnailer.c generated by valac 0.56.19, the Vala compiler
 * generated from thumbnailer.vala, do not modify */

#include <glib-object.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gdk/gdk.h>
#include <pango/pango.h>
#include <gio/gio.h>
#include <gst/gst.h>
#include <glib/gi18n-lib.h>
#include <float.h>
#include <math.h>

#define G4_THUMBNAILER_GRID_SIZE 160
#define G4_THUMBNAILER_ICON_SIZE 48
#define G4_UNKNOWN_ALBUM _ ("Unknown Album")
#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define G4_TYPE_LRU_CACHE (g4_lru_cache_get_type ())
#define G4_LRU_CACHE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G4_TYPE_LRU_CACHE, G4LruCache))
#define G4_LRU_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), G4_TYPE_LRU_CACHE, G4LruCacheClass))
#define G4_IS_LRU_CACHE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G4_TYPE_LRU_CACHE))
#define G4_IS_LRU_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), G4_TYPE_LRU_CACHE))
#define G4_LRU_CACHE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), G4_TYPE_LRU_CACHE, G4LruCacheClass))

typedef struct _G4LruCache G4LruCache;
typedef struct _G4LruCacheClass G4LruCacheClass;
typedef struct _G4LruCachePrivate G4LruCachePrivate;
enum  {
	G4_LRU_CACHE_0_PROPERTY,
	G4_LRU_CACHE_V_TYPE,
	G4_LRU_CACHE_V_DUP_FUNC,
	G4_LRU_CACHE_V_DESTROY_FUNC,
	G4_LRU_CACHE_NUM_PROPERTIES
};
static GParamSpec* g4_lru_cache_properties[G4_LRU_CACHE_NUM_PROPERTIES];
#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

#define G4_TYPE_THUMBNAILER (g4_thumbnailer_get_type ())
#define G4_THUMBNAILER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G4_TYPE_THUMBNAILER, G4Thumbnailer))
#define G4_THUMBNAILER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), G4_TYPE_THUMBNAILER, G4ThumbnailerClass))
#define G4_IS_THUMBNAILER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G4_TYPE_THUMBNAILER))
#define G4_IS_THUMBNAILER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), G4_TYPE_THUMBNAILER))
#define G4_THUMBNAILER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), G4_TYPE_THUMBNAILER, G4ThumbnailerClass))

typedef struct _G4Thumbnailer G4Thumbnailer;
typedef struct _G4ThumbnailerClass G4ThumbnailerClass;
typedef struct _G4ThumbnailerPrivate G4ThumbnailerPrivate;

#define G4_TYPE_COVER_CACHE (g4_cover_cache_get_type ())
#define G4_COVER_CACHE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G4_TYPE_COVER_CACHE, G4CoverCache))
#define G4_COVER_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), G4_TYPE_COVER_CACHE, G4CoverCacheClass))
#define G4_IS_COVER_CACHE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G4_TYPE_COVER_CACHE))
#define G4_IS_COVER_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), G4_TYPE_COVER_CACHE))
#define G4_COVER_CACHE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), G4_TYPE_COVER_CACHE, G4CoverCacheClass))

typedef struct _G4CoverCache G4CoverCache;
typedef struct _G4CoverCacheClass G4CoverCacheClass;
enum  {
	G4_THUMBNAILER_0_PROPERTY,
	G4_THUMBNAILER_COVER_FINDER_PROPERTY,
	G4_THUMBNAILER_PANGO_CONTEXT_PROPERTY,
	G4_THUMBNAILER_REMOTE_THUMBNAIL_PROPERTY,
	G4_THUMBNAILER_SCALE_FACTOR_PROPERTY,
	G4_THUMBNAILER_NUM_PROPERTIES
};
static GParamSpec* g4_thumbnailer_properties[G4_THUMBNAILER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define G4_TYPE_MUSIC (g4_music_get_type ())
#define G4_MUSIC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G4_TYPE_MUSIC, G4Music))
#define G4_MUSIC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), G4_TYPE_MUSIC, G4MusicClass))
#define G4_IS_MUSIC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G4_TYPE_MUSIC))
#define G4_IS_MUSIC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), G4_TYPE_MUSIC))
#define G4_MUSIC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), G4_TYPE_MUSIC, G4MusicClass))

typedef struct _G4Music G4Music;
typedef struct _G4MusicClass G4MusicClass;
typedef struct _G4ThumbnailerLoadAsyncData G4ThumbnailerLoadAsyncData;
typedef struct _Block67Data Block67Data;
typedef struct _G4MusicPrivate G4MusicPrivate;
typedef gpointer (*G4TaskFunc) (gpointer user_data);
#define _gst_tag_list_unref0(var) ((var == NULL) ? NULL : (var = (gst_tag_list_unref (var), NULL)))
#define _gst_sample_unref0(var) ((var == NULL) ? NULL : (var = (gst_sample_unref (var), NULL)))
typedef struct _G4ThumbnailerLoadDirectlyAsyncData G4ThumbnailerLoadDirectlyAsyncData;

#define G4_TYPE_BASE_PAINTABLE (g4_base_paintable_get_type ())
#define G4_BASE_PAINTABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G4_TYPE_BASE_PAINTABLE, G4BasePaintable))
#define G4_BASE_PAINTABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), G4_TYPE_BASE_PAINTABLE, G4BasePaintableClass))
#define G4_IS_BASE_PAINTABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G4_TYPE_BASE_PAINTABLE))
#define G4_IS_BASE_PAINTABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), G4_TYPE_BASE_PAINTABLE))
#define G4_BASE_PAINTABLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), G4_TYPE_BASE_PAINTABLE, G4BasePaintableClass))

typedef struct _G4BasePaintable G4BasePaintable;
typedef struct _G4BasePaintableClass G4BasePaintableClass;
enum  {
	G4_THUMBNAILER_TAG_UPDATED_SIGNAL,
	G4_THUMBNAILER_NUM_SIGNALS
};
static guint g4_thumbnailer_signals[G4_THUMBNAILER_NUM_SIGNALS] = {0};
#define _g_bytes_unref0(var) ((var == NULL) ? NULL : (var = (g_bytes_unref (var), NULL)))
#define _gst_buffer_unref0(var) ((var == NULL) ? NULL : (var = (gst_buffer_unref (var), NULL)))

struct _G4LruCache {
	GObject parent_instance;
	G4LruCachePrivate * priv;
};

struct _G4LruCacheClass {
	GObjectClass parent_class;
	gsize (*size_of_value) (G4LruCache* self, gconstpointer value);
};

struct _G4LruCachePrivate {
	GType v_type;
	GBoxedCopyFunc v_dup_func;
	GDestroyNotify v_destroy_func;
	gsize _max_size;
	gsize _size;
	GHashTable* _cache;
	GQueue* _queue;
};

struct _G4Thumbnailer {
	GObject parent_instance;
	G4ThumbnailerPrivate * priv;
};

struct _G4ThumbnailerClass {
	GObjectClass parent_class;
};

struct _G4ThumbnailerPrivate {
	GHashTable* _album_covers;
	GRecMutex __lock__album_covers;
	G4LruCache* _album_pixbufs;
	GRecMutex __lock__album_pixbufs;
	G4LruCache* _grid_cache;
	G4LruCache* _icon_cache;
	GQuark _loading_quark;
	G4CoverCache* _cover_finder;
	PangoContext* _pango_context;
	gboolean _remote_thumbnail;
	gint _scale_factor;
};

struct _G4ThumbnailerLoadAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	G4Thumbnailer* self;
	G4Music* music;
	gint size;
	GdkPaintable* result;
	gboolean is_small;
	gboolean _tmp0_;
	GdkPixbuf* pixbuf;
	GdkPixbuf* _tmp1_;
	GdkPaintable* paintable0;
	GdkPaintable* _tmp2_;
	gboolean _tmp3_;
	GdkPaintable* _tmp4_;
	GdkPaintable* _tmp5_;
	GdkPixbuf* _tmp6_;
	GdkPixbuf* _tmp7_;
	GdkTexture* _tmp8_;
	GdkPaintable* _tmp9_;
	GdkPaintable* paintable;
	GdkPaintable* _tmp10_;
	GdkPaintable* _tmp11_;
	gboolean _tmp12_;
	GdkPixbuf* _tmp13_;
	GdkPaintable* _tmp14_;
	GdkPixbuf* minbuf;
	const gchar* _tmp15_;
	const gchar* _tmp16_;
	GdkPixbuf* _tmp17_;
	GdkPixbuf* _tmp18_;
	GdkPixbuf* _tmp19_;
	GdkTexture* _tmp20_;
	GdkTexture* _tmp21_;
};

struct _Block67Data {
	int _ref_count_;
	G4Thumbnailer* self;
	GFile* file;
	gchar* album_key_;
	GstTagList** tags;
	gint tags_length1;
	gint _tags_size_;
	gchar** args;
	gint args_length1;
	gint _args_size_;
	gint size;
	gpointer _async_data_;
};

struct _G4Music {
	GObject parent_instance;
	G4MusicPrivate * priv;
	gchar* album;
	gchar* artist;
	gchar* title;
	gchar* album_artist;
	guint32 date;
	gchar* genre;
	gint track;
	gint disc;
	gboolean has_cover;
	gint64 modified_time;
	gchar* uri;
	gchar* cover_uri;
	gchar* _album_key;
	gchar* _artist_key;
	gchar* _title_key;
	gint _order;
};

struct _G4MusicClass {
	GObjectClass parent_class;
	gchar* (*get_abbreviation) (G4Music* self);
};

struct _G4ThumbnailerLoadDirectlyAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	G4Thumbnailer* self;
	G4Music* music;
	gint size;
	GdkPixbuf* result;
	Block67Data* _data67_;
	const gchar* _tmp0_;
	GFile* _tmp1_;
	gboolean is_native;
	GFile* _tmp2_;
	gboolean _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	const gchar* _tmp7_;
	const gchar* _tmp8_;
	gchar* _tmp9_;
	GstTagList** _tmp10_;
	const gchar* _tmp11_;
	const gchar* _tmp12_;
	const gchar* _tmp13_;
	const gchar* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	gchar* _tmp17_;
	gchar** _tmp18_;
	GdkPixbuf* pixbuf;
	GFile* _tmp19_;
	gpointer _tmp20_;
	gboolean _tmp21_;
	gboolean _tmp22_;
	GstTagList** _tmp23_;
	gint _tmp23__length1;
	GstTagList* _tmp24_;
	GstTagList** _tmp25_;
	gint _tmp25__length1;
	GstTagList* _tmp26_;
	const gchar* _tmp27_;
	const gchar* _tmp28_;
	gchar** _tmp29_;
	gint _tmp29__length1;
	const gchar* _tmp30_;
	gchar** _tmp31_;
	gint _tmp31__length1;
	const gchar* _tmp32_;
	gchar** _tmp33_;
	gint _tmp33__length1;
	const gchar* _tmp34_;
	gint _tmp35_;
	gint _tmp36_;
	gchar** _tmp37_;
	gint _tmp37__length1;
	const gchar* _tmp38_;
	gchar* _tmp39_;
};

static gint G4LruCache_private_offset;
static gpointer g4_lru_cache_parent_class = NULL;
static gint G4Thumbnailer_private_offset;
static gpointer g4_thumbnailer_parent_class = NULL;

VALA_EXTERN GType g4_lru_cache_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (G4LruCache, g_object_unref)
VALA_EXTERN gsize g4_lru_cache_size_of_value (G4LruCache* self,
                                  gconstpointer value);
static void _g_free0_ (gpointer var);
static inline void _g_queue_free__g_free0_ (GQueue* self);
VALA_EXTERN G4LruCache* g4_lru_cache_new (GType v_type,
                              GBoxedCopyFunc v_dup_func,
                              GDestroyNotify v_destroy_func,
                              gsize max_size);
VALA_EXTERN G4LruCache* g4_lru_cache_construct (GType object_type,
                                    GType v_type,
                                    GBoxedCopyFunc v_dup_func,
                                    GDestroyNotify v_destroy_func,
                                    gsize max_size);
VALA_EXTERN gpointer g4_lru_cache_find (G4LruCache* self,
                            const gchar* key);
VALA_EXTERN void g4_lru_cache_put (G4LruCache* self,
                       const gchar* key,
                       gconstpointer value,
                       gboolean replace);
VALA_EXTERN gboolean g4_lru_cache_remove (G4LruCache* self,
                              const gchar* key);
VALA_EXTERN void g4_lru_cache_remove_all (G4LruCache* self);
static gsize g4_lru_cache_real_size_of_value (G4LruCache* self,
                                       gconstpointer value);
static void g4_lru_cache_finalize (GObject * obj);
static GType g4_lru_cache_get_type_once (void);
static void _vala_g4_lru_cache_get_property (GObject * object,
                                      guint property_id,
                                      GValue * value,
                                      GParamSpec * pspec);
static void _vala_g4_lru_cache_set_property (GObject * object,
                                      guint property_id,
                                      const GValue * value,
                                      GParamSpec * pspec);
VALA_EXTERN GType g4_thumbnailer_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (G4Thumbnailer, g_object_unref)
VALA_EXTERN GType g4_cover_cache_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (G4CoverCache, g_object_unref)
VALA_EXTERN GType g4_music_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (G4Music, g_object_unref)
VALA_EXTERN GdkPaintable* g4_thumbnailer_find (G4Thumbnailer* self,
                                   G4Music* music,
                                   gint size);
VALA_EXTERN const gchar* g4_music_get_cover_key (G4Music* self);
VALA_EXTERN void g4_thumbnailer_put (G4Thumbnailer* self,
                         G4Music* music,
                         GdkPaintable* paintable,
                         gboolean replace,
                         gint size);
static void g4_thumbnailer_load_async_data_free (gpointer _data);
VALA_EXTERN void g4_thumbnailer_load_async (G4Thumbnailer* self,
                                G4Music* music,
                                gint size,
                                GAsyncReadyCallback _callback_,
                                gpointer _user_data_);
VALA_EXTERN GdkPaintable* g4_thumbnailer_load_finish (G4Thumbnailer* self,
                                          GAsyncResult* _res_);
static gboolean g4_thumbnailer_load_async_co (G4ThumbnailerLoadAsyncData* _data_);
VALA_EXTERN void g4_thumbnailer_load_directly_async (G4Thumbnailer* self,
                                         G4Music* music,
                                         gint size,
                                         GAsyncReadyCallback _callback_,
                                         gpointer _user_data_);
VALA_EXTERN GdkPixbuf* g4_thumbnailer_load_directly_finish (G4Thumbnailer* self,
                                                GAsyncResult* _res_);
static void g4_thumbnailer_load_async_ready (GObject* source_object,
                                      GAsyncResult* _res_,
                                      gpointer _user_data_);
VALA_EXTERN GdkPaintable* g4_thumbnailer_create_music_text_paintable (G4Thumbnailer* self,
                                                          G4Music* music);
static GdkPixbuf* g4_thumbnailer_find_pixbuf_from_cache (G4Thumbnailer* self,
                                                  const gchar* cover_key);
static void g4_thumbnailer_load_directly_async_data_free (gpointer _data);
static gboolean g4_thumbnailer_load_directly_async_co (G4ThumbnailerLoadDirectlyAsyncData* _data_);
static Block67Data* block67_data_ref (Block67Data* _data67_);
static void block67_data_unref (void * _userdata_);
VALA_EXTERN const gchar* g4_music_get_album_key (G4Music* self);
VALA_EXTERN gchar* g4_music_get_abbreviation (G4Music* self);
VALA_EXTERN void g4_run_async (GType v_type,
                   GBoxedCopyFunc v_dup_func,
                   GDestroyNotify v_destroy_func,
                   G4TaskFunc task,
                   gpointer task_target,
                   gboolean front,
                   gboolean in_single_pool,
                   GAsyncReadyCallback _callback_,
                   gpointer _user_data_);
VALA_EXTERN gpointer g4_run_finish (GAsyncResult* _res_);
static GdkPixbuf* __lambda42_ (Block67Data* _data67_);
VALA_EXTERN GstTagList* g4_parse_gst_tags (GFile* file);
VALA_EXTERN GstSample* g4_parse_image_from_tag_list (GstTagList* tags);
static gsize* _size_t_dup (gsize* self);
static void g4_thumbnailer_check_same_album_cover (G4Thumbnailer* self,
                                            const gchar* album_key,
                                            gchar** cover_key);
VALA_EXTERN GdkPixbuf* g4_load_clamp_pixbuf_from_sample (GstSample* sample,
                                             gint size);
VALA_EXTERN GFile* g4_cover_cache_find (G4CoverCache* self,
                            GFile* parent);
VALA_EXTERN GdkPixbuf* g4_load_clamp_pixbuf_from_file (GFile* file,
                                           gint size);
VALA_EXTERN GdkPixbuf* g4_create_clamp_pixbuf (GdkPixbuf* pixbuf,
                                   gint size);
static void g4_thumbnailer_put_pixbuf_to_cache (G4Thumbnailer* self,
                                         const gchar* cover_key,
                                         GdkPixbuf* pixbuf);
static gpointer ___lambda42__g4_task_func (gpointer self);
static void g4_thumbnailer_load_directly_async_ready (GObject* source_object,
                                               GAsyncResult* _res_,
                                               gpointer _user_data_);
VALA_EXTERN gboolean g4_music_from_gst_tags (G4Music* self,
                                 GstTagList* tags);
VALA_EXTERN void g4_music_set_cover_key (G4Music* self,
                             const gchar* value);
VALA_EXTERN GdkPaintable* g4_thumbnailer_create_simple_text_paintable (G4Thumbnailer* self,
                                                           const gchar* text,
                                                           gint size,
                                                           guint color_index);
VALA_EXTERN gchar* g4_thumbnailer_create_music_text_svg (G4Thumbnailer* self,
                                             G4Music* music);
VALA_EXTERN gchar* g4_create_text_svg (PangoContext* context,
                           const gchar* text,
                           guint color_index);
VALA_EXTERN GdkPaintable* g4_create_text_paintable (PangoContext* context,
                                        const gchar* text,
                                        gint width,
                                        gint height,
                                        guint color_index);
VALA_EXTERN G4BasePaintable* g4_base_paintable_new (GdkPaintable* paintable);
VALA_EXTERN G4BasePaintable* g4_base_paintable_construct (GType object_type,
                                              GdkPaintable* paintable);
VALA_EXTERN GType g4_base_paintable_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (G4BasePaintable, g_object_unref)
VALA_EXTERN G4Thumbnailer* g4_thumbnailer_new (void);
VALA_EXTERN G4Thumbnailer* g4_thumbnailer_construct (GType object_type);
VALA_EXTERN G4CoverCache* g4_thumbnailer_get_cover_finder (G4Thumbnailer* self);
VALA_EXTERN void g4_thumbnailer_set_cover_finder (G4Thumbnailer* self,
                                      G4CoverCache* value);
VALA_EXTERN PangoContext* g4_thumbnailer_get_pango_context (G4Thumbnailer* self);
VALA_EXTERN void g4_thumbnailer_set_pango_context (G4Thumbnailer* self,
                                       PangoContext* value);
VALA_EXTERN gboolean g4_thumbnailer_get_remote_thumbnail (G4Thumbnailer* self);
VALA_EXTERN void g4_thumbnailer_set_remote_thumbnail (G4Thumbnailer* self,
                                          gboolean value);
VALA_EXTERN gint g4_thumbnailer_get_scale_factor (G4Thumbnailer* self);
VALA_EXTERN void g4_thumbnailer_set_scale_factor (G4Thumbnailer* self,
                                      gint value);
static void g4_thumbnailer_finalize (GObject * obj);
static GType g4_thumbnailer_get_type_once (void);
static void _vala_g4_thumbnailer_get_property (GObject * object,
                                        guint property_id,
                                        GValue * value,
                                        GParamSpec * pspec);
static void _vala_g4_thumbnailer_set_property (GObject * object,
                                        guint property_id,
                                        const GValue * value,
                                        GParamSpec * pspec);
static GstMapInfo* _gst_map_info_dup (GstMapInfo* self);
static gboolean* _bool_dup (gboolean* self);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

VALA_EXTERN const guint32 G4_BACKGROUND_COLORS[28];

static inline gpointer
g4_lru_cache_get_instance_private (G4LruCache* self)
{
	return G_STRUCT_MEMBER_P (self, G4LruCache_private_offset);
}

static void
_g_free0_ (gpointer var)
{
	var = (g_free (var), NULL);
}

static inline void
_g_queue_free__g_free0_ (GQueue* self)
{
	g_queue_free_full (self, (GDestroyNotify) _g_free0_);
}

G4LruCache*
g4_lru_cache_construct (GType object_type,
                        GType v_type,
                        GBoxedCopyFunc v_dup_func,
                        GDestroyNotify v_destroy_func,
                        gsize max_size)
{
	G4LruCache * self = NULL;
	self = (G4LruCache*) g_object_new (object_type, "v-type", v_type, "v-dup-func", v_dup_func, "v-destroy-func", v_destroy_func, NULL);
	self->priv->v_type = v_type;
	self->priv->v_dup_func = v_dup_func;
	self->priv->v_destroy_func = v_destroy_func;
	self->priv->_max_size = max_size;
	return self;
}

G4LruCache*
g4_lru_cache_new (GType v_type,
                  GBoxedCopyFunc v_dup_func,
                  GDestroyNotify v_destroy_func,
                  gsize max_size)
{
	return g4_lru_cache_construct (G4_TYPE_LRU_CACHE, v_type, v_dup_func, v_destroy_func, max_size);
}

gpointer
g4_lru_cache_find (G4LruCache* self,
                   const gchar* key)
{
	GHashTable* _tmp0_;
	gconstpointer _tmp1_;
	gpointer _tmp2_;
	gpointer result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (key != NULL, NULL);
	_tmp0_ = self->priv->_cache;
	_tmp1_ = g_hash_table_lookup (_tmp0_, key);
	_tmp2_ = ((_tmp1_ != NULL) && (self->priv->v_dup_func != NULL)) ? self->priv->v_dup_func ((gpointer) _tmp1_) : ((gpointer) _tmp1_);
	result = _tmp2_;
	return result;
}

void
g4_lru_cache_put (G4LruCache* self,
                  const gchar* key,
                  gconstpointer value,
                  gboolean replace)
{
	gsize size = 0UL;
	GHashTable* _tmp12_;
	gchar* _tmp13_;
	gpointer _tmp14_;
	GQueue* _tmp15_;
	gchar* _tmp16_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (key != NULL);
	if (replace) {
		g4_lru_cache_remove (self, key);
	} else {
		GHashTable* _tmp0_;
		_tmp0_ = self->priv->_cache;
		if (g_hash_table_contains (_tmp0_, key)) {
			return;
		}
	}
	size = g4_lru_cache_size_of_value (self, value);
	while (TRUE) {
		gboolean _tmp1_ = FALSE;
		gchar* stolen_key = NULL;
		gpointer stolen_value = NULL;
		GHashTable* _tmp3_;
		GQueue* _tmp4_;
		gpointer _tmp5_;
		gchar* _tmp6_;
		gpointer _tmp7_ = NULL;
		gpointer _tmp8_ = NULL;
		gboolean _tmp9_;
		gboolean _tmp10_;
		if ((self->priv->_size + size) > self->priv->_max_size) {
			GQueue* _tmp2_;
			_tmp2_ = self->priv->_queue;
			_tmp1_ = _tmp2_->length > ((guint) 0);
		} else {
			_tmp1_ = FALSE;
		}
		if (!_tmp1_) {
			break;
		}
		_tmp3_ = self->priv->_cache;
		_tmp4_ = self->priv->_queue;
		_tmp5_ = g_queue_pop_head (_tmp4_);
		_tmp6_ = (gchar*) _tmp5_;
		_tmp9_ = g_hash_table_steal_extended (_tmp3_, _tmp6_, &_tmp7_, &_tmp8_);
		_g_free0 (stolen_key);
		stolen_key = (gchar*) _tmp7_;
		((stolen_value == NULL) || (self->priv->v_destroy_func == NULL)) ? NULL : (stolen_value = (self->priv->v_destroy_func (stolen_value), NULL));
		stolen_value = _tmp8_;
		_tmp10_ = _tmp9_;
		_g_free0 (_tmp6_);
		if (_tmp10_) {
			gconstpointer _tmp11_;
			_tmp11_ = stolen_value;
			self->priv->_size = self->priv->_size - g4_lru_cache_size_of_value (self, _tmp11_);
		}
		((stolen_value == NULL) || (self->priv->v_destroy_func == NULL)) ? NULL : (stolen_value = (self->priv->v_destroy_func (stolen_value), NULL));
		_g_free0 (stolen_key);
	}
	_tmp12_ = self->priv->_cache;
	_tmp13_ = g_strdup (key);
	_tmp14_ = ((value != NULL) && (self->priv->v_dup_func != NULL)) ? self->priv->v_dup_func ((gpointer) value) : ((gpointer) value);
	g_hash_table_insert (_tmp12_, _tmp13_, _tmp14_);
	_tmp15_ = self->priv->_queue;
	_tmp16_ = g_strdup (key);
	g_queue_push_tail (_tmp15_, _tmp16_);
	self->priv->_size = self->priv->_size + size;
}

gboolean
g4_lru_cache_remove (G4LruCache* self,
                     const gchar* key)
{
	gchar* stolen_key = NULL;
	gpointer stolen_value = NULL;
	GHashTable* _tmp0_;
	gpointer _tmp1_ = NULL;
	gpointer _tmp2_ = NULL;
	gboolean _tmp3_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (key != NULL, FALSE);
	_tmp0_ = self->priv->_cache;
	_tmp3_ = g_hash_table_steal_extended (_tmp0_, key, &_tmp1_, &_tmp2_);
	_g_free0 (stolen_key);
	stolen_key = (gchar*) _tmp1_;
	((stolen_value == NULL) || (self->priv->v_destroy_func == NULL)) ? NULL : (stolen_value = (self->priv->v_destroy_func (stolen_value), NULL));
	stolen_value = _tmp2_;
	if (_tmp3_) {
		GList* link = NULL;
		GQueue* _tmp4_;
		GCompareFunc _tmp5_;
		GList* _tmp6_;
		GList* _tmp7_;
		gconstpointer _tmp10_;
		_tmp4_ = self->priv->_queue;
		_tmp5_ = ((GCompareFunc) g_strcmp0);
		_tmp6_ = g_queue_find_custom (_tmp4_, key, _tmp5_);
		link = _tmp6_;
		_tmp7_ = link;
		if (_tmp7_ != ((GList*) NULL)) {
			GQueue* _tmp8_;
			GList* _tmp9_;
			_tmp8_ = self->priv->_queue;
			_tmp9_ = link;
			g_queue_unlink (_tmp8_, _tmp9_);
		}
		_tmp10_ = stolen_value;
		self->priv->_size = self->priv->_size - g4_lru_cache_size_of_value (self, _tmp10_);
		result = TRUE;
		((stolen_value == NULL) || (self->priv->v_destroy_func == NULL)) ? NULL : (stolen_value = (self->priv->v_destroy_func (stolen_value), NULL));
		_g_free0 (stolen_key);
		return result;
	}
	result = FALSE;
	((stolen_value == NULL) || (self->priv->v_destroy_func == NULL)) ? NULL : (stolen_value = (self->priv->v_destroy_func (stolen_value), NULL));
	_g_free0 (stolen_key);
	return result;
}

void
g4_lru_cache_remove_all (G4LruCache* self)
{
	GHashTable* _tmp0_;
	GQueue* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_cache;
	g_hash_table_remove_all (_tmp0_);
	_tmp1_ = self->priv->_queue;
	g_queue_clear (_tmp1_);
	self->priv->_size = (gsize) 0;
}

static gsize
g4_lru_cache_real_size_of_value (G4LruCache* self,
                                 gconstpointer value)
{
	gsize result;
	result = (gsize) 1;
	return result;
}

gsize
g4_lru_cache_size_of_value (G4LruCache* self,
                            gconstpointer value)
{
	G4LruCacheClass* _klass_;
	g_return_val_if_fail (self != NULL, 0UL);
	_klass_ = G4_LRU_CACHE_GET_CLASS (self);
	if (_klass_->size_of_value) {
		return _klass_->size_of_value (self, value);
	}
	return 0UL;
}

static void
g4_lru_cache_class_init (G4LruCacheClass * klass,
                         gpointer klass_data)
{
	g4_lru_cache_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &G4LruCache_private_offset);
	((G4LruCacheClass *) klass)->size_of_value = (gsize (*) (G4LruCache*, gconstpointer)) g4_lru_cache_real_size_of_value;
	G_OBJECT_CLASS (klass)->get_property = _vala_g4_lru_cache_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_g4_lru_cache_set_property;
	G_OBJECT_CLASS (klass)->finalize = g4_lru_cache_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), G4_LRU_CACHE_V_TYPE, g_param_spec_gtype ("v-type", "type", "type", G_TYPE_NONE, G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), G4_LRU_CACHE_V_DUP_FUNC, g_param_spec_pointer ("v-dup-func", "dup func", "dup func", G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), G4_LRU_CACHE_V_DESTROY_FUNC, g_param_spec_pointer ("v-destroy-func", "destroy func", "destroy func", G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
}

static void
g4_lru_cache_instance_init (G4LruCache * self,
                            gpointer klass)
{
	GHashFunc _tmp0_;
	GEqualFunc _tmp1_;
	GHashTable* _tmp2_;
	GQueue* _tmp3_;
	self->priv = g4_lru_cache_get_instance_private (self);
	self->priv->_max_size = (gsize) 0;
	self->priv->_size = (gsize) 0;
	_tmp0_ = g_str_hash;
	_tmp1_ = g_str_equal;
	_tmp2_ = g_hash_table_new_full (_tmp0_, _tmp1_, _g_free0_, self->priv->v_destroy_func);
	self->priv->_cache = _tmp2_;
	_tmp3_ = g_queue_new ();
	self->priv->_queue = _tmp3_;
}

static void
g4_lru_cache_finalize (GObject * obj)
{
	G4LruCache * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, G4_TYPE_LRU_CACHE, G4LruCache);
	_g_hash_table_unref0 (self->priv->_cache);
	(self->priv->_queue == NULL) ? NULL : (self->priv->_queue = (_g_queue_free__g_free0_ (self->priv->_queue), NULL));
	G_OBJECT_CLASS (g4_lru_cache_parent_class)->finalize (obj);
}

static GType
g4_lru_cache_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (G4LruCacheClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) g4_lru_cache_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (G4LruCache), 0, (GInstanceInitFunc) g4_lru_cache_instance_init, NULL };
	GType g4_lru_cache_type_id;
	g4_lru_cache_type_id = g_type_register_static (G_TYPE_OBJECT, "G4LruCache", &g_define_type_info, 0);
	G4LruCache_private_offset = g_type_add_instance_private (g4_lru_cache_type_id, sizeof (G4LruCachePrivate));
	return g4_lru_cache_type_id;
}

GType
g4_lru_cache_get_type (void)
{
	static volatile gsize g4_lru_cache_type_id__once = 0;
	if (g_once_init_enter (&g4_lru_cache_type_id__once)) {
		GType g4_lru_cache_type_id;
		g4_lru_cache_type_id = g4_lru_cache_get_type_once ();
		g_once_init_leave (&g4_lru_cache_type_id__once, g4_lru_cache_type_id);
	}
	return g4_lru_cache_type_id__once;
}

static void
_vala_g4_lru_cache_get_property (GObject * object,
                                 guint property_id,
                                 GValue * value,
                                 GParamSpec * pspec)
{
	G4LruCache * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, G4_TYPE_LRU_CACHE, G4LruCache);
	switch (property_id) {
		case G4_LRU_CACHE_V_TYPE:
		g_value_set_gtype (value, self->priv->v_type);
		break;
		case G4_LRU_CACHE_V_DUP_FUNC:
		g_value_set_pointer (value, self->priv->v_dup_func);
		break;
		case G4_LRU_CACHE_V_DESTROY_FUNC:
		g_value_set_pointer (value, self->priv->v_destroy_func);
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_g4_lru_cache_set_property (GObject * object,
                                 guint property_id,
                                 const GValue * value,
                                 GParamSpec * pspec)
{
	G4LruCache * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, G4_TYPE_LRU_CACHE, G4LruCache);
	switch (property_id) {
		case G4_LRU_CACHE_V_TYPE:
		self->priv->v_type = g_value_get_gtype (value);
		break;
		case G4_LRU_CACHE_V_DUP_FUNC:
		self->priv->v_dup_func = g_value_get_pointer (value);
		break;
		case G4_LRU_CACHE_V_DESTROY_FUNC:
		self->priv->v_destroy_func = g_value_get_pointer (value);
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
g4_thumbnailer_get_instance_private (G4Thumbnailer* self)
{
	return G_STRUCT_MEMBER_P (self, G4Thumbnailer_private_offset);
}

GdkPaintable*
g4_thumbnailer_find (G4Thumbnailer* self,
                     G4Music* music,
                     gint size)
{
	G4LruCache* _tmp0_ = NULL;
	G4LruCache* cache = NULL;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	gpointer _tmp5_;
	GdkPaintable* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (music != NULL, NULL);
	if (size >= G4_THUMBNAILER_GRID_SIZE) {
		G4LruCache* _tmp1_;
		_tmp1_ = self->priv->_grid_cache;
		_tmp0_ = _tmp1_;
	} else {
		G4LruCache* _tmp2_;
		_tmp2_ = self->priv->_icon_cache;
		_tmp0_ = _tmp2_;
	}
	cache = _tmp0_;
	_tmp3_ = g4_music_get_cover_key (music);
	_tmp4_ = _tmp3_;
	_tmp5_ = g4_lru_cache_find (cache, _tmp4_);
	result = (GdkPaintable*) _tmp5_;
	return result;
}

void
g4_thumbnailer_put (G4Thumbnailer* self,
                    G4Music* music,
                    GdkPaintable* paintable,
                    gboolean replace,
                    gint size)
{
	G4LruCache* _tmp0_ = NULL;
	G4LruCache* cache = NULL;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (music != NULL);
	g_return_if_fail (paintable != NULL);
	if (size >= G4_THUMBNAILER_GRID_SIZE) {
		G4LruCache* _tmp1_;
		_tmp1_ = self->priv->_grid_cache;
		_tmp0_ = _tmp1_;
	} else {
		G4LruCache* _tmp2_;
		_tmp2_ = self->priv->_icon_cache;
		_tmp0_ = _tmp2_;
	}
	cache = _tmp0_;
	_tmp3_ = g4_music_get_cover_key (music);
	_tmp4_ = _tmp3_;
	g4_lru_cache_put (cache, _tmp4_, paintable, replace);
}

static void
g4_thumbnailer_load_async_data_free (gpointer _data)
{
	G4ThumbnailerLoadAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->music);
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (G4ThumbnailerLoadAsyncData, _data_);
}

static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

void
g4_thumbnailer_load_async (G4Thumbnailer* self,
                           G4Music* music,
                           gint size,
                           GAsyncReadyCallback _callback_,
                           gpointer _user_data_)
{
	G4ThumbnailerLoadAsyncData* _data_;
	G4Thumbnailer* _tmp0_;
	G4Music* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (music != NULL);
	_data_ = g_slice_new0 (G4ThumbnailerLoadAsyncData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, g4_thumbnailer_load_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (music);
	_g_object_unref0 (_data_->music);
	_data_->music = _tmp1_;
	_data_->size = size;
	g4_thumbnailer_load_async_co (_data_);
}

GdkPaintable*
g4_thumbnailer_load_finish (G4Thumbnailer* self,
                            GAsyncResult* _res_)
{
	GdkPaintable* result;
	G4ThumbnailerLoadAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static void
g4_thumbnailer_load_async_ready (GObject* source_object,
                                 GAsyncResult* _res_,
                                 gpointer _user_data_)
{
	G4ThumbnailerLoadAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	g4_thumbnailer_load_async_co (_data_);
}

static gboolean
g4_thumbnailer_load_async_co (G4ThumbnailerLoadAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->is_small = _data_->size <= G4_THUMBNAILER_GRID_SIZE;
	if (_data_->is_small) {
		_data_->_tmp0_ = !g_object_replace_qdata ((GObject*) _data_->music, _data_->self->priv->_loading_quark, (gpointer) ((gintptr) FALSE), (gpointer) ((gintptr) TRUE), NULL, NULL);
	} else {
		_data_->_tmp0_ = FALSE;
	}
	if (_data_->_tmp0_) {
		_data_->result = NULL;
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_state_ = 1;
	g4_thumbnailer_load_directly_async (_data_->self, _data_->music, _data_->size, g4_thumbnailer_load_async_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp1_ = g4_thumbnailer_load_directly_finish (_data_->self, _data_->_res_);
	_data_->pixbuf = _data_->_tmp1_;
	if (_data_->is_small) {
		g_object_steal_qdata ((GObject*) _data_->music, _data_->self->priv->_loading_quark);
	}
	_data_->_tmp2_ = g4_thumbnailer_find (_data_->self, _data_->music, _data_->size);
	_data_->paintable0 = _data_->_tmp2_;
	if (_data_->is_small) {
		_data_->_tmp4_ = _data_->paintable0;
		_data_->_tmp3_ = _data_->_tmp4_ != NULL;
	} else {
		_data_->_tmp3_ = FALSE;
	}
	if (_data_->_tmp3_) {
		_data_->result = _data_->paintable0;
		_g_object_unref0 (_data_->pixbuf);
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp6_ = _data_->pixbuf;
	if (_data_->_tmp6_ != NULL) {
		_data_->_tmp7_ = _data_->pixbuf;
		_data_->_tmp8_ = gdk_texture_new_for_pixbuf (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp7_, gdk_pixbuf_get_type (), GdkPixbuf));
		_g_object_unref0 (_data_->_tmp5_);
		_data_->_tmp5_ = (GdkPaintable*) _data_->_tmp8_;
	} else {
		_data_->_tmp9_ = g4_thumbnailer_create_music_text_paintable (_data_->self, _data_->music);
		_g_object_unref0 (_data_->_tmp5_);
		_data_->_tmp5_ = _data_->_tmp9_;
	}
	_data_->_tmp10_ = _data_->_tmp5_;
	_data_->_tmp5_ = NULL;
	_data_->paintable = _data_->_tmp10_;
	if (_data_->is_small) {
		_data_->_tmp11_ = _data_->paintable;
		g4_thumbnailer_put (_data_->self, _data_->music, _data_->_tmp11_, FALSE, _data_->size);
	} else {
		_data_->_tmp13_ = _data_->pixbuf;
		if (_data_->_tmp13_ != NULL) {
			_data_->_tmp14_ = _data_->paintable0;
			_data_->_tmp12_ = _data_->_tmp14_ == NULL;
		} else {
			_data_->_tmp12_ = FALSE;
		}
		if (_data_->_tmp12_) {
			_data_->_tmp15_ = g4_music_get_cover_key (_data_->music);
			_data_->_tmp16_ = _data_->_tmp15_;
			_data_->_tmp17_ = g4_thumbnailer_find_pixbuf_from_cache (_data_->self, _data_->_tmp16_);
			_data_->minbuf = _data_->_tmp17_;
			_data_->_tmp18_ = _data_->minbuf;
			if (_data_->_tmp18_ != NULL) {
				_data_->_tmp19_ = _data_->minbuf;
				_data_->_tmp20_ = gdk_texture_new_for_pixbuf (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp19_, gdk_pixbuf_get_type (), GdkPixbuf));
				_data_->_tmp21_ = _data_->_tmp20_;
				g4_thumbnailer_put (_data_->self, _data_->music, (GdkPaintable*) _data_->_tmp21_, FALSE, G4_THUMBNAILER_ICON_SIZE);
				_g_object_unref0 (_data_->_tmp21_);
			}
			_g_object_unref0 (_data_->minbuf);
		}
	}
	_data_->result = _data_->paintable;
	_g_object_unref0 (_data_->_tmp5_);
	_g_object_unref0 (_data_->paintable0);
	_g_object_unref0 (_data_->pixbuf);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
g4_thumbnailer_load_directly_async_data_free (gpointer _data)
{
	G4ThumbnailerLoadDirectlyAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->music);
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (G4ThumbnailerLoadDirectlyAsyncData, _data_);
}

void
g4_thumbnailer_load_directly_async (G4Thumbnailer* self,
                                    G4Music* music,
                                    gint size,
                                    GAsyncReadyCallback _callback_,
                                    gpointer _user_data_)
{
	G4ThumbnailerLoadDirectlyAsyncData* _data_;
	G4Thumbnailer* _tmp0_;
	G4Music* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (music != NULL);
	_data_ = g_slice_new0 (G4ThumbnailerLoadDirectlyAsyncData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, g4_thumbnailer_load_directly_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (music);
	_g_object_unref0 (_data_->music);
	_data_->music = _tmp1_;
	_data_->size = size;
	g4_thumbnailer_load_directly_async_co (_data_);
}

GdkPixbuf*
g4_thumbnailer_load_directly_finish (G4Thumbnailer* self,
                                     GAsyncResult* _res_)
{
	GdkPixbuf* result;
	G4ThumbnailerLoadDirectlyAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static Block67Data*
block67_data_ref (Block67Data* _data67_)
{
	g_atomic_int_inc (&_data67_->_ref_count_);
	return _data67_;
}

static void
block67_data_unref (void * _userdata_)
{
	Block67Data* _data67_;
	_data67_ = (Block67Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data67_->_ref_count_)) {
		G4Thumbnailer* self;
		self = _data67_->self;
		_data67_->args = (_vala_array_free (_data67_->args, _data67_->args_length1, (GDestroyNotify) g_free), NULL);
		_data67_->tags = (_vala_array_free (_data67_->tags, _data67_->tags_length1, (GDestroyNotify) gst_tag_list_unref), NULL);
		_g_free0 (_data67_->album_key_);
		_g_object_unref0 (_data67_->file);
		_g_object_unref0 (self);
		g_slice_free (Block67Data, _data67_);
	}
}

static const gchar*
string_to_string (const gchar* self)
{
	const gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self;
	return result;
}

static gpointer
_gst_tag_list_ref0 (gpointer self)
{
	return self ? gst_tag_list_ref (self) : NULL;
}

static gsize*
_size_t_dup (gsize* self)
{
	gsize* dup;
	dup = g_new0 (gsize, 1);
	memcpy (dup, self, sizeof (gsize));
	return dup;
}

static gpointer
__size_t_dup0 (gpointer self)
{
	return self ? _size_t_dup (self) : NULL;
}

static GdkPixbuf*
__lambda42_ (Block67Data* _data67_)
{
	G4Thumbnailer* self;
	GstTagList* tag = NULL;
	GstTagList** _tmp0_;
	gint _tmp0__length1;
	GFile* _tmp1_;
	GstTagList* _tmp2_;
	GstTagList* _tmp3_;
	GFile* cover_file = NULL;
	GdkPixbuf* pixbuf = NULL;
	GstSample* sample = NULL;
	gboolean _tmp4_ = FALSE;
	GstTagList* _tmp5_;
	gboolean _tmp32_ = FALSE;
	GdkPixbuf* _tmp33_;
	GdkPixbuf* _tmp60_;
	gchar** _tmp74_;
	gint _tmp74__length1;
	gchar** _tmp75_;
	gint _tmp75__length1;
	const gchar* _tmp76_;
	gchar* _tmp77_;
	GdkPixbuf* result;
	self = _data67_->self;
	_tmp0_ = _data67_->tags;
	_tmp0__length1 = _data67_->tags_length1;
	_tmp1_ = _data67_->file;
	_tmp2_ = g4_parse_gst_tags (_tmp1_);
	_gst_tag_list_unref0 (_tmp0_[0]);
	_tmp0_[0] = _tmp2_;
	_tmp3_ = _gst_tag_list_ref0 (_tmp0_[0]);
	tag = _tmp3_;
	cover_file = NULL;
	pixbuf = NULL;
	sample = NULL;
	_tmp5_ = tag;
	if (_tmp5_ != NULL) {
		GstTagList* _tmp6_;
		GstSample* _tmp7_;
		GstSample* _tmp8_;
		_tmp6_ = tag;
		_tmp7_ = g4_parse_image_from_tag_list ((GstTagList*) _tmp6_);
		_gst_sample_unref0 (sample);
		sample = _tmp7_;
		_tmp8_ = sample;
		_tmp4_ = _tmp8_ != NULL;
	} else {
		_tmp4_ = FALSE;
	}
	if (_tmp4_) {
		GstSample* _tmp9_ = NULL;
		GstSample* _tmp10_;
		GstBuffer* _tmp11_ = NULL;
		GstBuffer* _tmp13_ = NULL;
		gsize* _tmp14_ = NULL;
		gsize* _tmp17_ = NULL;
		gsize* _tmp18_;
		gsize image_size = 0UL;
		gsize* _tmp21_;
		gsize _tmp22_;
		gchar* album_key = NULL;
		const gchar* _tmp23_;
		gchar* _tmp24_;
		gchar* _tmp25_;
		gchar* _tmp26_;
		gchar* _tmp27_;
		const gchar* _tmp28_;
		gchar** _tmp29_;
		gint _tmp29__length1;
		GstSample* _tmp30_;
		GdkPixbuf* _tmp31_;
		_tmp10_ = sample;
		_tmp9_ = _tmp10_;
		_tmp11_ = NULL;
		if (_tmp9_ != NULL) {
			GstBuffer* _tmp12_;
			_tmp12_ = gst_sample_get_buffer ((GstSample*) _tmp9_);
			_tmp11_ = _tmp12_;
		}
		_tmp13_ = _tmp11_;
		_tmp14_ = NULL;
		if (_tmp13_ != NULL) {
			gsize _tmp15_;
			gsize* _tmp16_;
			_tmp15_ = gst_buffer_get_size ((GstBuffer*) _tmp13_);
			_tmp16_ = __size_t_dup0 (&_tmp15_);
			_g_free0 (_tmp14_);
			_tmp14_ = _tmp16_;
		}
		_tmp18_ = _tmp14_;
		_tmp14_ = NULL;
		_tmp17_ = _tmp18_;
		if (_tmp17_ == NULL) {
			gsize _tmp19_;
			gsize* _tmp20_;
			_tmp19_ = (gsize) 0;
			_tmp20_ = __size_t_dup0 (&_tmp19_);
			_g_free0 (_tmp17_);
			_tmp17_ = _tmp20_;
		}
		_tmp21_ = _tmp17_;
		_tmp17_ = NULL;
		_tmp22_ = (gsize) (*_tmp21_);
		_g_free0 (_tmp21_);
		image_size = _tmp22_;
		_tmp23_ = _data67_->album_key_;
		_tmp24_ = g_strdup_printf ("%x", image_size);
		_tmp25_ = _tmp24_;
		_tmp26_ = g_strconcat (_tmp23_, _tmp25_, NULL);
		_tmp27_ = _tmp26_;
		_g_free0 (_tmp25_);
		album_key = _tmp27_;
		_tmp28_ = album_key;
		_tmp29_ = _data67_->args;
		_tmp29__length1 = _data67_->args_length1;
		g4_thumbnailer_check_same_album_cover (self, _tmp28_, &_tmp29_[0]);
		_tmp30_ = sample;
		_tmp31_ = g4_load_clamp_pixbuf_from_sample ((GstSample*) _tmp30_, _data67_->size * self->priv->_scale_factor);
		_g_object_unref0 (pixbuf);
		pixbuf = _tmp31_;
		_g_free0 (album_key);
		_g_free0 (_tmp17_);
		_g_free0 (_tmp14_);
	}
	_tmp33_ = pixbuf;
	if (_tmp33_ == NULL) {
		G4CoverCache* _tmp34_ = NULL;
		G4CoverCache* _tmp35_;
		GFile* _tmp36_ = NULL;
		GFile* _tmp41_;
		GFile* _tmp42_;
		_tmp35_ = self->priv->_cover_finder;
		_tmp34_ = _tmp35_;
		_tmp36_ = NULL;
		if (_tmp34_ != NULL) {
			GFile* _tmp37_;
			GFile* _tmp38_;
			GFile* _tmp39_;
			GFile* _tmp40_;
			_tmp37_ = _data67_->file;
			_tmp38_ = g_file_get_parent (_tmp37_);
			_tmp39_ = _tmp38_;
			_tmp40_ = g4_cover_cache_find (G_TYPE_CHECK_INSTANCE_CAST (_tmp34_, G4_TYPE_COVER_CACHE, G4CoverCache), _tmp39_);
			_g_object_unref0 (_tmp36_);
			_tmp36_ = _tmp40_;
			_g_object_unref0 (_tmp39_);
		}
		_tmp41_ = _tmp36_;
		_tmp36_ = NULL;
		_g_object_unref0 (cover_file);
		cover_file = _tmp41_;
		_tmp42_ = cover_file;
		_tmp32_ = _tmp42_ != NULL;
		_g_object_unref0 (_tmp36_);
	} else {
		_tmp32_ = FALSE;
	}
	if (_tmp32_) {
		GFile* _tmp43_ = NULL;
		GFile* _tmp44_;
		gchar* _tmp45_ = NULL;
		gchar* album_key = NULL;
		gchar* _tmp47_;
		GFile* _tmp48_ = NULL;
		GFile* _tmp49_;
		gchar* _tmp50_ = NULL;
		gchar** _tmp52_;
		gint _tmp52__length1;
		gchar** _tmp53_;
		gint _tmp53__length1;
		gchar* _tmp54_;
		gchar* _tmp55_;
		const gchar* _tmp56_;
		gchar** _tmp57_;
		gint _tmp57__length1;
		GFile* _tmp58_;
		GdkPixbuf* _tmp59_;
		_tmp44_ = cover_file;
		_tmp43_ = _tmp44_;
		_tmp45_ = NULL;
		if (_tmp43_ != NULL) {
			gchar* _tmp46_;
			_tmp46_ = g_file_get_path (G_TYPE_CHECK_INSTANCE_CAST (_tmp43_, g_file_get_type (), GFile));
			_g_free0 (_tmp45_);
			_tmp45_ = _tmp46_;
		}
		_tmp47_ = g_strdup ((const gchar*) _tmp45_);
		album_key = _tmp47_;
		_tmp49_ = cover_file;
		_tmp48_ = _tmp49_;
		_tmp50_ = NULL;
		if (_tmp48_ != NULL) {
			gchar* _tmp51_;
			_tmp51_ = g_file_get_uri (G_TYPE_CHECK_INSTANCE_CAST (_tmp48_, g_file_get_type (), GFile));
			_g_free0 (_tmp50_);
			_tmp50_ = _tmp51_;
		}
		_tmp52_ = _data67_->args;
		_tmp52__length1 = _data67_->args_length1;
		_tmp53_ = _data67_->args;
		_tmp53__length1 = _data67_->args_length1;
		_tmp54_ = g_strdup ((const gchar*) _tmp50_);
		_g_free0 (_tmp53_[1]);
		_tmp53_[1] = _tmp54_;
		_tmp55_ = g_strdup (_tmp53_[1]);
		_g_free0 (_tmp52_[0]);
		_tmp52_[0] = _tmp55_;
		_tmp56_ = album_key;
		_tmp57_ = _data67_->args;
		_tmp57__length1 = _data67_->args_length1;
		g4_thumbnailer_check_same_album_cover (self, _tmp56_, &_tmp57_[0]);
		_tmp58_ = cover_file;
		_tmp59_ = g4_load_clamp_pixbuf_from_file (G_TYPE_CHECK_INSTANCE_CAST (_tmp58_, g_file_get_type (), GFile), _data67_->size * self->priv->_scale_factor);
		_g_object_unref0 (pixbuf);
		pixbuf = _tmp59_;
		_g_free0 (_tmp50_);
		_g_free0 (album_key);
		_g_free0 (_tmp45_);
	}
	_tmp60_ = pixbuf;
	if (_tmp60_ != NULL) {
		GdkPixbuf* minbuf = NULL;
		gchar** _tmp61_;
		gint _tmp61__length1;
		const gchar* _tmp62_;
		GdkPixbuf* _tmp63_;
		GdkPixbuf* _tmp64_;
		GdkPixbuf* _tmp70_ = NULL;
		GdkPixbuf* _tmp73_;
		_tmp61_ = _data67_->args;
		_tmp61__length1 = _data67_->args_length1;
		_tmp62_ = _tmp61_[0];
		_tmp63_ = g4_thumbnailer_find_pixbuf_from_cache (self, _tmp62_);
		minbuf = _tmp63_;
		_tmp64_ = minbuf;
		if (_tmp64_ == NULL) {
			GdkPixbuf* _tmp65_;
			GdkPixbuf* _tmp66_;
			gchar** _tmp67_;
			gint _tmp67__length1;
			const gchar* _tmp68_;
			GdkPixbuf* _tmp69_;
			_tmp65_ = pixbuf;
			_tmp66_ = g4_create_clamp_pixbuf (G_TYPE_CHECK_INSTANCE_CAST (_tmp65_, gdk_pixbuf_get_type (), GdkPixbuf), G4_THUMBNAILER_ICON_SIZE * self->priv->_scale_factor);
			_g_object_unref0 (minbuf);
			minbuf = _tmp66_;
			_tmp67_ = _data67_->args;
			_tmp67__length1 = _data67_->args_length1;
			_tmp68_ = _tmp67_[0];
			_tmp69_ = minbuf;
			g4_thumbnailer_put_pixbuf_to_cache (self, _tmp68_, G_TYPE_CHECK_INSTANCE_CAST (_tmp69_, gdk_pixbuf_get_type (), GdkPixbuf));
		}
		if (_data67_->size <= G4_THUMBNAILER_ICON_SIZE) {
			GdkPixbuf* _tmp71_;
			_tmp71_ = minbuf;
			_tmp70_ = _tmp71_;
		} else {
			GdkPixbuf* _tmp72_;
			_tmp72_ = pixbuf;
			_tmp70_ = _tmp72_;
		}
		_tmp73_ = _g_object_ref0 (_tmp70_);
		result = _tmp73_;
		_g_object_unref0 (minbuf);
		_gst_sample_unref0 (sample);
		_g_object_unref0 (pixbuf);
		_g_object_unref0 (cover_file);
		_gst_tag_list_unref0 (tag);
		return result;
	}
	_tmp74_ = _data67_->args;
	_tmp74__length1 = _data67_->args_length1;
	_tmp75_ = _data67_->args;
	_tmp75__length1 = _data67_->args_length1;
	_tmp76_ = _tmp75_[2];
	_tmp77_ = g_strdup (_tmp76_);
	_g_free0 (_tmp74_[0]);
	_tmp74_[0] = _tmp77_;
	result = NULL;
	_gst_sample_unref0 (sample);
	_g_object_unref0 (pixbuf);
	_g_object_unref0 (cover_file);
	_gst_tag_list_unref0 (tag);
	return result;
}

static gpointer
___lambda42__g4_task_func (gpointer self)
{
	gpointer result;
	result = __lambda42_ (self);
	return result;
}

static void
g4_thumbnailer_load_directly_async_ready (GObject* source_object,
                                          GAsyncResult* _res_,
                                          gpointer _user_data_)
{
	G4ThumbnailerLoadDirectlyAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	g4_thumbnailer_load_directly_async_co (_data_);
}

static gboolean
g4_thumbnailer_load_directly_async_co (G4ThumbnailerLoadDirectlyAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_data67_ = g_slice_new0 (Block67Data);
	_data_->_data67_->_ref_count_ = 1;
	_data_->_data67_->self = g_object_ref (_data_->self);
	_data_->_data67_->size = _data_->size;
	_data_->_data67_->_async_data_ = _data_;
	_data_->_tmp0_ = _data_->music->uri;
	_data_->_tmp1_ = g_file_new_for_uri (_data_->_tmp0_);
	_data_->_data67_->file = _data_->_tmp1_;
	_data_->_tmp2_ = _data_->_data67_->file;
	_data_->is_native = g_file_is_native (_data_->_tmp2_);
	if (!_data_->self->priv->_remote_thumbnail) {
		_data_->_tmp3_ = !_data_->is_native;
	} else {
		_data_->_tmp3_ = FALSE;
	}
	if (_data_->_tmp3_) {
		_data_->result = NULL;
		block67_data_unref (_data_->_data67_);
		_data_->_data67_ = NULL;
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp4_ = g4_music_get_album_key (_data_->music);
	_data_->_tmp5_ = _data_->_tmp4_;
	_data_->_tmp6_ = string_to_string (_data_->_tmp5_);
	_data_->_tmp7_ = _data_->music->artist;
	_data_->_tmp8_ = string_to_string (_data_->_tmp7_);
	_data_->_tmp9_ = g_strconcat (_data_->_tmp6_, "-", _data_->_tmp8_, "-", NULL);
	_data_->_data67_->album_key_ = _data_->_tmp9_;
	_data_->_tmp10_ = g_new0 (GstTagList*, 1 + 1);
	_data_->_tmp10_[0] = NULL;
	_data_->_data67_->tags = _data_->_tmp10_;
	_data_->_data67_->tags_length1 = 1;
	_data_->_data67_->_tags_size_ = _data_->_data67_->tags_length1;
	_data_->_tmp12_ = _data_->music->cover_uri;
	_data_->_tmp11_ = _data_->_tmp12_;
	if (_data_->_tmp11_ == NULL) {
		_data_->_tmp11_ = "";
	}
	_data_->_tmp13_ = g4_music_get_cover_key (_data_->music);
	_data_->_tmp14_ = _data_->_tmp13_;
	_data_->_tmp15_ = g_strdup (_data_->_tmp14_);
	_data_->_tmp16_ = g_strdup ((const gchar*) _data_->_tmp11_);
	_data_->_tmp17_ = g4_music_get_abbreviation (_data_->music);
	_data_->_tmp18_ = g_new0 (gchar*, 3 + 1);
	_data_->_tmp18_[0] = _data_->_tmp15_;
	_data_->_tmp18_[1] = _data_->_tmp16_;
	_data_->_tmp18_[2] = _data_->_tmp17_;
	_data_->_data67_->args = _data_->_tmp18_;
	_data_->_data67_->args_length1 = 3;
	_data_->_data67_->_args_size_ = _data_->_data67_->args_length1;
	_data_->_tmp19_ = _data_->_data67_->file;
	_data_->_state_ = 1;
	g4_run_async (gdk_pixbuf_get_type (), (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, ___lambda42__g4_task_func, _data_->_data67_, FALSE, g_file_has_uri_scheme (_data_->_tmp19_, "smb"), g4_thumbnailer_load_directly_async_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp20_ = g4_run_finish (_data_->_res_);
	_data_->pixbuf = (GdkPixbuf*) _data_->_tmp20_;
	if (!_data_->is_native) {
		_data_->_tmp23_ = _data_->_data67_->tags;
		_data_->_tmp23__length1 = _data_->_data67_->tags_length1;
		_data_->_tmp24_ = _data_->_tmp23_[0];
		_data_->_tmp22_ = _data_->_tmp24_ != NULL;
	} else {
		_data_->_tmp22_ = FALSE;
	}
	if (_data_->_tmp22_) {
		_data_->_tmp25_ = _data_->_data67_->tags;
		_data_->_tmp25__length1 = _data_->_data67_->tags_length1;
		_data_->_tmp26_ = _data_->_tmp25_[0];
		_data_->_tmp21_ = g4_music_from_gst_tags (_data_->music, (GstTagList*) _data_->_tmp26_);
	} else {
		_data_->_tmp21_ = FALSE;
	}
	if (_data_->_tmp21_) {
		g_signal_emit (_data_->self, g4_thumbnailer_signals[G4_THUMBNAILER_TAG_UPDATED_SIGNAL], 0, _data_->music);
	}
	_data_->_tmp27_ = g4_music_get_cover_key (_data_->music);
	_data_->_tmp28_ = _data_->_tmp27_;
	_data_->_tmp29_ = _data_->_data67_->args;
	_data_->_tmp29__length1 = _data_->_data67_->args_length1;
	_data_->_tmp30_ = _data_->_tmp29_[0];
	if (g_strcmp0 (_data_->_tmp28_, _data_->_tmp30_) != 0) {
		_data_->_tmp31_ = _data_->_data67_->args;
		_data_->_tmp31__length1 = _data_->_data67_->args_length1;
		_data_->_tmp32_ = _data_->_tmp31_[0];
		g4_music_set_cover_key (_data_->music, _data_->_tmp32_);
	}
	_data_->_tmp33_ = _data_->_data67_->args;
	_data_->_tmp33__length1 = _data_->_data67_->args_length1;
	_data_->_tmp34_ = _data_->_tmp33_[1];
	_data_->_tmp35_ = strlen (_data_->_tmp34_);
	_data_->_tmp36_ = _data_->_tmp35_;
	if (_data_->_tmp36_ > 0) {
		_data_->_tmp37_ = _data_->_data67_->args;
		_data_->_tmp37__length1 = _data_->_data67_->args_length1;
		_data_->_tmp38_ = _data_->_tmp37_[1];
		_data_->_tmp39_ = g_strdup (_data_->_tmp38_);
		_g_free0 (_data_->music->cover_uri);
		_data_->music->cover_uri = _data_->_tmp39_;
	}
	_data_->result = _data_->pixbuf;
	block67_data_unref (_data_->_data67_);
	_data_->_data67_ = NULL;
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

GdkPaintable*
g4_thumbnailer_create_music_text_paintable (G4Thumbnailer* self,
                                            G4Music* music)
{
	gchar* text = NULL;
	gchar* _tmp0_;
	gint color_count = 0;
	guint _tmp1_ = 0U;
	gboolean _tmp2_ = FALSE;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	guint color_index = 0U;
	const gchar* _tmp9_;
	GdkPaintable* _tmp10_;
	GdkPaintable* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (music != NULL, NULL);
	_tmp0_ = g4_music_get_abbreviation (music);
	text = _tmp0_;
	color_count = G_N_ELEMENTS (G4_BACKGROUND_COLORS) / 2;
	_tmp3_ = text;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	if (_tmp5_ == 0) {
		_tmp2_ = TRUE;
	} else {
		const gchar* _tmp6_;
		_tmp6_ = text;
		_tmp2_ = g_strcmp0 (_tmp6_, G4_UNKNOWN_ALBUM) == 0;
	}
	if (_tmp2_) {
		_tmp1_ = (guint) (color_count - 1);
	} else {
		GHashFunc _tmp7_;
		const gchar* _tmp8_;
		_tmp7_ = g_str_hash;
		_tmp8_ = text;
		_tmp1_ = _tmp7_ (_tmp8_) % (color_count - 1);
	}
	color_index = _tmp1_;
	_tmp9_ = text;
	_tmp10_ = g4_thumbnailer_create_simple_text_paintable (self, _tmp9_, G4_THUMBNAILER_ICON_SIZE, color_index);
	result = _tmp10_;
	_g_free0 (text);
	return result;
}

gchar*
g4_thumbnailer_create_music_text_svg (G4Thumbnailer* self,
                                      G4Music* music)
{
	gchar* text = NULL;
	gchar* _tmp0_;
	gint color_count = 0;
	guint _tmp1_ = 0U;
	gboolean _tmp2_ = FALSE;
	const gchar* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	guint color_index = 0U;
	PangoContext* _tmp9_;
	const gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (music != NULL, NULL);
	_tmp0_ = g4_music_get_abbreviation (music);
	text = _tmp0_;
	color_count = G_N_ELEMENTS (G4_BACKGROUND_COLORS) / 2;
	_tmp3_ = text;
	_tmp4_ = strlen (_tmp3_);
	_tmp5_ = _tmp4_;
	if (_tmp5_ == 0) {
		_tmp2_ = TRUE;
	} else {
		const gchar* _tmp6_;
		_tmp6_ = text;
		_tmp2_ = g_strcmp0 (_tmp6_, G4_UNKNOWN_ALBUM) == 0;
	}
	if (_tmp2_) {
		_tmp1_ = (guint) (color_count - 1);
	} else {
		GHashFunc _tmp7_;
		const gchar* _tmp8_;
		_tmp7_ = g_str_hash;
		_tmp8_ = text;
		_tmp1_ = _tmp7_ (_tmp8_) % (color_count - 1);
	}
	color_index = _tmp1_;
	_tmp9_ = self->priv->_pango_context;
	_tmp10_ = text;
	_tmp11_ = g4_create_text_svg (G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, pango_context_get_type (), PangoContext), _tmp10_, color_index);
	result = _tmp11_;
	_g_free0 (text);
	return result;
}

GdkPaintable*
g4_thumbnailer_create_simple_text_paintable (G4Thumbnailer* self,
                                             const gchar* text,
                                             gint size,
                                             guint color_index)
{
	GdkPaintable* paintable = NULL;
	PangoContext* _tmp0_;
	GdkPaintable* _tmp1_;
	GdkPaintable* _tmp2_ = NULL;
	GdkPaintable* _tmp3_;
	GdkPaintable* _tmp4_;
	GdkPaintable* _tmp6_;
	GdkPaintable* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (text != NULL, NULL);
	_tmp0_ = self->priv->_pango_context;
	_tmp1_ = g4_create_text_paintable (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, pango_context_get_type (), PangoContext), text, size * self->priv->_scale_factor, size * self->priv->_scale_factor, color_index);
	paintable = _tmp1_;
	_tmp3_ = paintable;
	_tmp4_ = _g_object_ref0 (_tmp3_);
	_tmp2_ = _tmp4_;
	if (_tmp2_ == NULL) {
		G4BasePaintable* _tmp5_;
		_tmp5_ = g4_base_paintable_new (NULL);
		_g_object_unref0 (_tmp2_);
		_tmp2_ = (GdkPaintable*) _tmp5_;
	}
	_tmp6_ = _tmp2_;
	_tmp2_ = NULL;
	result = G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, gdk_paintable_get_type (), GdkPaintable);
	_g_object_unref0 (_tmp2_);
	_g_object_unref0 (paintable);
	return result;
}

static void
g4_thumbnailer_check_same_album_cover (G4Thumbnailer* self,
                                       const gchar* album_key,
                                       gchar** cover_key)
{
	const gchar* key = NULL;
	const gchar* uri = NULL;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (album_key != NULL);
	g_return_if_fail (*cover_key != NULL);
	{
		GHashTable* _tmp0_;
		_tmp0_ = self->priv->_album_covers;
		g_rec_mutex_lock (&self->priv->__lock__album_covers);
		{
			GHashTable* _tmp1_;
			gconstpointer _tmp2_ = NULL;
			gconstpointer _tmp3_ = NULL;
			gboolean _tmp4_;
			_tmp1_ = self->priv->_album_covers;
			_tmp4_ = g_hash_table_lookup_extended (_tmp1_, album_key, &_tmp2_, &_tmp3_);
			key = (const gchar*) _tmp2_;
			uri = (const gchar*) _tmp3_;
			if (_tmp4_) {
				const gchar* _tmp5_;
				gchar* _tmp6_;
				_tmp5_ = uri;
				_tmp6_ = g_strdup (_tmp5_);
				_g_free0 (*cover_key);
				*cover_key = _tmp6_;
			} else {
				GHashTable* _tmp7_;
				gchar* _tmp8_;
				gchar* _tmp9_;
				_tmp7_ = self->priv->_album_covers;
				_tmp8_ = g_strdup (album_key);
				_tmp9_ = g_strdup (*cover_key);
				g_hash_table_insert (_tmp7_, _tmp8_, _tmp9_);
			}
		}
		__finally0:
		{
			GHashTable* _tmp10_;
			_tmp10_ = self->priv->_album_covers;
			g_rec_mutex_unlock (&self->priv->__lock__album_covers);
		}
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return;
		}
	}
}

static GdkPixbuf*
g4_thumbnailer_find_pixbuf_from_cache (G4Thumbnailer* self,
                                       const gchar* cover_key)
{
	GError* _inner_error0_ = NULL;
	GdkPixbuf* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (cover_key != NULL, NULL);
	{
		G4LruCache* _tmp0_;
		_tmp0_ = self->priv->_album_pixbufs;
		g_rec_mutex_lock (&self->priv->__lock__album_pixbufs);
		{
			G4LruCache* _tmp1_;
			gpointer _tmp2_;
			_tmp1_ = self->priv->_album_pixbufs;
			_tmp2_ = g4_lru_cache_find (_tmp1_, cover_key);
			result = (GdkPixbuf*) _tmp2_;
			{
				G4LruCache* _tmp3_;
				_tmp3_ = self->priv->_album_pixbufs;
				g_rec_mutex_unlock (&self->priv->__lock__album_pixbufs);
			}
			return result;
		}
		__finally0:
		{
			G4LruCache* _tmp4_;
			_tmp4_ = self->priv->_album_pixbufs;
			g_rec_mutex_unlock (&self->priv->__lock__album_pixbufs);
		}
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return NULL;
	}
}

static void
g4_thumbnailer_put_pixbuf_to_cache (G4Thumbnailer* self,
                                    const gchar* cover_key,
                                    GdkPixbuf* pixbuf)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (cover_key != NULL);
	g_return_if_fail (pixbuf != NULL);
	{
		G4LruCache* _tmp0_;
		_tmp0_ = self->priv->_album_pixbufs;
		g_rec_mutex_lock (&self->priv->__lock__album_pixbufs);
		{
			G4LruCache* _tmp1_;
			_tmp1_ = self->priv->_album_pixbufs;
			g4_lru_cache_put (_tmp1_, cover_key, pixbuf, FALSE);
		}
		__finally0:
		{
			G4LruCache* _tmp2_;
			_tmp2_ = self->priv->_album_pixbufs;
			g_rec_mutex_unlock (&self->priv->__lock__album_pixbufs);
		}
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return;
		}
	}
}

G4Thumbnailer*
g4_thumbnailer_construct (GType object_type)
{
	G4Thumbnailer * self = NULL;
	self = (G4Thumbnailer*) g_object_new (object_type, NULL);
	return self;
}

G4Thumbnailer*
g4_thumbnailer_new (void)
{
	return g4_thumbnailer_construct (G4_TYPE_THUMBNAILER);
}

G4CoverCache*
g4_thumbnailer_get_cover_finder (G4Thumbnailer* self)
{
	G4CoverCache* result;
	G4CoverCache* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_cover_finder;
	result = _tmp0_;
	return result;
}

void
g4_thumbnailer_set_cover_finder (G4Thumbnailer* self,
                                 G4CoverCache* value)
{
	G4CoverCache* old_value;
	g_return_if_fail (self != NULL);
	old_value = g4_thumbnailer_get_cover_finder (self);
	if (old_value != value) {
		G4CoverCache* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_cover_finder);
		self->priv->_cover_finder = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, g4_thumbnailer_properties[G4_THUMBNAILER_COVER_FINDER_PROPERTY]);
	}
}

PangoContext*
g4_thumbnailer_get_pango_context (G4Thumbnailer* self)
{
	PangoContext* result;
	PangoContext* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_pango_context;
	result = _tmp0_;
	return result;
}

void
g4_thumbnailer_set_pango_context (G4Thumbnailer* self,
                                  PangoContext* value)
{
	PangoContext* old_value;
	g_return_if_fail (self != NULL);
	old_value = g4_thumbnailer_get_pango_context (self);
	if (old_value != value) {
		PangoContext* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_pango_context);
		self->priv->_pango_context = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, g4_thumbnailer_properties[G4_THUMBNAILER_PANGO_CONTEXT_PROPERTY]);
	}
}

gboolean
g4_thumbnailer_get_remote_thumbnail (G4Thumbnailer* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_remote_thumbnail;
	return result;
}

void
g4_thumbnailer_set_remote_thumbnail (G4Thumbnailer* self,
                                     gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = g4_thumbnailer_get_remote_thumbnail (self);
	if (old_value != value) {
		self->priv->_remote_thumbnail = value;
		g_object_notify_by_pspec ((GObject *) self, g4_thumbnailer_properties[G4_THUMBNAILER_REMOTE_THUMBNAIL_PROPERTY]);
	}
}

gint
g4_thumbnailer_get_scale_factor (G4Thumbnailer* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = self->priv->_scale_factor;
	return result;
}

void
g4_thumbnailer_set_scale_factor (G4Thumbnailer* self,
                                 gint value)
{
	gint old_value;
	g_return_if_fail (self != NULL);
	old_value = g4_thumbnailer_get_scale_factor (self);
	if (old_value != value) {
		self->priv->_scale_factor = value;
		g_object_notify_by_pspec ((GObject *) self, g4_thumbnailer_properties[G4_THUMBNAILER_SCALE_FACTOR_PROPERTY]);
	}
}

static void
g4_thumbnailer_class_init (G4ThumbnailerClass * klass,
                           gpointer klass_data)
{
	g4_thumbnailer_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &G4Thumbnailer_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_g4_thumbnailer_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_g4_thumbnailer_set_property;
	G_OBJECT_CLASS (klass)->finalize = g4_thumbnailer_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), G4_THUMBNAILER_COVER_FINDER_PROPERTY, g4_thumbnailer_properties[G4_THUMBNAILER_COVER_FINDER_PROPERTY] = g_param_spec_object ("cover-finder", "cover-finder", "cover-finder", G4_TYPE_COVER_CACHE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), G4_THUMBNAILER_PANGO_CONTEXT_PROPERTY, g4_thumbnailer_properties[G4_THUMBNAILER_PANGO_CONTEXT_PROPERTY] = g_param_spec_object ("pango-context", "pango-context", "pango-context", pango_context_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), G4_THUMBNAILER_REMOTE_THUMBNAIL_PROPERTY, g4_thumbnailer_properties[G4_THUMBNAILER_REMOTE_THUMBNAIL_PROPERTY] = g_param_spec_boolean ("remote-thumbnail", "remote-thumbnail", "remote-thumbnail", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), G4_THUMBNAILER_SCALE_FACTOR_PROPERTY, g4_thumbnailer_properties[G4_THUMBNAILER_SCALE_FACTOR_PROPERTY] = g_param_spec_int ("scale-factor", "scale-factor", "scale-factor", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g4_thumbnailer_signals[G4_THUMBNAILER_TAG_UPDATED_SIGNAL] = g_signal_new ("tag-updated", G4_TYPE_THUMBNAILER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, G4_TYPE_MUSIC);
}

static void
g4_thumbnailer_instance_init (G4Thumbnailer * self,
                              gpointer klass)
{
	GHashFunc _tmp0_;
	GEqualFunc _tmp1_;
	GHashTable* _tmp2_;
	G4LruCache* _tmp3_;
	G4LruCache* _tmp4_;
	G4LruCache* _tmp5_;
	self->priv = g4_thumbnailer_get_instance_private (self);
	g_rec_mutex_init (&self->priv->__lock__album_covers);
	_tmp0_ = g_str_hash;
	_tmp1_ = g_str_equal;
	_tmp2_ = g_hash_table_new_full (_tmp0_, _tmp1_, _g_free0_, _g_free0_);
	self->priv->_album_covers = _tmp2_;
	g_rec_mutex_init (&self->priv->__lock__album_pixbufs);
	_tmp3_ = g4_lru_cache_new (gdk_pixbuf_get_type (), (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, (gsize) 1000);
	self->priv->_album_pixbufs = _tmp3_;
	_tmp4_ = g4_lru_cache_new (gdk_paintable_get_type (), (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, (gsize) 500);
	self->priv->_grid_cache = _tmp4_;
	_tmp5_ = g4_lru_cache_new (gdk_paintable_get_type (), (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, (gsize) 1000);
	self->priv->_icon_cache = _tmp5_;
	self->priv->_loading_quark = g_quark_from_string ("loading_quark");
}

static void
g4_thumbnailer_finalize (GObject * obj)
{
	G4Thumbnailer * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, G4_TYPE_THUMBNAILER, G4Thumbnailer);
	g_rec_mutex_clear (&self->priv->__lock__album_covers);
	_g_hash_table_unref0 (self->priv->_album_covers);
	g_rec_mutex_clear (&self->priv->__lock__album_pixbufs);
	_g_object_unref0 (self->priv->_album_pixbufs);
	_g_object_unref0 (self->priv->_grid_cache);
	_g_object_unref0 (self->priv->_icon_cache);
	_g_object_unref0 (self->priv->_cover_finder);
	_g_object_unref0 (self->priv->_pango_context);
	G_OBJECT_CLASS (g4_thumbnailer_parent_class)->finalize (obj);
}

static GType
g4_thumbnailer_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (G4ThumbnailerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) g4_thumbnailer_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (G4Thumbnailer), 0, (GInstanceInitFunc) g4_thumbnailer_instance_init, NULL };
	GType g4_thumbnailer_type_id;
	g4_thumbnailer_type_id = g_type_register_static (G_TYPE_OBJECT, "G4Thumbnailer", &g_define_type_info, 0);
	G4Thumbnailer_private_offset = g_type_add_instance_private (g4_thumbnailer_type_id, sizeof (G4ThumbnailerPrivate));
	return g4_thumbnailer_type_id;
}

GType
g4_thumbnailer_get_type (void)
{
	static volatile gsize g4_thumbnailer_type_id__once = 0;
	if (g_once_init_enter (&g4_thumbnailer_type_id__once)) {
		GType g4_thumbnailer_type_id;
		g4_thumbnailer_type_id = g4_thumbnailer_get_type_once ();
		g_once_init_leave (&g4_thumbnailer_type_id__once, g4_thumbnailer_type_id);
	}
	return g4_thumbnailer_type_id__once;
}

static void
_vala_g4_thumbnailer_get_property (GObject * object,
                                   guint property_id,
                                   GValue * value,
                                   GParamSpec * pspec)
{
	G4Thumbnailer * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, G4_TYPE_THUMBNAILER, G4Thumbnailer);
	switch (property_id) {
		case G4_THUMBNAILER_COVER_FINDER_PROPERTY:
		g_value_set_object (value, g4_thumbnailer_get_cover_finder (self));
		break;
		case G4_THUMBNAILER_PANGO_CONTEXT_PROPERTY:
		g_value_set_object (value, g4_thumbnailer_get_pango_context (self));
		break;
		case G4_THUMBNAILER_REMOTE_THUMBNAIL_PROPERTY:
		g_value_set_boolean (value, g4_thumbnailer_get_remote_thumbnail (self));
		break;
		case G4_THUMBNAILER_SCALE_FACTOR_PROPERTY:
		g_value_set_int (value, g4_thumbnailer_get_scale_factor (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_g4_thumbnailer_set_property (GObject * object,
                                   guint property_id,
                                   const GValue * value,
                                   GParamSpec * pspec)
{
	G4Thumbnailer * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, G4_TYPE_THUMBNAILER, G4Thumbnailer);
	switch (property_id) {
		case G4_THUMBNAILER_COVER_FINDER_PROPERTY:
		g4_thumbnailer_set_cover_finder (self, g_value_get_object (value));
		break;
		case G4_THUMBNAILER_PANGO_CONTEXT_PROPERTY:
		g4_thumbnailer_set_pango_context (self, g_value_get_object (value));
		break;
		case G4_THUMBNAILER_REMOTE_THUMBNAIL_PROPERTY:
		g4_thumbnailer_set_remote_thumbnail (self, g_value_get_boolean (value));
		break;
		case G4_THUMBNAILER_SCALE_FACTOR_PROPERTY:
		g4_thumbnailer_set_scale_factor (self, g_value_get_int (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

GdkPixbuf*
g4_create_clamp_pixbuf (GdkPixbuf* pixbuf,
                        gint size)
{
	gint width = 0;
	gint _tmp0_;
	gint _tmp1_;
	gint height = 0;
	gint _tmp2_;
	gint _tmp3_;
	gboolean _tmp4_ = FALSE;
	gboolean _tmp5_ = FALSE;
	GdkPixbuf* _tmp11_;
	GdkPixbuf* result;
	g_return_val_if_fail (pixbuf != NULL, NULL);
	_tmp0_ = gdk_pixbuf_get_width (pixbuf);
	_tmp1_ = _tmp0_;
	width = _tmp1_;
	_tmp2_ = gdk_pixbuf_get_height (pixbuf);
	_tmp3_ = _tmp2_;
	height = _tmp3_;
	if (size > 0) {
		_tmp5_ = width > size;
	} else {
		_tmp5_ = FALSE;
	}
	if (_tmp5_) {
		_tmp4_ = height > size;
	} else {
		_tmp4_ = FALSE;
	}
	if (_tmp4_) {
		gdouble _tmp6_ = 0.0;
		gdouble scale = 0.0;
		gint dx = 0;
		gint dy = 0;
		GdkPixbuf* newbuf = NULL;
		GdkPixbuf* _tmp7_;
		GdkPixbuf* _tmp8_;
		if (width > height) {
			_tmp6_ = size / ((gdouble) height);
		} else {
			_tmp6_ = size / ((gdouble) width);
		}
		scale = _tmp6_;
		dx = (gint) ((width * scale) + 0.5);
		dy = (gint) ((height * scale) + 0.5);
		_tmp7_ = gdk_pixbuf_scale_simple (pixbuf, dx, dy, GDK_INTERP_TILES);
		newbuf = _tmp7_;
		_tmp8_ = newbuf;
		if (_tmp8_ != NULL) {
			GdkPixbuf* _tmp9_;
			GdkPixbuf* _tmp10_;
			_tmp9_ = newbuf;
			_tmp10_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, gdk_pixbuf_get_type (), GdkPixbuf));
			result = _tmp10_;
			_g_object_unref0 (newbuf);
			return result;
		}
		_g_object_unref0 (newbuf);
	}
	_tmp11_ = _g_object_ref0 (pixbuf);
	result = _tmp11_;
	return result;
}

GdkPixbuf*
g4_load_clamp_pixbuf_from_file (GFile* file,
                                gint size)
{
	GError* _inner_error0_ = NULL;
	GdkPixbuf* result;
	g_return_val_if_fail (file != NULL, NULL);
	{
		GFileInputStream* fis = NULL;
		GFileInputStream* _tmp0_;
		GBufferedInputStream* bis = NULL;
		GFileInputStream* _tmp1_;
		GBufferedInputStream* _tmp2_;
		GBufferedInputStream* _tmp3_;
		GdkPixbuf* _tmp4_ = NULL;
		GBufferedInputStream* _tmp5_;
		GdkPixbuf* _tmp6_;
		GdkPixbuf* _tmp7_;
		_tmp0_ = g_file_read (file, NULL, &_inner_error0_);
		fis = _tmp0_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp1_ = fis;
		_tmp2_ = (GBufferedInputStream*) g_buffered_input_stream_new ((GInputStream*) _tmp1_);
		bis = _tmp2_;
		_tmp3_ = bis;
		g_buffered_input_stream_set_buffer_size (_tmp3_, (guint) 16384);
		_tmp5_ = bis;
		_tmp6_ = gdk_pixbuf_new_from_stream_at_scale ((GInputStream*) _tmp5_, size, size, TRUE, NULL, &_inner_error0_);
		_tmp4_ = _tmp6_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (bis);
			_g_object_unref0 (fis);
			goto __catch0_g_error;
		}
		_tmp7_ = _tmp4_;
		_tmp4_ = NULL;
		result = _tmp7_;
		_g_object_unref0 (_tmp4_);
		_g_object_unref0 (bis);
		_g_object_unref0 (fis);
		return result;
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return NULL;
	}
	result = NULL;
	return result;
}

static gpointer
_gst_buffer_ref0 (gpointer self)
{
	return self ? gst_buffer_ref (self) : NULL;
}

static GstMapInfo*
_gst_map_info_dup (GstMapInfo* self)
{
	GstMapInfo* dup;
	dup = g_new0 (GstMapInfo, 1);
	memcpy (dup, self, sizeof (GstMapInfo));
	return dup;
}

static gpointer
__gst_map_info_dup0 (gpointer self)
{
	return self ? _gst_map_info_dup (self) : NULL;
}

static gboolean*
_bool_dup (gboolean* self)
{
	gboolean* dup;
	dup = g_new0 (gboolean, 1);
	memcpy (dup, self, sizeof (gboolean));
	return dup;
}

static gpointer
__bool_dup0 (gpointer self)
{
	return self ? _bool_dup (self) : NULL;
}

GdkPixbuf*
g4_load_clamp_pixbuf_from_sample (GstSample* sample,
                                  gint size)
{
	GstBuffer* buffer = NULL;
	GstBuffer* _tmp0_;
	GstBuffer* _tmp1_;
	GstMapInfo* info = NULL;
	GError* _inner_error0_ = NULL;
	GdkPixbuf* result;
	g_return_val_if_fail (sample != NULL, NULL);
	_tmp0_ = gst_sample_get_buffer (sample);
	_tmp1_ = _gst_buffer_ref0 (_tmp0_);
	buffer = _tmp1_;
	info = NULL;
	{
		GstBuffer* _tmp2_ = NULL;
		GstBuffer* _tmp3_;
		gboolean* _tmp4_ = NULL;
		gboolean* _tmp10_ = NULL;
		gboolean* _tmp11_;
		_tmp3_ = buffer;
		_tmp2_ = _tmp3_;
		_tmp4_ = NULL;
		if (_tmp2_ != NULL) {
			GstMapInfo _tmp5_ = {0};
			gboolean _tmp6_;
			GstMapInfo _tmp7_;
			GstMapInfo* _tmp8_;
			gboolean* _tmp9_;
			_tmp6_ = gst_buffer_map ((GstBuffer*) _tmp2_, &_tmp5_, GST_MAP_READ);
			_g_free0 (info);
			_tmp7_ = _tmp5_;
			_tmp8_ = __gst_map_info_dup0 (&_tmp7_);
			info = _tmp8_;
			_tmp9_ = __bool_dup0 (&_tmp6_);
			_g_free0 (_tmp4_);
			_tmp4_ = _tmp9_;
		}
		_tmp11_ = __bool_dup0 (_tmp4_);
		_tmp10_ = _tmp11_;
		if (_tmp10_ == NULL) {
			gboolean _tmp12_;
			gboolean* _tmp13_;
			_tmp12_ = FALSE;
			_tmp13_ = __bool_dup0 (&_tmp12_);
			_g_free0 (_tmp10_);
			_tmp10_ = _tmp13_;
		}
		if ((gboolean) (*_tmp10_)) {
			GstMapInfo* _tmp14_ = NULL;
			GstMapInfo* _tmp15_;
			guint8* _tmp16_ = NULL;
			gint _tmp16__length1;
			gint __tmp16__size_;
			GBytes* bytes = NULL;
			GBytes* _tmp18_;
			GMemoryInputStream* stream = NULL;
			GBytes* _tmp19_;
			GMemoryInputStream* _tmp20_;
			GdkPixbuf* _tmp21_ = NULL;
			GMemoryInputStream* _tmp22_;
			GdkPixbuf* _tmp23_;
			GdkPixbuf* _tmp24_;
			_tmp15_ = info;
			_tmp14_ = _tmp15_;
			_tmp16_ = NULL;
			_tmp16__length1 = 0;
			__tmp16__size_ = _tmp16__length1;
			if (_tmp14_ != NULL) {
				guint8* _tmp17_;
				gint _tmp17__length1;
				_tmp17_ = ((GstMapInfo) (*_tmp14_)).data;
				_tmp17__length1 = ((GstMapInfo) (*_tmp14_)).size;
				_tmp16_ = _tmp17_;
				_tmp16__length1 = _tmp17__length1;
				__tmp16__size_ = _tmp16__length1;
			}
			_tmp18_ = g_bytes_new_static (_tmp16_, _tmp16__length1);
			bytes = _tmp18_;
			_tmp19_ = bytes;
			_tmp20_ = (GMemoryInputStream*) g_memory_input_stream_new_from_bytes (_tmp19_);
			stream = _tmp20_;
			_tmp22_ = stream;
			_tmp23_ = gdk_pixbuf_new_from_stream_at_scale ((GInputStream*) _tmp22_, size, size, TRUE, NULL, &_inner_error0_);
			_tmp21_ = _tmp23_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				_g_object_unref0 (stream);
				_g_bytes_unref0 (bytes);
				_g_free0 (_tmp10_);
				_g_free0 (_tmp4_);
				goto __catch0_g_error;
			}
			_tmp24_ = _tmp21_;
			_tmp21_ = NULL;
			result = _tmp24_;
			_g_object_unref0 (_tmp21_);
			_g_object_unref0 (stream);
			_g_bytes_unref0 (bytes);
			_g_free0 (_tmp10_);
			_g_free0 (_tmp4_);
			{
				GError* _inner_error0_ = NULL;
				GstMapInfo* _tmp25_;
				_tmp25_ = info;
				if (_tmp25_ != NULL) {
					GstBuffer* _tmp26_ = NULL;
					GstBuffer* _tmp27_;
					_tmp27_ = buffer;
					_tmp26_ = _tmp27_;
					if (_tmp26_ != NULL) {
						GstMapInfo* _tmp28_;
						GstMapInfo _tmp29_;
						_tmp28_ = info;
						_tmp29_ = (GstMapInfo) (*_tmp28_);
						gst_buffer_unmap ((GstBuffer*) _tmp26_, &_tmp29_);
					}
				}
			}
			_g_free0 (info);
			_gst_buffer_unref0 (buffer);
			return result;
		}
		_g_free0 (_tmp10_);
		_g_free0 (_tmp4_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
	}
	__finally0:
	{
		GError* _inner_error1_ = NULL;
		GstMapInfo* _tmp30_;
		_tmp30_ = info;
		if (_tmp30_ != NULL) {
			GstBuffer* _tmp26_ = NULL;
			GstBuffer* _tmp31_;
			_tmp31_ = buffer;
			_tmp26_ = _tmp31_;
			if (_tmp26_ != NULL) {
				GstMapInfo* _tmp32_;
				GstMapInfo _tmp33_;
				_tmp32_ = info;
				_tmp33_ = (GstMapInfo) (*_tmp32_);
				gst_buffer_unmap ((GstBuffer*) _tmp26_, &_tmp33_);
			}
		}
	}
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (info);
		_gst_buffer_unref0 (buffer);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return NULL;
	}
	result = NULL;
	_g_free0 (info);
	_gst_buffer_unref0 (buffer);
	return result;
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

