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

/*
 * Copyright (c) 2016,2024,2026 focus-timer contributors
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 *
 * Authors: Kamil Prusko <kamilprusko@gmail.com>
 */

#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <config.h>
#include <gio/gio.h>
#include "ft_core.h"
#include <float.h>
#include <math.h>
#include <glib/gi18n-lib.h>
#include <glib-object.h>

#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

#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
enum  {
	FT_SOUND_0_PROPERTY,
	FT_SOUND_URI_PROPERTY,
	FT_SOUND_VOLUME_PROPERTY,
	FT_SOUND_ERROR_PROPERTY,
	FT_SOUND_NUM_PROPERTIES
};
static GParamSpec* ft_sound_properties[FT_SOUND_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
enum  {
	FT_ALERT_SOUND_0_PROPERTY,
	FT_ALERT_SOUND_EVENT_ID_PROPERTY,
	FT_ALERT_SOUND_NUM_PROPERTIES
};
static GParamSpec* ft_alert_sound_properties[FT_ALERT_SOUND_NUM_PROPERTIES];
enum  {
	FT_BACKGROUND_SOUND_0_PROPERTY,
	FT_BACKGROUND_SOUND_LOOP_PROPERTY,
	FT_BACKGROUND_SOUND_NUM_PROPERTIES
};
static GParamSpec* ft_background_sound_properties[FT_BACKGROUND_SOUND_NUM_PROPERTIES];

struct _FtSoundPrivate {
	gdouble _volume;
	GError* _error;
	gchar* _uri;
};

struct _FtAlertSoundPrivate {
	gchar* _event_id;
};

struct _FtBackgroundSoundPrivate {
	gboolean _loop;
};

static gint FtSound_private_offset;
static gpointer ft_sound_parent_class = NULL;
static gint FtAlertSound_private_offset;
static gpointer ft_alert_sound_parent_class = NULL;
static gint FtBackgroundSound_private_offset;
static gpointer ft_background_sound_parent_class = NULL;

VALA_EXTERN gchar* ft_build_absolute_path (const gchar* path);
VALA_EXTERN gchar* ft_build_absolute_uri (const gchar* uri);
VALA_EXTERN gboolean ft_is_mime_type (const gchar* content_type,
                          gchar** mime_types,
                          gint mime_types_length1);
static void ft_sound_prepare (FtSound* self);
static void ft_sound_set_error (FtSound* self,
                         GError* value);
static void ft_sound_on_playback_error (FtSound* self,
                                 GError* _error_);
static void ft_sound_real_initialize_player (FtSound* self);
static void _ft_sound_on_playback_error_ft_sound_player_playback_error (FtSoundPlayer* _sender,
                                                                 GError* _error_,
                                                                 gpointer self);
static void ft_sound_real_destroy_player (FtSound* self);
static void ft_sound_real_destroy (FtSound* self);
static void ft_sound_finalize (GObject * obj);
static GType ft_sound_get_type_once (void);
static void _vala_ft_sound_get_property (GObject * object,
                                  guint property_id,
                                  GValue * value,
                                  GParamSpec * pspec);
static void _vala_ft_sound_set_property (GObject * object,
                                  guint property_id,
                                  const GValue * value,
                                  GParamSpec * pspec);
static void ft_alert_sound_finalize (GObject * obj);
static GType ft_alert_sound_get_type_once (void);
static void _vala_ft_alert_sound_get_property (GObject * object,
                                        guint property_id,
                                        GValue * value,
                                        GParamSpec * pspec);
static void _vala_ft_alert_sound_set_property (GObject * object,
                                        guint property_id,
                                        const GValue * value,
                                        GParamSpec * pspec);
static void ft_background_sound_real_initialize_player (FtSound* base);
static void ft_background_sound_finalize (GObject * obj);
static GType ft_background_sound_get_type_once (void);
static void _vala_ft_background_sound_get_property (GObject * object,
                                             guint property_id,
                                             GValue * value,
                                             GParamSpec * pspec);
static void _vala_ft_background_sound_set_property (GObject * object,
                                             guint property_id,
                                             const GValue * value,
                                             GParamSpec * pspec);
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);

gchar*
ft_build_absolute_path (const gchar* path)
{
	gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (path != NULL, NULL);
	_tmp0_ = g_build_filename (PACKAGE_DATA_DIR, "sounds", path, NULL);
	result = _tmp0_;
	return result;
}

