changeset 3178:4634dab72608

alsa-ng: Add get_volume() implementation.
author William Pitcock <nenolod@atheme.org>
date Wed, 10 Jun 2009 00:06:15 -0500
parents 1117166277f7
children 0c4359baee34
files src/alsa-ng/alsa-core.c
diffstat 1 files changed, 26 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/alsa-ng/alsa-core.c	Tue Jun 09 23:34:50 2009 -0500
+++ b/src/alsa-ng/alsa-core.c	Wed Jun 10 00:06:15 2009 -0500
@@ -157,6 +157,31 @@
     snd_mixer_handle_events(amixer);
 }
 
+static void
+alsaplug_get_volume(gint *l, gint *r)
+{
+    snd_mixer_elem_t *elem = alsaplug_guess_mixer_elem(amixer);
+
+    if (elem == NULL)
+        return;
+
+    snd_mixer_handle_events(amixer);
+
+    *l = 0;
+    *r = 0;
+
+    if (snd_mixer_selem_is_playback_mono(elem))
+    {
+        snd_mixer_selem_get_playback_volume(elem, SND_MIXER_SCHN_MONO, (glong *) l);
+        snd_mixer_selem_get_playback_volume(elem, SND_MIXER_SCHN_MONO, (glong *) r);
+    }
+    else
+    {
+        snd_mixer_selem_get_playback_volume(elem, SND_MIXER_SCHN_FRONT_LEFT, (glong *) l);
+        snd_mixer_selem_get_playback_volume(elem, SND_MIXER_SCHN_FRONT_RIGHT, (glong *) r);
+    }
+}
+
 /********************************************************************************
  * ALSA PCM I/O functions.                                                      *
  ********************************************************************************/
@@ -456,6 +481,7 @@
     .flush = alsaplug_flush,
     .pause = alsaplug_pause,
     .set_volume = alsaplug_set_volume,
+    .get_volume = alsaplug_get_volume,
 };
 
 OutputPlugin *alsa_oplist[] = { &alsa_op, NULL };