Esempio n. 1
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);
}
static void
set_playbin_volume (RBPlayerGst *player, float volume)
{
	/* ignore the deep-notify we get directly from the sink, as it causes deadlock.
	 * we still get another one anyway.
	 */
	g_signal_handlers_block_by_func (player->priv->playbin, volume_notify_cb, player);
	if (gst_element_implements_interface (player->priv->playbin, GST_TYPE_STREAM_VOLUME))
		gst_stream_volume_set_volume (GST_STREAM_VOLUME (player->priv->playbin),
					      GST_STREAM_VOLUME_FORMAT_CUBIC, volume);
	else
		g_object_set (player->priv->playbin, "volume", volume, NULL);
	g_signal_handlers_unblock_by_func (player->priv->playbin, volume_notify_cb, player);
}
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;
}
Esempio n. 4
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;
}
Esempio n. 5
0
void
xmr_player_set_volume(XmrPlayer *player,
			float		 volume)
{
	g_return_if_fail( player != NULL);
	g_return_if_fail (volume >= 0.0 && volume <= 1.0);

	if (player->priv->playbin == NULL)
		return ;

	g_signal_handlers_block_by_func(player->priv->playbin, volume_notify_cb, player);

	if (gst_element_implements_interface(player->priv->playbin, GST_TYPE_STREAM_VOLUME))
		gst_stream_volume_set_volume(GST_STREAM_VOLUME(player->priv->playbin),
					      GST_STREAM_VOLUME_FORMAT_CUBIC, volume);
	else
		g_object_set(player->priv->playbin, "volume", volume, NULL);

	g_signal_handlers_unblock_by_func(player->priv->playbin, volume_notify_cb, player);

	player->priv->cur_volume = volume;
}