[Xfce4-commits] [apps/xfce4-volumed-pulse] 18/62: Added a volume channel number check before calling gst_mixer_get_volume
noreply at xfce.org
noreply at xfce.org
Thu Sep 8 10:32:40 CEST 2016
This is an automated email from the git hooks/post-receive script.
ochosi pushed a commit to branch master
in repository apps/xfce4-volumed-pulse.
commit 4ad92331c550cdbda9b9d299465f9fab3568cd94
Author: Steve Dodier <sidnioulz at gmail.com>
Date: Thu Nov 18 16:58:44 2010 +0100
Added a volume channel number check before calling gst_mixer_get_volume
---
ChangeLog | 3 +++
src/xvd_mixer.c | 47 +++++++++++++++++++++++++++++------------------
2 files changed, 32 insertions(+), 18 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 8dcb950..21bbda5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,7 @@
2010-11-18 Steve Dodier <sidnioulz at gmail.com>
+ * Check for volume channels before getting a GStreamer track's volume (fixes lp #667617)
+
+2010-11-18 Steve Dodier <sidnioulz at gmail.com>
* Add a value check incase a GStreamer track has a volume range of 0 (fixes lp #624520)
2010-11-18 Steve Dodier <sidnioulz at gmail.com>
diff --git a/src/xvd_mixer.c b/src/xvd_mixer.c
index 1cb7977..cd7c006 100644
--- a/src/xvd_mixer.c
+++ b/src/xvd_mixer.c
@@ -155,10 +155,16 @@ void
xvd_mixer_init_volume(XvdInstance *Inst)
{
if ((Inst->card) && (Inst->track)) {
- gint *volumes = g_malloc (sizeof (gint) * Inst->track->num_channels);
- gst_mixer_get_volume (GST_MIXER (Inst->card), Inst->track, volumes);
- xvd_calculate_avg_volume (Inst, volumes, Inst->track->num_channels);
- g_free (volumes);
+ if (Inst->track->num_channels) {
+ gint *volumes = g_malloc (sizeof (gint) * Inst->track->num_channels);
+ gst_mixer_get_volume (GST_MIXER (Inst->card), Inst->track, volumes);
+ xvd_calculate_avg_volume (Inst, volumes, Inst->track->num_channels);
+ g_free (volumes);
+ } else {
+ g_debug ("Current track has no volume channels, defaulting volume to 0.\n");
+ xvd_calculate_avg_volume (Inst, NULL, Inst->track->num_channels);
+ }
+
Inst->muted = (GST_MIXER_TRACK_HAS_FLAG (Inst->track, GST_MIXER_TRACK_MUTE));
}
}
@@ -389,26 +395,31 @@ xvd_mixer_change_volume(XvdInstance *Inst,
gint step)
{
if ((Inst->card) && (Inst->track)) {
- gint i;
- gint *volumes = g_malloc (sizeof (gint) * Inst->track->num_channels);
+ if(Inst->track->num_channels) {
+ gint i;
+ gint *volumes = g_malloc (sizeof (gint) * Inst->track->num_channels);
- gst_mixer_get_volume (GST_MIXER (Inst->card), Inst->track, volumes);
+ gst_mixer_get_volume (GST_MIXER (Inst->card), Inst->track, volumes);
- for (i=0; i<Inst->track->num_channels; i++) {
- volumes[i] += _nearest_int ((gdouble)(step * (Inst->track->max_volume - Inst->track->min_volume)) / 100.0);
+ for (i=0; i<Inst->track->num_channels; i++) {
+ volumes[i] += _nearest_int ((gdouble)(step * (Inst->track->max_volume - Inst->track->min_volume)) / 100.0);
- if (volumes[i] > Inst->track->max_volume)
- volumes[i] = Inst->track->max_volume;
+ if (volumes[i] > Inst->track->max_volume)
+ volumes[i] = Inst->track->max_volume;
- if (volumes[i] < Inst->track->min_volume)
- volumes[i] = Inst->track->min_volume;
- }
- xvd_calculate_avg_volume (Inst, volumes, Inst->track->num_channels);
+ if (volumes[i] < Inst->track->min_volume)
+ volumes[i] = Inst->track->min_volume;
+ }
+ xvd_calculate_avg_volume (Inst, volumes, Inst->track->num_channels);
- gst_mixer_set_volume (GST_MIXER (Inst->card), Inst->track, volumes);
- g_free (volumes);
+ gst_mixer_set_volume (GST_MIXER (Inst->card), Inst->track, volumes);
+ g_free (volumes);
- return TRUE;
+ return TRUE;
+ } else {
+ g_debug ("Current track has no volume channels, cannot change volume.\n");
+ return FALSE;
+ }
}
return FALSE;
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list