alsa support does not compile

Jerry James james at xemacs.org
Fri Apr 7 12:17:58 EDT 2006


Ilya,

"Ilya N. Golubev" <gin at mo.msk.ru> wrote:
> In `libalsa2-devel-1.0.2-3mdk' binary package
> `snd_mixer_selem_get_playback_volume_range' return type is `void'.
> Please add checks both for that and for possibly missing
> `snd_mixer_selem_channel_id_t' enum items.  In this version both this
> type enum is defined and `snd_mixer_selem_get_playback_volume_range'
> is declared in `<alsa/mixer.h>', and the following include set is
> enough to compile.
>
> #include <sys/types.h>
> #include <alsa/mixer.h>

Does the following patch fix the build for you?

Index: alsaplay.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/alsaplay.c,v
retrieving revision 1.1
diff -d -u -r1.1 alsaplay.c
--- alsaplay.c	2006/03/27 17:40:58	1.1
+++ alsaplay.c	2006/04/07 16:16:10
@@ -41,6 +41,8 @@
 #include <alsa/control.h>
 #include <alsa/mixer.h>
 
+#define ALSA_VERSION(major,minor,sub) (((major)<<16) | ((minor)<<8)| (sub))
+
 struct mixer_state
 {
   snd_mixer_t *mixer;
@@ -51,22 +53,26 @@
   int reset_front_center;
   int reset_front_right;
   int reset_rear_left;
-  int reset_rear_center;
   int reset_rear_right;
+  int reset_woofer;
+#if SND_LIB_VERSION >= ALSA_VERSION (1, 0, 10)
+  int reset_rear_center;
   int reset_side_left;
   int reset_side_right;
-  int reset_woofer;
+#endif
 
   /* Old volumes for the channels */
   long front_left_vol;
   long front_center_vol;
   long front_right_vol;
   long rear_left_vol;
-  long rear_center_vol;
   long rear_right_vol;
+  long woofer_vol;
+#if SND_LIB_VERSION >= ALSA_VERSION (1, 0, 10)
+  long rear_center_vol;
   long side_left_vol;
   long side_right_vol;
-  long woofer_vol;
+#endif
 };
 
 /* Assemble a machine half-word in little-endian order */
@@ -227,9 +233,13 @@
     }
 
   /* Translate the Lisp volume range to the device volume range */
+#if SND_LIB_VERSION < ALSA_VERSION (1, 0, 10)
+  snd_mixer_selem_get_playback_volume_range (mix->vol_ctl, &min_vol, &max_vol);
+#else
   if (snd_mixer_selem_get_playback_volume_range (mix->vol_ctl, &min_vol,
 						 &max_vol) < 0)
     return;
+#endif
 
   dev_vol = volume * (max_vol - min_vol) / 100 + min_vol;
 
@@ -251,24 +261,26 @@
     mix->reset_rear_left = 1;
 
   if (snd_mixer_selem_get_playback_volume
-      (mix->vol_ctl, SND_MIXER_SCHN_REAR_CENTER, &mix->rear_center_vol) >= 0)
-    mix->reset_rear_center = 1;
-
-  if (snd_mixer_selem_get_playback_volume
       (mix->vol_ctl, SND_MIXER_SCHN_REAR_RIGHT, &mix->rear_right_vol) >= 0)
     mix->reset_rear_right = 1;
 
   if (snd_mixer_selem_get_playback_volume
+      (mix->vol_ctl, SND_MIXER_SCHN_WOOFER, &mix->woofer_vol) >= 0)
+    mix->reset_woofer = 1;
+
+#if SND_LIB_VERSION >= ALSA_VERSION (1, 0, 10)
+  if (snd_mixer_selem_get_playback_volume
+      (mix->vol_ctl, SND_MIXER_SCHN_REAR_CENTER, &mix->rear_center_vol) >= 0)
+    mix->reset_rear_center = 1;
+
+  if (snd_mixer_selem_get_playback_volume
       (mix->vol_ctl, SND_MIXER_SCHN_SIDE_LEFT, &mix->side_left_vol) >= 0)
     mix->reset_side_left = 1;
 
   if (snd_mixer_selem_get_playback_volume
       (mix->vol_ctl, SND_MIXER_SCHN_SIDE_RIGHT, &mix->side_right_vol) >= 0)
     mix->reset_side_right = 1;
-
-  if (snd_mixer_selem_get_playback_volume
-      (mix->vol_ctl, SND_MIXER_SCHN_WOOFER, &mix->woofer_vol) >= 0)
-    mix->reset_woofer = 1;
+#endif
 
   /* Set the volume */
   snd_mixer_selem_set_playback_volume_all (mix->vol_ctl, dev_vol);
@@ -293,14 +305,19 @@
     snd_mixer_selem_set_playback_volume
       (mix->vol_ctl, SND_MIXER_SCHN_REAR_LEFT, mix->rear_left_vol);
 
-  if (mix->reset_rear_center)
-    snd_mixer_selem_set_playback_volume
-      (mix->vol_ctl, SND_MIXER_SCHN_REAR_CENTER, mix->rear_center_vol);
-
   if (mix->reset_rear_right)
     snd_mixer_selem_set_playback_volume
       (mix->vol_ctl, SND_MIXER_SCHN_REAR_RIGHT, mix->rear_right_vol);
 
+  if (mix->reset_woofer)
+    snd_mixer_selem_set_playback_volume
+      (mix->vol_ctl, SND_MIXER_SCHN_WOOFER, mix->woofer_vol);
+
+#if SND_LIB_VERSION >= ALSA_VERSION (1, 0, 10)
+  if (mix->reset_rear_center)
+    snd_mixer_selem_set_playback_volume
+      (mix->vol_ctl, SND_MIXER_SCHN_REAR_CENTER, mix->rear_center_vol);
+
   if (mix->reset_side_left)
     snd_mixer_selem_set_playback_volume
       (mix->vol_ctl, SND_MIXER_SCHN_SIDE_LEFT, mix->side_left_vol);
@@ -308,10 +325,7 @@
   if (mix->reset_side_right)
     snd_mixer_selem_set_playback_volume
       (mix->vol_ctl, SND_MIXER_SCHN_SIDE_RIGHT, mix->side_right_vol);
-
-  if (mix->reset_woofer)
-    snd_mixer_selem_set_playback_volume
-      (mix->vol_ctl, SND_MIXER_SCHN_WOOFER, mix->woofer_vol);
+#endif
 
   snd_mixer_close (mix->mixer);
 }

Thanks,
-- 
Jerry James, Assistant Professor        james at xemacs.org
Computer Science Department             http://www.cs.usu.edu/~jerry/
Utah State University




More information about the XEmacs-Beta mailing list