static void _eventd_libcanberra_event_action(EventdPluginContext *context, const gchar *config_id, EventdEvent *event) { EventdCanberraEvent *canberra_event; canberra_event = g_hash_table_lookup(context->events, config_id); if ( canberra_event == NULL ) return; int error; error = ca_context_play(context->context, 1, CA_PROP_EVENT_ID, canberra_event->sound_name, CA_PROP_MEDIA_ROLE, "event", NULL); if ( error < 0 ) g_warning("Couldn't play named sound '%s': %s", canberra_event->sound_name, ca_strerror(error)); #ifndef ENABLE_SOUND error = ca_context_play(context->context, 1, CA_PROP_MEDIA_FILENAME, canberra_event->sound_file, CA_PROP_MEDIA_ROLE, "event", NULL); if ( error < 0 ) g_warning("Couldn't play sound file '%s': %s", canberra_event->sound_file, ca_strerror(error)); #endif /* ! ENABLE_SOUND */ }
static void play_sound (void) { ca_context_play (ca_gtk_context_get (), UPS_SOUND_LOOP_ID, CA_PROP_EVENT_ID, "battery-caution", CA_PROP_EVENT_DESCRIPTION, _("Battery is critically low"), NULL); }
int canberra_play_sound_file(char *file, char *device, char* driver) { int curid = ++id; setlocale(LC_ALL, ""); ca_context *ca = connect_canberra_context(device, driver); if (ca == NULL) { return -1; } int playret = ca_context_play(ca, curid, CA_PROP_MEDIA_FILENAME, file, NULL); if (playret != CA_SUCCESS) { g_warning("play_sound_file filename:%s id=%d %s\n", file, curid, ca_strerror(playret)); ca_context_destroy(ca); return playret; } // wait for end int playing; do { g_usleep(500 * 1000); // sleep 0.5s int ret = ca_context_playing(ca, curid, &playing); if (ret != CA_SUCCESS) { g_warning("ca_context_playing id=%d %s\n", curid, ca_strerror(ret)); } } while (playing > 0); ca_context_destroy(ca); return playret; }
int canberra_play_system_sound(char *theme, char *event_id, char *device, char* driver) { int curid = ++id; setlocale(LC_ALL, ""); ca_context *ca = connect_canberra_context(device, driver); if (ca == NULL) { return -1; } int playret = ca_context_play(ca, curid, CA_PROP_CANBERRA_XDG_THEME_NAME, theme, CA_PROP_EVENT_ID, event_id, NULL); if (playret != CA_SUCCESS) { g_warning("play: id=%d %s\n", curid, ca_strerror(playret)); ca_context_destroy(ca); return playret; } // wait for end int playing; do { g_usleep(500 * 1000); // sleep 0.5s int ret = ca_context_playing(ca, curid, &playing); if (ret != CA_SUCCESS) { g_warning("ca_context_playing id=%d %s\n", curid, ca_strerror(ret)); } } while (playing > 0); ca_context_destroy(ca); return playret; }
static void workspace_switch_sound(MetaWorkspace *from, MetaWorkspace *to) { MetaWorkspaceLayout layout; int i, nw, x, y, fi, ti; const char *e; nw = meta_screen_get_n_workspaces(from->screen); fi = meta_workspace_index(from); ti = meta_workspace_index(to); meta_screen_calc_workspace_layout(from->screen, nw, fi, &layout); for (i = 0; i < nw; i++) if (layout.grid[i] == ti) break; if (i >= nw) { meta_bug("Failed to find destination workspace in layout\n"); goto finish; } y = i / layout.cols; x = i % layout.cols; /* We priorize horizontal over vertical movements here. The rationale for this is that horizontal movements are probably more interesting for sound effects because speakers are usually positioned on a horizontal and not a vertical axis. i.e. your spatial "Woosh!" effects will easily be able to encode horizontal movement but not such much vertical movement. */ if (x < layout.current_col) e = "desktop-switch-left"; else if (x > layout.current_col) e = "desktop-switch-right"; else if (y < layout.current_row) e = "desktop-switch-up"; else if (y > layout.current_row) e = "desktop-switch-down"; else { meta_bug("Uh, origin and destination workspace at same logic position!\n"); goto finish; } #ifdef HAVE_CANBERRA ca_context_play(ca_gtk_context_get(), 1, CA_PROP_EVENT_ID, e, CA_PROP_EVENT_DESCRIPTION, "Desktop switched", CA_PROP_CANBERRA_CACHE_CONTROL, "permanent", NULL); #endif finish: meta_screen_free_workspace_layout (&layout); }
/// Trigger a sound named \p name, for example "button-pressed"; void play(const char* name) { ca_context_play(m_ctx, 0, CA_PROP_EVENT_ID, name, /* The XDG sound name */ // CA_PROP_MEDIA_NAME, "The user pressed the button foobar", // CA_PROP_EVENT_MOUSE_X, "555", // CA_PROP_EVENT_MOUSE_Y, "666", // CA_PROP_WINDOW_NAME, "Foobar Dialog", // CA_PROP_WINDOW_ICON_NAME, "libcanberra-test-foobar-dialog", // CA_PROP_WINDOW_X11_DISPLAY, ":0", // CA_PROP_WINDOW_X11_XID, "4711", NULL); }
void notify (void) { NotifyNotification *notify; GError *error_notify = NULL; entry_text = gtk_entry_get_text (GTK_ENTRY (entry)); if(g_strcmp0 (entry_text, "Notification text") != 0) notify = notify_notification_new (entry_text, NULL, "clocks"); else notify = notify_notification_new (_("Time is up!"), NULL, "clocks"); notify_notification_set_category (notify, "GTimeUtils"); notify_notification_set_urgency (notify, NOTIFY_URGENCY_NORMAL); notify_notification_show (notify, &error_notify); if(error_notify) g_fprintf (stderr, "Can not initialize notification: %s\n", error_notify->message); ca_context_play(sound, 0, CA_PROP_APPLICATION_NAME, "Gtimer", CA_PROP_EVENT_ID, "complete-copy", CA_PROP_MEDIA_ROLE, "notification", CA_PROP_APPLICATION_ICON_NAME, "clocks", CA_PROP_CANBERRA_CACHE_CONTROL, "never", NULL); }
static void play_music() { static ca_context *notification = NULL; const char *file = "/usr/share/sounds/login.wav"; if (!notification) { ca_context_create(¬ification); ca_context_change_props( notification, CA_PROP_APPLICATION_NAME, "Dawati Alarm Notify", NULL); } ca_context_play(notification, 0, CA_PROP_MEDIA_FILENAME, file, NULL); }