/** * gsound_context_new: * @cancellable: (allow-none): A #GCancellable, or %NULL * @error: Return location for error * * Returns: (transfer full): A new #GSoundContext */ GSoundContext * gsound_context_new(GCancellable *cancellable, GError **error) { return GSOUND_CONTEXT(g_initable_new(GSOUND_TYPE_CONTEXT, cancellable, error, NULL)); }
static void gsound_context_finalize(GObject *obj) { GSoundContext *self = GSOUND_CONTEXT(obj); ca_context_destroy(self->priv->ca); G_OBJECT_CLASS(gsound_context_parent_class)->finalize(obj); }
static void on_play_finished(GObject *obj, GAsyncResult *result, gpointer user_data) { GError *error = NULL; GMainLoop *main_loop = user_data; gsound_context_play_full_finish(GSOUND_CONTEXT(obj), result, &error); if (error) { g_assert_error(error, G_IO_ERROR, G_IO_ERROR_CANCELLED); g_error_free(error); } else { g_assert_not_reached(); } g_main_loop_quit (main_loop); }
static gboolean gsound_context_real_init(GInitable *initable, GCancellable *cancellable, GError **error) { GSoundContext *self = GSOUND_CONTEXT(initable); if (self->priv->ca) return TRUE; int success = ca_context_create(&self->priv->ca); if (!test_return(success, error)) return FALSE; /* Set a couple of attributes here if we can */ ca_proplist *pl; ca_proplist_create(&pl); ca_proplist_sets(pl, CA_PROP_APPLICATION_NAME, g_get_application_name()); if (g_application_get_default()) { GApplication *app = g_application_get_default (); ca_proplist_sets(pl, CA_PROP_APPLICATION_ID, g_application_get_application_id(app)); } success = ca_context_change_props_full(self->priv->ca, pl); ca_proplist_destroy(pl); if (!test_return(success, error)) { ca_context_destroy(self->priv->ca); self->priv->ca = NULL; } return TRUE; }