/** * gsound_context_open: * @context: A #GSoundContext * @error: Return location for error, or %NULL * * Returns: %TRUE if the output device was opened successfully, or %FALSE * (populating @error) */ gboolean gsound_context_open(GSoundContext *self, GError **error) { g_return_val_if_fail(GSOUND_IS_CONTEXT(self), FALSE); return test_return (ca_context_open(self->priv->ca), error); }
static ca_context* connect_canberra_context(char* device, char* driver) { ca_context* ca = NULL; if (ca_context_create(&ca) != 0) { g_warning("Create canberra context failed"); return NULL; } // set backend driver if (strlen(driver) > 0) { if (ca_context_set_driver(ca, driver) != 0 ) { g_warning("Set '%s' as backend driver failed", driver); ca_context_destroy(ca); return NULL; } } if (strlen(device) > 0) { if (ca_context_change_device(ca, device) != 0) { g_warning("Set '%s' as backend device failed", device); ca_context_destroy(ca); return NULL; } } if (ca_context_open(ca) != 0) { g_warning("Connect the context to sound system failed"); ca_context_destroy(ca); return NULL; } return ca; }
static void _eventd_libcanberra_start(EventdPluginContext *context) { int error; error = ca_context_open(context->context); if ( error < 0 ) g_warning("Couldn't open libcanberra context: %s", ca_strerror(error)); else context->started = TRUE; }
static int canberra_connect () { int error; if (c_context) return TRUE; ca_context_create (&c_context); error = ca_context_open (c_context); if (error) { N_WARNING (LOG_CAT "can't connect to canberra! %s", ca_strerror (error)); ca_context_destroy (c_context); c_context = 0; return FALSE; } return TRUE; }