static gboolean osk_audio_init_canberra(OskAudio* audio) { GdkScreen* screen; ca_proplist* props; const char* name; int nr; if (ca_context_create(&audio->ca) != CA_SUCCESS) return FALSE; screen = gdk_screen_get_default(); nr = gdk_screen_get_number(screen); name = gdk_display_get_name(gdk_screen_get_display(screen)); /* Set default application properties */ ca_proplist_create(&props); ca_proplist_sets(props, CA_PROP_APPLICATION_NAME, "Onboard"); ca_proplist_sets(props, CA_PROP_APPLICATION_ID, "org.onboard.Onboard"); ca_proplist_sets(props, CA_PROP_APPLICATION_ICON_NAME, "onboard"); ca_proplist_sets(props, CA_PROP_WINDOW_X11_DISPLAY, name); ca_proplist_setf(props, CA_PROP_WINDOW_X11_SCREEN, "%i", nr); ca_context_change_props_full(audio->ca, props); ca_proplist_destroy(props); return TRUE; }
/** * gsound_context_change_attrsv: * @context: A #GSoundContext * @attrs: (element-type utf8 utf8): Hash table of attributes to set * @error: Return location for error, or %NULL * * Returns: %TRUE if attributes were updated successfully */ gboolean gsound_context_change_attrsv (GSoundContext *self, GHashTable *attrs, GError **error) { ca_proplist *pl; g_return_val_if_fail(GSOUND_IS_CONTEXT(self), FALSE); int res = ca_proplist_create(&pl); if (!test_return (res, error)) return FALSE; hash_table_to_prop_list (attrs, pl); res = ca_context_change_props_full(self->priv->ca, pl); ca_proplist_destroy(pl); return test_return(res, error); }
int ca_context_change_props(ca_context *c, ...) { va_list ap; int ret; ca_proplist *p = NULL; ca_return_val_if_fail(!ca_detect_fork(), CA_ERROR_FORKED); ca_return_val_if_fail(c, CA_ERROR_INVALID); va_start(ap, c); ret = ca_proplist_from_ap(&p, ap); va_end(ap); if (ret < 0) return ret; ret = ca_context_change_props_full(c, p); ca_assert_se(ca_proplist_destroy(p) == 0); return ret; }
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; }
/** * gsound_context_change_attrs: (skip) * @context: A #GSoundContext * @error: Return location for error * @...: %NULL terminated list of attribute name-value pairs * * Returns: %TRUE if attributes were updated successfully */ gboolean gsound_context_change_attrs(GSoundContext *self, GError **error, ...) { ca_proplist *pl; va_list args; int res; g_return_val_if_fail(GSOUND_IS_CONTEXT(self), FALSE); if ((res = ca_proplist_create(&pl)) != CA_SUCCESS) return test_return(res, error); va_start(args, error); var_args_to_prop_list (args, pl); va_end(args); res = ca_context_change_props_full(self->priv->ca, pl); ca_proplist_destroy(pl); return test_return(res, error); }