コード例 #1
0
ファイル: PulseAESound.cpp プロジェクト: A600/xbmc
void CPulseAESound::Play()
{
  pa_threaded_mainloop_lock(m_mainLoop);
  /* we only keep the most recent operation as it is the only one needed for IsPlaying to function */
  if (m_op)
    pa_operation_unref(m_op);
  m_op = pa_context_play_sample(m_context, m_pulseName.c_str(), NULL, PA_VOLUME_INVALID, NULL, NULL);
  pa_threaded_mainloop_unlock(m_mainLoop);
}
コード例 #2
0
ファイル: sounds.cpp プロジェクト: alinelena/cameraplus
void Sounds::play(const char *id) {
  if (isMuted()) {
    qmlInfo(this) << "not playing sounds while muted";
    return;
  }

  if (!m_ctx) {
    qmlInfo(this) << "not connected to pulse audio";
    return;
  }

  pa_operation *o = pa_context_play_sample(m_ctx, id, NULL, playbackVolume(), NULL, NULL);

  if (o) {
    pa_operation_unref(o);
  }
}
コード例 #3
0
void QSoundEffectPrivate::playSample()
{
    pa_volume_t volume = PA_VOLUME_NORM;

    daemon()->lock();
#ifdef Q_WS_MAEMO_5
    volume = PA_VOLUME_NORM / 100 * ((daemon()->volume() + m_volume) / 2);
#endif
    pa_operation_unref(
            pa_context_play_sample(daemon()->context(),
                m_name.constData(),
                0,
                volume,
                play_callback,
                this)
            );
    daemon()->unlock();

    m_playbackTime.start();
}
コード例 #4
0
ファイル: notify.c プロジェクト: shr-project/shr
static void
moko_notify_start_ringtone (MokoNotify *notify)
{
  MokoNotifyPrivate *priv;

  g_return_if_fail (MOKO_IS_NOTIFY (notify));
  priv = notify->priv;

  if (!priv->pac || !priv->started)
    return;

  priv->operation = pa_context_play_sample (priv->pac,
                                            "ringtone",
                                            NULL,
                                            PA_VOLUME_NORM,
                                            NULL,
                                            NULL);
  g_timeout_add (500, (GSourceFunc)play_timeout, (gpointer)notify);
  g_debug ("Playing");
}
コード例 #5
0
ファイル: sounds.cpp プロジェクト: alinelena/cameraplus
void Sounds::playAndBlock(const char *id) {
  if (isMuted()) {
    qmlInfo(this) << "not playing sounds while muted";
    return;
  }

  if (!m_ctx) {
    qmlInfo(this) << "not connected to pulse audio";
    return;
  }

  SoundFileInfo *info = m_files[id];
  if (!info) {
    qmlInfo(this) << "unknown sound id " << id;
    return;
  }

  if (!info->duration()) {
    qmlInfo(this) << "unknown file duration";
    return;
  }

  pa_threaded_mainloop_lock(m_loop);
  pa_operation *o = pa_context_play_sample(m_ctx, id, NULL, playbackVolume(),
					   (pa_context_success_cb_t)contextSuccessCallback,
					   m_loop);

  if (!o) {
    qmlInfo(this) << "failed to play sample " << id;
    return;
  }

  bool sleep = false;

  while (true) {
    bool out = false;

    switch (pa_operation_get_state(o)) {
    case PA_OPERATION_RUNNING:
      out = false;
      break;

    case PA_OPERATION_DONE:
      sleep = true;
      out = true;
      break;

    case PA_OPERATION_CANCELLED:
      sleep = false;
      out = true;
      break;
    }

    if (out) {
      break;
    }

    pa_threaded_mainloop_wait(m_loop);
  }

  pa_threaded_mainloop_unlock(m_loop);

  pa_operation_unref(o);

  // Sleep for the duration of the file:
  if (sleep) {
    usleep(info->duration());
  }
}