/**
 * empathy_sound_manager_stop:
 * @self: a #EmpathySoundManager
 * @sound_id: The #EmpathySound to stop playing.
 *
 * Stop playing a sound. If it has been stated in loop with
 * empathy_sound_start_playing(), it will also stop replaying.
 */
void
empathy_sound_manager_stop (EmpathySoundManager *self,
    EmpathySound sound_id)
{
  EmpathySoundEntry *entry;
  EmpathyRepeatableSound *repeatable_sound;

  g_return_if_fail (sound_id < LAST_EMPATHY_SOUND);

  entry = &(sound_entries[sound_id]);
  g_return_if_fail (entry->sound_id == sound_id);

  repeatable_sound = g_hash_table_lookup (self->priv->repeating_sounds,
      GINT_TO_POINTER (sound_id));
  if (repeatable_sound != NULL)
    {
      /* The sound must be stopped... If it is waiting for replay, remove
       * it from hash table to cancel. Otherwise we'll cancel the sound
       * being played. */
      if (repeatable_sound->replay_timeout_id != 0)
        {
          g_hash_table_remove (self->priv->repeating_sounds,
              GINT_TO_POINTER (sound_id));
          return;
        }
    }

  ca_context_cancel (ca_gtk_context_get (), entry->sound_id);
}
Example #2
0
static void
_eventd_libcanberra_stop(EventdPluginContext *context)
{
    int error;
    error = ca_context_cancel(context->context, 1);
    if ( error < 0 )
        g_warning("Couldn't cancel sounds: %s", ca_strerror(error));
    context->started = FALSE;
}
Example #3
0
void
play_loop_stop (guint *id)
{
        if (*id == 0)
                return;

        ca_context_cancel (ca_gtk_context_get (), UPS_SOUND_LOOP_ID);
        g_source_remove (*id);
        *id = 0;
}
Example #4
0
static PyObject*
osk_audio_cancel(PyObject* self, PyObject* args)
{
    OskAudio* audio = (OskAudio*) self;
    int ret;

    ret = ca_context_cancel(audio->ca, DEFAULT_SOUND_ID);
    if (ret < 0)
    {
        PyErr_SetString(OSK_EXCEPTION, ca_strerror(ret));
        return NULL;
    }

    Py_RETURN_NONE;
}
static gboolean
empathy_sound_play_internal (GtkWidget *widget, EmpathySound sound_id,
  ca_finish_callback_t callback, gpointer user_data)
{
  EmpathySoundEntry *entry;
  ca_context *c;
  ca_proplist *p = NULL;

  entry = &(sound_entries[sound_id]);
  g_return_val_if_fail (entry->sound_id == sound_id, FALSE);

  c = ca_gtk_context_get ();
  ca_context_cancel (c, entry->sound_id);

  DEBUG ("Play sound \"%s\" (%s)",
         entry->event_ca_id,
         entry->event_ca_description);

  if (ca_proplist_create (&p) < 0)
    goto failed;

  if (ca_proplist_sets (p, CA_PROP_EVENT_ID, entry->event_ca_id) < 0)
    goto failed;

  if (ca_proplist_sets (p, CA_PROP_EVENT_DESCRIPTION,
          gettext (entry->event_ca_description)) < 0)
    goto failed;

  if (ca_gtk_proplist_set_for_widget (p, widget) < 0)
    goto failed;

  ca_context_play_full (ca_gtk_context_get (), entry->sound_id, p, callback,
      user_data);

  ca_proplist_destroy (p);

  return TRUE;

failed:
  if (p != NULL)
    ca_proplist_destroy (p);

  return FALSE;
}
Example #6
0
static void
on_cancellable_cancelled(GCancellable *cancellable,
                         GSoundContext *self)
{
    ca_context_cancel(self->priv->ca, GPOINTER_TO_INT(cancellable));
}