Exemplo n.º 1
0
static gboolean
modem_tones_timeout(gpointer _self)
{
  MODEM_TONES(_self)->priv->timeout = 0;
  modem_tones_stop(MODEM_TONES(_self), 0);
  return FALSE;
}
Exemplo n.º 2
0
guint
modem_tones_start_full(ModemTones *self,
  int event,
  int volume,
  unsigned duration,
  ModemTonesStoppedNotify *notify,
  gpointer data)
{
  ModemTonesPrivate *priv = self->priv;

  g_return_val_if_fail(!priv->dispose_has_run, 0);

  volume += priv->volume;

  if (volume > 0)
    volume = 0;
  else if (volume < -63)
    volume = -63;

  if (event == TONES_EVENT_DROPPED) {
    if (duration > 1200)
      duration = 1200;
  }

  modem_tones_stop(self, 0);

  if (event < 0)
    return 0;

  if (priv->source == 0)
    priv->source++;

  priv->playing = priv->source++;
  priv->event = event;
  priv->evolume = volume;
  priv->duration = duration;

  if (duration) {
    priv->timeout = g_timeout_add_full(G_PRIORITY_DEFAULT, duration,
                    modem_tones_timeout, self, modem_tones_timeout_removed);
  }

  priv->data = data;
  priv->notify = notify;

  g_timer_start(priv->timer);

  DEBUG("calling StartEventTone(%u, %d, %u) with %u",
    priv->event, priv->evolume, priv->duration, priv->playing);

  dbus_g_proxy_call_no_reply(priv->proxy,
    "StartEventTone",
    G_TYPE_UINT, priv->event,
    G_TYPE_INT, priv->evolume,
    G_TYPE_UINT, priv->duration,
    G_TYPE_INVALID);

  return priv->playing;
}
Exemplo n.º 3
0
static void
modem_tones_dispose(GObject *object)
{
  ModemTones *self = MODEM_TONES(object);
  ModemTonesPrivate *priv = self->priv;

  if (priv->dispose_has_run)
    return;
  priv->dispose_has_run = 1;
  modem_tones_stop(self, 0);
  priv->dispose_has_run = 2;
  g_assert(!priv->event_id);

  if (G_OBJECT_CLASS(modem_tones_parent_class)->dispose)
    G_OBJECT_CLASS(modem_tones_parent_class)->dispose(object);
}
Exemplo n.º 4
0
static void
modem_tones_dispose(GObject *object)
{
  ModemTones *self = MODEM_TONES(object);
  ModemTonesPrivate *priv = self->priv;

  if (priv->dispose_has_run)
    return;
  priv->dispose_has_run = 1;
  modem_tones_stop(self, 0);
  priv->dispose_has_run = 2;
  while (!g_queue_is_empty(priv->stop_requests)) {
    modem_request_cancel(g_queue_pop_head(priv->stop_requests));
  }
  g_assert(!priv->playing);
  g_object_run_dispose(G_OBJECT(priv->proxy));

  if (G_OBJECT_CLASS(modem_tones_parent_class)->dispose)
    G_OBJECT_CLASS(modem_tones_parent_class)->dispose(object);
}
Exemplo n.º 5
0
guint
modem_tones_start_full(ModemTones *self,
  int event,
  int volume,
  unsigned duration,
  ModemTonesStoppedNotify *notify,
  gpointer data)
{
  ModemTonesPrivate *priv = self->priv;
  NgfProplist *proplist;

  g_return_val_if_fail(!priv->dispose_has_run, 0);

  volume += priv->volume;

  if (volume > 0)
    volume = 0;
  else if (volume < -63)
    volume = -63;

  if (event == TONES_EVENT_DROPPED) {
    if (duration > 1200)
      duration = 1200;
  }

  modem_tones_stop(self, 0);

  if (event < 0)
    return 0;

  priv->event = event;
  priv->evolume = volume;
  priv->duration = duration;

  if (duration) {
    priv->timeout = g_timeout_add_full(G_PRIORITY_DEFAULT, duration,
                    modem_tones_timeout, self, modem_tones_timeout_removed);
  }

  priv->data = data;
  priv->notify = notify;

  g_timer_start(priv->timer);

  proplist = ngf_proplist_new();

  if (event > TONES_EVENT_DTMF_D)
    ngf_proplist_set_as_unsigned(proplist, "tonegen.pattern", event);
  else
    ngf_proplist_set_as_unsigned(proplist, "tonegen.value", event);

  ngf_proplist_set_as_integer(proplist, "tonegen.dbm0", volume);

  if (duration > 0)
    ngf_proplist_set_as_unsigned(proplist, "tonegen.duration", duration);

  if (event > TONES_EVENT_DTMF_D)
    priv->event_id = ngf_client_play_event(priv->ngf, "indicator", proplist);
  else
    priv->event_id = ngf_client_play_event(priv->ngf, "dtmf", proplist);

  ngf_proplist_free(proplist);

  DEBUG("called StartEventTone(%u, %d, %u) with %u",
    priv->event, priv->evolume, priv->duration, priv->event_id);

  return priv->event_id;
}