float MediaPlayerPrivateGStreamerBase::volume() const
{
    if (!m_volumeElement)
        return 0;

    return gst_stream_volume_get_volume(m_volumeElement.get(), GST_STREAM_VOLUME_FORMAT_CUBIC);
}
void MediaPlayerPrivateGStreamerBase::notifyPlayerOfVolumeChange()
{
    if (!m_player || !m_volumeElement)
        return;
    double volume;
    volume = gst_stream_volume_get_volume(m_volumeElement.get(), GST_STREAM_VOLUME_FORMAT_CUBIC);
    // get_volume() can return values superior to 1.0 if the user
    // applies software user gain via third party application (GNOME
    // volume control for instance).
    volume = CLAMP(volume, 0.0, 1.0);
    m_player->volumeChanged(static_cast<float>(volume));
}
static gboolean
emit_volume_changed_idle (RBPlayerGst *player)
{
	double vol;

	if (gst_element_implements_interface (player->priv->playbin, GST_TYPE_STREAM_VOLUME)) {
		vol = gst_stream_volume_get_volume (GST_STREAM_VOLUME (player->priv->playbin),
						    GST_STREAM_VOLUME_FORMAT_CUBIC);
	} else {
		vol = player->priv->cur_volume;
	}

	_rb_player_emit_volume_changed (RB_PLAYER (player), vol);
	return FALSE;
}
Exemplo n.º 4
0
static void
play_set_relative_volume (GstPlay * play, gdouble volume_step)
{
  gdouble volume;

  volume = gst_stream_volume_get_volume (GST_STREAM_VOLUME (play->playbin),
      GST_STREAM_VOLUME_FORMAT_CUBIC);

  volume = round ((volume + volume_step) * VOLUME_STEPS) / VOLUME_STEPS;
  volume = CLAMP (volume, 0.0, 10.0);

  gst_stream_volume_set_volume (GST_STREAM_VOLUME (play->playbin),
      GST_STREAM_VOLUME_FORMAT_CUBIC, volume);

  g_print ("Volume: %.0f%%                  \n", volume * 100);
}
Exemplo n.º 5
0
static gboolean
emit_volume_changed_idle(XmrPlayer *player)
{
	gdouble vol;

	if (gst_element_implements_interface(player->priv->playbin, GST_TYPE_STREAM_VOLUME))
	{
		vol = gst_stream_volume_get_volume(GST_STREAM_VOLUME (player->priv->playbin),
						    GST_STREAM_VOLUME_FORMAT_CUBIC);
	}
	else
	{
		vol = player->priv->cur_volume;
	}

	g_signal_emit(player, signals[VOLUME_CHANGED], 0, vol);

	return FALSE;
}
Exemplo n.º 6
0
double StreamVolume::volume(StreamVolumeFormat format) const
{
    return gst_stream_volume_get_volume(object<GstStreamVolume>(),
                                        static_cast<GstStreamVolumeFormat>(format));
}