gchar*
ft_build_absolute_uri (const gchar* uri)
{
	gchar* scheme = NULL;
	gchar* _tmp0_;
	gboolean _tmp1_ = FALSE;
	const gchar* _tmp2_;
	gchar* _tmp13_;
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (uri != NULL, NULL);
	_tmp0_ = g_uri_parse_scheme (uri);
	scheme = _tmp0_;
	_tmp2_ = scheme;
	if (_tmp2_ == NULL) {
		_tmp1_ = g_strcmp0 (uri, "") != 0;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		gchar* preset_filename = NULL;
		gchar* _tmp3_;
		gchar* preset_path = NULL;
		const gchar* _tmp4_;
		gchar* _tmp5_;
		_tmp3_ = g_strdup (uri);
		preset_filename = _tmp3_;
		_tmp4_ = preset_filename;
		_tmp5_ = ft_build_absolute_path (_tmp4_);
		preset_path = _tmp5_;
		{
			gchar* _tmp6_ = NULL;
			const gchar* _tmp7_;
			gchar* _tmp8_;
			gchar* _tmp9_;
			_tmp7_ = preset_path;
			_tmp8_ = g_filename_to_uri (_tmp7_, NULL, &_inner_error0_);
			_tmp6_ = _tmp8_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				if (_inner_error0_->domain == G_CONVERT_ERROR) {
					goto __catch0_g_convert_error;
				}
				_g_free0 (preset_path);
				_g_free0 (preset_filename);
				_g_free0 (scheme);
				g_critical ("file %s: line %d: unexpected 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;
			}
			_tmp9_ = _tmp6_;
			_tmp6_ = NULL;
			result = _tmp9_;
			_g_free0 (_tmp6_);
			_g_free0 (preset_path);
			_g_free0 (preset_filename);
			_g_free0 (scheme);
			return result;
		}
		goto __finally0;
		__catch0_g_convert_error:
		{
			GError* _error_ = NULL;
			const gchar* _tmp10_;
			GError* _tmp11_;
			const gchar* _tmp12_;
			_error_ = _inner_error0_;
			_inner_error0_ = NULL;
			_tmp10_ = preset_path;
			_tmp11_ = _error_;
			_tmp12_ = _tmp11_->message;
			g_warning ("sounds.vala:33: Failed to convert \"%s\" to URI: %s", _tmp10_, _tmp12_);
			_g_error_free0 (_error_);
		}
		__finally0:
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_free0 (preset_path);
			_g_free0 (preset_filename);
			_g_free0 (scheme);
			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;
		}
		_g_free0 (preset_path);
		_g_free0 (preset_filename);
	}
	_tmp13_ = g_strdup (uri);
	result = _tmp13_;
	_g_free0 (scheme);
	return result;
}

gboolean
ft_is_mime_type (const gchar* content_type,
                 gchar** mime_types,
                 gint mime_types_length1)
{
	gboolean result;
	g_return_val_if_fail (content_type != NULL, FALSE);
	if (g_content_type_is_unknown (content_type)) {
		result = FALSE;
		return result;
	}
	{
		gchar** mime_type_collection = NULL;
		gint mime_type_collection_length1 = 0;
		gint _mime_type_collection_size_ = 0;
		gint mime_type_it = 0;
		mime_type_collection = mime_types;
		mime_type_collection_length1 = mime_types_length1;
		for (mime_type_it = 0; mime_type_it < mime_type_collection_length1; mime_type_it = mime_type_it + 1) {
			gchar* _tmp0_;
			gchar* mime_type = NULL;
			_tmp0_ = g_strdup (mime_type_collection[mime_type_it]);
			mime_type = _tmp0_;
			{
				const gchar* _tmp1_;
				_tmp1_ = mime_type;
				if (g_content_type_is_mime_type (content_type, _tmp1_)) {
					result = TRUE;
					_g_free0 (mime_type);
					return result;
				}
				_g_free0 (mime_type);
			}
		}
	}
	result = FALSE;
	return result;
}

GQuark
ft_sound_error_quark (void)
{
	return g_quark_from_static_string ("ft-sound-error-quark");
}

static GType
ft_sound_error_get_type_once (void)
{
	static const GEnumValue values[] = {{FT_SOUND_ERROR_NOT_FOUND, "FT_SOUND_ERROR_NOT_FOUND", "not-found"}, {FT_SOUND_ERROR_NOT_INITIALIZED, "FT_SOUND_ERROR_NOT_INITIALIZED", "not-initialized"}, {FT_SOUND_ERROR_NOT_SUPPORTED, "FT_SOUND_ERROR_NOT_SUPPORTED", "not-supported"}, {0, NULL, NULL}};
	GType ft_sound_error_type_id;
	ft_sound_error_type_id = g_enum_register_static ("FtSoundError", values);
	return ft_sound_error_type_id;
}

GType
ft_sound_error_get_type (void)
{
	static volatile gsize ft_sound_error_type_id__once = 0;
	if (g_once_init_enter (&ft_sound_error_type_id__once)) {
		GType ft_sound_error_type_id;
		ft_sound_error_type_id = ft_sound_error_get_type_once ();
		g_once_init_leave (&ft_sound_error_type_id__once, ft_sound_error_type_id);
	}
	return ft_sound_error_type_id__once;
}

static inline gpointer
ft_sound_get_instance_private (FtSound* self)
{
	return G_STRUCT_MEMBER_P (self, FtSound_private_offset);
}

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

static void
ft_sound_prepare (FtSound* self)
{
	gchar* uri = NULL;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_uri;
	_tmp1_ = ft_build_absolute_uri (_tmp0_);
	uri = _tmp1_;
	{
		const gchar* _tmp2_;
		FtSoundPlayer* _tmp18_ = NULL;
		const gchar* _tmp19_;
		FtSoundPlayer* player = NULL;
		FtSoundPlayer* _tmp25_;
		FtSoundPlayer* _tmp26_;
		FtSoundPlayer* _tmp27_;
		GError* _tmp32_;
		FtSoundPlayer* _tmp33_;
		_tmp2_ = uri;
		if (g_strcmp0 (_tmp2_, "") != 0) {
			GFile* file = NULL;
			const gchar* _tmp3_;
			GFile* _tmp4_;
			gchar* content_type = NULL;
			GFile* _tmp5_;
			gchar* _tmp6_;
			gchar* _tmp7_;
			gchar* _tmp8_;
			gchar* _tmp9_;
			GFile* _tmp10_;
			const gchar* _tmp12_;
			gint _tmp13_ = 0;
			gchar** _tmp14_;
			gchar** _tmp15_;
			gint _tmp15__length1;
			gboolean _tmp16_;
			_tmp3_ = uri;
			_tmp4_ = g_file_new_for_uri (_tmp3_);
			file = _tmp4_;
			_tmp5_ = file;
			_tmp6_ = g_file_get_basename (_tmp5_);
			_tmp7_ = _tmp6_;
			_tmp8_ = g_content_type_guess (_tmp7_, NULL, (gsize) 0, NULL);
			_tmp9_ = _tmp8_;
			_g_free0 (_tmp7_);
			content_type = _tmp9_;
			_tmp10_ = file;
			if (!g_file_query_exists (_tmp10_, NULL)) {
				GError* _tmp11_;
				_tmp11_ = g_error_new_literal (FT_SOUND_ERROR, FT_SOUND_ERROR_NOT_FOUND, _ ("File not found"));
				_inner_error0_ = _tmp11_;
				_g_free0 (content_type);
				_g_object_unref0 (file);
				goto __catch0_g_error;
			}
			_tmp12_ = content_type;
			_tmp14_ = ft_sound_player_get_supported_mime_types (&_tmp13_);
			_tmp15_ = _tmp14_;
			_tmp15__length1 = _tmp13_;
			_tmp16_ = !ft_is_mime_type (_tmp12_, _tmp15_, (gint) _tmp13_);
			_tmp15_ = (_vala_array_free (_tmp15_, _tmp15__length1, (GDestroyNotify) g_free), NULL);
			if (_tmp16_) {
				GError* _tmp17_;
				_tmp17_ = g_error_new_literal (FT_SOUND_ERROR, FT_SOUND_ERROR_NOT_SUPPORTED, _ ("File type not supported"));
				_inner_error0_ = _tmp17_;
				_g_free0 (content_type);
				_g_object_unref0 (file);
				goto __catch0_g_error;
			}
			_g_free0 (content_type);
			_g_object_unref0 (file);
		}
		_tmp19_ = uri;
		if (g_strcmp0 (_tmp19_, "") != 0) {
			FtSoundPlayer* _tmp20_ = NULL;
			FtSoundPlayer* _tmp21_;
			FtSoundPlayer* _tmp22_;
			FtSoundPlayer* _tmp24_;
			_tmp21_ = self->player;
			_tmp22_ = _g_object_ref0 (_tmp21_);
			_tmp20_ = _tmp22_;
			if (_tmp20_ == NULL) {
				FtSoundPlayer* _tmp23_;
				_tmp23_ = ft_sound_player_new (&_inner_error0_);
				_g_object_unref0 (_tmp20_);
				_tmp20_ = _tmp23_;
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					_g_object_unref0 (_tmp20_);
					_g_object_unref0 (_tmp18_);
					goto __catch0_g_error;
				}
			}
			_tmp24_ = _tmp20_;
			_tmp20_ = NULL;
			_g_object_unref0 (_tmp18_);
			_tmp18_ = _tmp24_;
			_g_object_unref0 (_tmp20_);
		} else {
			_g_object_unref0 (_tmp18_);
			_tmp18_ = NULL;
		}
		_tmp25_ = _tmp18_;
		_tmp18_ = NULL;
		player = _tmp25_;
		_tmp26_ = self->player;
		_tmp27_ = player;
		if (_tmp26_ != _tmp27_) {
			FtSoundPlayer* _tmp28_;
			FtSoundPlayer* _tmp29_;
			FtSoundPlayer* _tmp30_;
			FtSoundPlayer* _tmp31_;
			_tmp28_ = self->player;
			if (_tmp28_ != NULL) {
				ft_sound_destroy_player (self);
			}
			_tmp29_ = player;
			_tmp30_ = _g_object_ref0 (_tmp29_);
			_g_object_unref0 (self->player);
			self->player = _tmp30_;
			_tmp31_ = self->player;
			if (_tmp31_ != NULL) {
				ft_sound_initialize_player (self);
			}
		}
		_tmp32_ = self->priv->_error;
		if (_tmp32_ != NULL) {
			ft_sound_set_error (self, NULL);
		}
		_tmp33_ = player;
		if (_tmp33_ != NULL) {
			FtSoundPlayer* _tmp34_;
			const gchar* _tmp35_;
			_tmp34_ = player;
			_tmp35_ = uri;
			ft_sound_player_set_uri (_tmp34_, _tmp35_);
		}
		_g_object_unref0 (player);
		_g_object_unref0 (_tmp18_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* _error_ = NULL;
		const gchar* _tmp36_;
		GError* _tmp37_;
		const gchar* _tmp38_;
		FtSoundPlayer* _tmp39_;
		GError* _tmp40_;
		_error_ = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp36_ = uri;
		_tmp37_ = _error_;
		_tmp38_ = _tmp37_->message;
		g_warning ("sounds.vala:148: Error while initializing sound player for uri=%s: %s", _tmp36_, _tmp38_);
		_tmp39_ = self->player;
		if (_tmp39_ != NULL) {
			ft_sound_destroy_player (self);
			_g_object_unref0 (self->player);
			self->player = NULL;
		}
		_tmp40_ = _error_;
		ft_sound_set_error (self, _tmp40_);
		_g_error_free0 (_error_);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_free0 (uri);
		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;
	}
	_g_free0 (uri);
}

static void
ft_sound_on_playback_error (FtSound* self,
                            GError* _error_)
{
	FtSoundPlayer* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (_error_ != NULL);
	_tmp0_ = self->player;
	_tmp1_ = ft_sound_player_get_uri (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = _error_->message;
	g_warning ("sounds.vala:163: Playback error for uri=%s: %s", _tmp2_, _tmp3_);
	ft_sound_set_error (self, _error_);
}

gboolean
ft_sound_can_play (FtSound* self)
{
	FtSoundPlayer* _tmp0_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->player;
	result = _tmp0_ != NULL;
	return result;
}

gboolean
ft_sound_is_playing (FtSound* self)
{
	gboolean _tmp0_ = FALSE;
	FtSoundPlayer* _tmp1_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp1_ = self->player;
	if (_tmp1_ != NULL) {
		FtSoundPlayer* _tmp2_;
		_tmp2_ = self->player;
		_tmp0_ = ft_sound_player_is_playing (_tmp2_);
	} else {
		_tmp0_ = FALSE;
	}
	result = _tmp0_;
	return result;
}

void
ft_sound_play (FtSound* self)
{
	gboolean _tmp0_ = FALSE;
	FtSoundPlayer* _tmp1_;
	FtSoundPlayer* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp1_ = self->player;
	if (_tmp1_ == NULL) {
		const gchar* _tmp2_;
		_tmp2_ = self->priv->_uri;
		_tmp0_ = g_strcmp0 (_tmp2_, "") != 0;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		ft_sound_prepare (self);
	}
	_tmp3_ = self->player;
	if (_tmp3_ != NULL) {
		FtSoundPlayer* _tmp4_;
		_tmp4_ = self->player;
		ft_sound_player_play (_tmp4_);
	}
}

void
ft_sound_stop (FtSound* self)
{
	FtSoundPlayer* _tmp0_ = NULL;
	FtSoundPlayer* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp1_ = self->player;
	_tmp0_ = _tmp1_;
	if (_tmp0_ != NULL) {
		ft_sound_player_stop (_tmp0_);
	}
}

static void
_ft_sound_on_playback_error_ft_sound_player_playback_error (FtSoundPlayer* _sender,
                                                            GError* _error_,
                                                            gpointer self)
{
	ft_sound_on_playback_error ((FtSound*) self, _error_);
}

static void
ft_sound_real_initialize_player (FtSound* self)
{
	FtSoundPlayer* _tmp0_;
	FtSoundPlayer* _tmp1_;
	_tmp0_ = self->player;
	g_object_bind_property_with_closures ((GObject*) self, "volume", (GObject*) _tmp0_, "volume", G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp1_ = self->player;
	g_signal_connect_object (_tmp1_, "playback-error", (GCallback) _ft_sound_on_playback_error_ft_sound_player_playback_error, self, 0);
}

void
ft_sound_initialize_player (FtSound* self)
{
	FtSoundClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = FT_SOUND_GET_CLASS (self);
	if (_klass_->initialize_player) {
		_klass_->initialize_player (self);
	}
}

static void
ft_sound_real_destroy_player (FtSound* self)
{
	FtSoundPlayer* _tmp0_;
	guint _tmp1_;
	FtSoundPlayer* _tmp2_;
	_tmp0_ = self->player;
	g_signal_parse_name ("playback-error", FT_TYPE_SOUND_PLAYER, &_tmp1_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_tmp0_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp1_, 0, NULL, (GCallback) _ft_sound_on_playback_error_ft_sound_player_playback_error, self);
	_tmp2_ = self->player;
	ft_sound_player_stop (_tmp2_);
}

void
ft_sound_destroy_player (FtSound* self)
{
	FtSoundClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = FT_SOUND_GET_CLASS (self);
	if (_klass_->destroy_player) {
		_klass_->destroy_player (self);
	}
}

static void
ft_sound_real_destroy (FtSound* self)
{
	FtSoundPlayer* _tmp0_;
	_tmp0_ = self->player;
	if (_tmp0_ != NULL) {
		ft_sound_destroy_player (self);
		_g_object_unref0 (self->player);
		self->player = NULL;
	}
}

void
ft_sound_destroy (FtSound* self)
{
	FtSoundClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = FT_SOUND_GET_CLASS (self);
	if (_klass_->destroy) {
		_klass_->destroy (self);
	}
}

FtSound*
ft_sound_construct (GType object_type)
{
	FtSound * self = NULL;
	self = (FtSound*) g_object_new (object_type, NULL);
	return self;
}

const gchar*
ft_sound_get_uri (FtSound* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_uri;
	result = _tmp0_;
	return result;
}

void
ft_sound_set_uri (FtSound* self,
                  const gchar* value)
{
	const gchar* _tmp0_ = NULL;
	gchar* uri = NULL;
	gchar* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	if (_tmp0_ == NULL) {
		_tmp0_ = "";
	}
	_tmp1_ = g_strdup (_tmp0_);
	uri = _tmp1_;
	_tmp2_ = self->priv->_uri;
	_tmp3_ = uri;
	if (g_strcmp0 (_tmp2_, _tmp3_) != 0) {
		const gchar* _tmp4_;
		gchar* _tmp5_;
		_tmp4_ = uri;
		_tmp5_ = g_strdup (_tmp4_);
		_g_free0 (self->priv->_uri);
		self->priv->_uri = _tmp5_;
		ft_sound_prepare (self);
		g_object_notify ((GObject*) self, "uri");
	} else {
		GError* _tmp6_;
		_tmp6_ = self->priv->_error;
		if (_tmp6_ != NULL) {
			ft_sound_prepare (self);
		}
	}
	_g_free0 (uri);
}

gdouble
ft_sound_get_volume (FtSound* self)
{
	gdouble result;
	g_return_val_if_fail (self != NULL, -1.0);
	result = self->priv->_volume;
	return result;
}

void
ft_sound_set_volume (FtSound* self,
                     gdouble value)
{
	gdouble old_value;
	g_return_if_fail (self != NULL);
	old_value = ft_sound_get_volume (self);
	if (old_value != value) {
		self->priv->_volume = value;
		g_object_notify_by_pspec ((GObject *) self, ft_sound_properties[FT_SOUND_VOLUME_PROPERTY]);
	}
}

GError*
ft_sound_get_error (FtSound* self)
{
	GError* result;
	GError* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_error;
	result = _tmp0_;
	return result;
}

static gpointer
_g_error_copy0 (gpointer self)
{
	return self ? g_error_copy (self) : NULL;
}

static void
ft_sound_set_error (FtSound* self,
                    GError* value)
{
	GError* old_value;
	g_return_if_fail (self != NULL);
	old_value = ft_sound_get_error (self);
	if (old_value != value) {
		GError* _tmp0_;
		_tmp0_ = _g_error_copy0 (value);
		_g_error_free0 (self->priv->_error);
		self->priv->_error = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, ft_sound_properties[FT_SOUND_ERROR_PROPERTY]);
	}
}

static void
ft_sound_class_init (FtSoundClass * klass,
                     gpointer klass_data)
{
	ft_sound_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &FtSound_private_offset);
	((FtSoundClass *) klass)->initialize_player = (void (*) (FtSound*)) ft_sound_real_initialize_player;
	((FtSoundClass *) klass)->destroy_player = (void (*) (FtSound*)) ft_sound_real_destroy_player;
	((FtSoundClass *) klass)->destroy = (void (*) (FtSound*)) ft_sound_real_destroy;
	G_OBJECT_CLASS (klass)->get_property = _vala_ft_sound_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_ft_sound_set_property;
	G_OBJECT_CLASS (klass)->finalize = ft_sound_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_SOUND_URI_PROPERTY, ft_sound_properties[FT_SOUND_URI_PROPERTY] = g_param_spec_string ("uri", "uri", "uri", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_EXPLICIT_NOTIFY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_SOUND_VOLUME_PROPERTY, ft_sound_properties[FT_SOUND_VOLUME_PROPERTY] = g_param_spec_double ("volume", "volume", "volume", -G_MAXDOUBLE, G_MAXDOUBLE, 1.0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_SOUND_ERROR_PROPERTY, ft_sound_properties[FT_SOUND_ERROR_PROPERTY] = g_param_spec_boxed ("error", "error", "error", G_TYPE_ERROR, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
ft_sound_instance_init (FtSound * self,
                        gpointer klass)
{
	gchar* _tmp0_;
	self->priv = ft_sound_get_instance_private (self);
	self->priv->_volume = 1.0;
	_tmp0_ = g_strdup ("");
	self->priv->_uri = _tmp0_;
	self->player = NULL;
}

static void
ft_sound_finalize (GObject * obj)
{
	FtSound * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_SOUND, FtSound);
	_g_error_free0 (self->priv->_error);
	_g_free0 (self->priv->_uri);
	_g_object_unref0 (self->player);
	G_OBJECT_CLASS (ft_sound_parent_class)->finalize (obj);
}

/**
     * A sound player instance is intended for playing a single sound multiple times.
     */
static GType
ft_sound_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FtSoundClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ft_sound_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FtSound), 0, (GInstanceInitFunc) ft_sound_instance_init, NULL };
	GType ft_sound_type_id;
	ft_sound_type_id = g_type_register_static (G_TYPE_OBJECT, "FtSound", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
	FtSound_private_offset = g_type_add_instance_private (ft_sound_type_id, sizeof (FtSoundPrivate));
	return ft_sound_type_id;
}

GType
ft_sound_get_type (void)
{
	static volatile gsize ft_sound_type_id__once = 0;
	if (g_once_init_enter (&ft_sound_type_id__once)) {
		GType ft_sound_type_id;
		ft_sound_type_id = ft_sound_get_type_once ();
		g_once_init_leave (&ft_sound_type_id__once, ft_sound_type_id);
	}
	return ft_sound_type_id__once;
}

static void
_vala_ft_sound_get_property (GObject * object,
                             guint property_id,
                             GValue * value,
                             GParamSpec * pspec)
{
	FtSound * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FT_TYPE_SOUND, FtSound);
	switch (property_id) {
		case FT_SOUND_URI_PROPERTY:
		g_value_set_string (value, ft_sound_get_uri (self));
		break;
		case FT_SOUND_VOLUME_PROPERTY:
		g_value_set_double (value, ft_sound_get_volume (self));
		break;
		case FT_SOUND_ERROR_PROPERTY:
		g_value_set_boxed (value, ft_sound_get_error (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_ft_sound_set_property (GObject * object,
                             guint property_id,
                             const GValue * value,
                             GParamSpec * pspec)
{
	FtSound * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FT_TYPE_SOUND, FtSound);
	switch (property_id) {
		case FT_SOUND_URI_PROPERTY:
		ft_sound_set_uri (self, g_value_get_string (value));
		break;
		case FT_SOUND_VOLUME_PROPERTY:
		ft_sound_set_volume (self, g_value_get_double (value));
		break;
		case FT_SOUND_ERROR_PROPERTY:
		ft_sound_set_error (self, g_value_get_boxed (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
ft_alert_sound_get_instance_private (FtAlertSound* self)
{
	return G_STRUCT_MEMBER_P (self, FtAlertSound_private_offset);
}

FtAlertSound*
ft_alert_sound_construct (GType object_type,
                          const gchar* event_id)
{
	FtAlertSound * self = NULL;
	g_return_val_if_fail (event_id != NULL, NULL);
	self = (FtAlertSound*) g_object_new (object_type, "event-id", event_id, NULL);
	return self;
}

FtAlertSound*
ft_alert_sound_new (const gchar* event_id)
{
	return ft_alert_sound_construct (FT_TYPE_ALERT_SOUND, event_id);
}

const gchar*
ft_alert_sound_get_event_id (FtAlertSound* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_event_id;
	result = _tmp0_;
	return result;
}

static void
ft_alert_sound_set_event_id (FtAlertSound* self,
                             const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = ft_alert_sound_get_event_id (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_event_id);
		self->priv->_event_id = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, ft_alert_sound_properties[FT_ALERT_SOUND_EVENT_ID_PROPERTY]);
	}
}

static void
ft_alert_sound_class_init (FtAlertSoundClass * klass,
                           gpointer klass_data)
{
	ft_alert_sound_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &FtAlertSound_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_ft_alert_sound_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_ft_alert_sound_set_property;
	G_OBJECT_CLASS (klass)->finalize = ft_alert_sound_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_ALERT_SOUND_EVENT_ID_PROPERTY, ft_alert_sound_properties[FT_ALERT_SOUND_EVENT_ID_PROPERTY] = g_param_spec_string ("event-id", "event-id", "event-id", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}

static void
ft_alert_sound_instance_init (FtAlertSound * self,
                              gpointer klass)
{
	self->priv = ft_alert_sound_get_instance_private (self);
}

static void
ft_alert_sound_finalize (GObject * obj)
{
	FtAlertSound * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_ALERT_SOUND, FtAlertSound);
	_g_free0 (self->priv->_event_id);
	G_OBJECT_CLASS (ft_alert_sound_parent_class)->finalize (obj);
}

static GType
ft_alert_sound_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FtAlertSoundClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ft_alert_sound_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FtAlertSound), 0, (GInstanceInitFunc) ft_alert_sound_instance_init, NULL };
	GType ft_alert_sound_type_id;
	ft_alert_sound_type_id = g_type_register_static (FT_TYPE_SOUND, "FtAlertSound", &g_define_type_info, 0);
	FtAlertSound_private_offset = g_type_add_instance_private (ft_alert_sound_type_id, sizeof (FtAlertSoundPrivate));
	return ft_alert_sound_type_id;
}

GType
ft_alert_sound_get_type (void)
{
	static volatile gsize ft_alert_sound_type_id__once = 0;
	if (g_once_init_enter (&ft_alert_sound_type_id__once)) {
		GType ft_alert_sound_type_id;
		ft_alert_sound_type_id = ft_alert_sound_get_type_once ();
		g_once_init_leave (&ft_alert_sound_type_id__once, ft_alert_sound_type_id);
	}
	return ft_alert_sound_type_id__once;
}

static void
_vala_ft_alert_sound_get_property (GObject * object,
                                   guint property_id,
                                   GValue * value,
                                   GParamSpec * pspec)
{
	FtAlertSound * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FT_TYPE_ALERT_SOUND, FtAlertSound);
	switch (property_id) {
		case FT_ALERT_SOUND_EVENT_ID_PROPERTY:
		g_value_set_string (value, ft_alert_sound_get_event_id (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_ft_alert_sound_set_property (GObject * object,
                                   guint property_id,
                                   const GValue * value,
                                   GParamSpec * pspec)
{
	FtAlertSound * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FT_TYPE_ALERT_SOUND, FtAlertSound);
	switch (property_id) {
		case FT_ALERT_SOUND_EVENT_ID_PROPERTY:
		ft_alert_sound_set_event_id (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
ft_background_sound_get_instance_private (FtBackgroundSound* self)
{
	return G_STRUCT_MEMBER_P (self, FtBackgroundSound_private_offset);
}

static void
ft_background_sound_real_initialize_player (FtSound* base)
{
	FtBackgroundSound * self;
	FtSoundPlayer* _tmp0_;
	self = (FtBackgroundSound*) base;
	FT_SOUND_CLASS (ft_background_sound_parent_class)->initialize_player (G_TYPE_CHECK_INSTANCE_CAST (self, FT_TYPE_SOUND, FtSound));
	_tmp0_ = ((FtSound*) self)->player;
	g_object_bind_property_with_closures ((GObject*) self, "loop", (GObject*) _tmp0_, "loop", G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
}

void
ft_background_sound_fade_in (FtBackgroundSound* self,
                             gint64 duration)
{
	FtSoundPlayer* _tmp0_ = NULL;
	FtSoundPlayer* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp1_ = ((FtSound*) self)->player;
	_tmp0_ = _tmp1_;
	if (_tmp0_ != NULL) {
		ft_sound_player_fade_in (_tmp0_, duration);
	}
}

void
ft_background_sound_fade_out (FtBackgroundSound* self,
                              gint64 duration)
{
	FtSoundPlayer* _tmp0_ = NULL;
	FtSoundPlayer* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp1_ = ((FtSound*) self)->player;
	_tmp0_ = _tmp1_;
	if (_tmp0_ != NULL) {
		ft_sound_player_fade_out (_tmp0_, duration);
	}
}

FtBackgroundSound*
ft_background_sound_construct (GType object_type)
{
	FtBackgroundSound * self = NULL;
	self = (FtBackgroundSound*) ft_sound_construct (object_type);
	return self;
}

FtBackgroundSound*
ft_background_sound_new (void)
{
	return ft_background_sound_construct (FT_TYPE_BACKGROUND_SOUND);
}

gboolean
ft_background_sound_get_loop (FtBackgroundSound* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_loop;
	return result;
}

void
ft_background_sound_set_loop (FtBackgroundSound* self,
                              gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = ft_background_sound_get_loop (self);
	if (old_value != value) {
		self->priv->_loop = value;
		g_object_notify_by_pspec ((GObject *) self, ft_background_sound_properties[FT_BACKGROUND_SOUND_LOOP_PROPERTY]);
	}
}

static void
ft_background_sound_class_init (FtBackgroundSoundClass * klass,
                                gpointer klass_data)
{
	ft_background_sound_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &FtBackgroundSound_private_offset);
	((FtSoundClass *) klass)->initialize_player = (void (*) (FtSound*)) ft_background_sound_real_initialize_player;
	G_OBJECT_CLASS (klass)->get_property = _vala_ft_background_sound_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_ft_background_sound_set_property;
	G_OBJECT_CLASS (klass)->finalize = ft_background_sound_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_BACKGROUND_SOUND_LOOP_PROPERTY, ft_background_sound_properties[FT_BACKGROUND_SOUND_LOOP_PROPERTY] = g_param_spec_boolean ("loop", "loop", "loop", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
ft_background_sound_instance_init (FtBackgroundSound * self,
                                   gpointer klass)
{
	self->priv = ft_background_sound_get_instance_private (self);
	self->priv->_loop = FALSE;
}

static void
ft_background_sound_finalize (GObject * obj)
{
	FtBackgroundSound * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_BACKGROUND_SOUND, FtBackgroundSound);
	G_OBJECT_CLASS (ft_background_sound_parent_class)->finalize (obj);
}

static GType
ft_background_sound_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FtBackgroundSoundClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ft_background_sound_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FtBackgroundSound), 0, (GInstanceInitFunc) ft_background_sound_instance_init, NULL };
	GType ft_background_sound_type_id;
	ft_background_sound_type_id = g_type_register_static (FT_TYPE_SOUND, "FtBackgroundSound", &g_define_type_info, 0);
	FtBackgroundSound_private_offset = g_type_add_instance_private (ft_background_sound_type_id, sizeof (FtBackgroundSoundPrivate));
	return ft_background_sound_type_id;
}

GType
ft_background_sound_get_type (void)
{
	static volatile gsize ft_background_sound_type_id__once = 0;
	if (g_once_init_enter (&ft_background_sound_type_id__once)) {
		GType ft_background_sound_type_id;
		ft_background_sound_type_id = ft_background_sound_get_type_once ();
		g_once_init_leave (&ft_background_sound_type_id__once, ft_background_sound_type_id);
	}
	return ft_background_sound_type_id__once;
}

static void
_vala_ft_background_sound_get_property (GObject * object,
                                        guint property_id,
                                        GValue * value,
                                        GParamSpec * pspec)
{
	FtBackgroundSound * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FT_TYPE_BACKGROUND_SOUND, FtBackgroundSound);
	switch (property_id) {
		case FT_BACKGROUND_SOUND_LOOP_PROPERTY:
		g_value_set_boolean (value, ft_background_sound_get_loop (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_ft_background_sound_set_property (GObject * object,
                                        guint property_id,
                                        const GValue * value,
                                        GParamSpec * pspec)
{
	FtBackgroundSound * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FT_TYPE_BACKGROUND_SOUND, FtBackgroundSound);
	switch (property_id) {
		case FT_BACKGROUND_SOUND_LOOP_PROPERTY:
		ft_background_sound_set_loop (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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;
}

