chiark / gitweb /
Build fixes for uaudio ALSA/OSS backends.
authorRichard Kettlewell <rjk@greenend.org.uk>
Sun, 8 Mar 2009 11:32:33 +0000 (11:32 +0000)
committerRichard Kettlewell <rjk@greenend.org.uk>
Sun, 8 Mar 2009 11:32:33 +0000 (11:32 +0000)
lib/uaudio-alsa.c
lib/uaudio-oss.c

index be716cf..2236c91 100644 (file)
@@ -149,6 +149,11 @@ static int to_percent(long n) {
   return (n - alsa_mixer_min) * 100 / (alsa_mixer_max - alsa_mixer_min);
 }
 
+/** @brief Convert a percentage to a level */
+static int from_percent(int n) {
+  return alsa_mixer_min + n * (alsa_mixer_max - alsa_mixer_min) / 100;
+}
+
 static void alsa_open_mixer(void) {
   int err;
   snd_mixer_selem_id_t *id;
@@ -159,8 +164,8 @@ static void alsa_open_mixer(void) {
   snd_mixer_selem_id_alloca(&id);
   if((err = snd_mixer_open(&alsa_mixer_handle, 0)))
     fatal(0, "snd_mixer_open: %s", snd_strerror(err));
-  if((err = snd_mixer_attach(alsa_mixer_handle, config->device)))
-    fatal(0, "snd_mixer_attach %s: %s", config->device, snd_strerror(err));
+  if((err = snd_mixer_attach(alsa_mixer_handle, device)))
+    fatal(0, "snd_mixer_attach %s: %s", device, snd_strerror(err));
   if((err = snd_mixer_selem_register(alsa_mixer_handle,
                                      0/*options*/, 0/*classp*/)))
     fatal(0, "snd_mixer_selem_register %s: %s",
index d4c3711..081e1eb 100644 (file)
@@ -145,11 +145,11 @@ static void oss_stop(void) {
 static const char *oss_channels[] = SOUND_DEVICE_NAMES;
 
 static int oss_mixer_find_channel(const char *channel) {
-  if(!channel[strspn(c, "0123456789")])
+  if(!channel[strspn(channel, "0123456789")])
     return atoi(channel);
   else {
-    for(int n = 0; n < sizeof oss_channels / sizeof *oss_channels; ++n)
-      if(!strcmp(oss_channels[n], channels))
+    for(unsigned n = 0; n < sizeof oss_channels / sizeof *oss_channels; ++n)
+      if(!strcmp(oss_channels[n], channel))
        return n;
     return -1;
   }
@@ -175,7 +175,7 @@ static void oss_get_volume(int *left, int *right) {
   int r;
 
   *left = *right = 0;
-  if(ioctl(oss_mixer_fd, SOUND_MIXER_READ(ch), &r) < 0)
+  if(ioctl(oss_mixer_fd, SOUND_MIXER_READ(oss_mixer_channel), &r) < 0)
     error(errno, "error getting volume");
   else {
     *left = r & 0xff;
@@ -185,9 +185,9 @@ static void oss_get_volume(int *left, int *right) {
 
 static void oss_set_volume(int *left, int *right) {
   int r =  (*left & 0xff) + (*right & 0xff) * 256;
-  if(ioctl(fd, SOUND_MIXER_WRITE(ch), &r) == -1)
+  if(ioctl(oss_mixer_fd, SOUND_MIXER_WRITE(oss_mixer_channel), &r) == -1)
     error(errno, "error setting volume");
-  else if(ioctl(oss_mixer_fd, SOUND_MIXER_READ(ch), &r) < 0)
+  else if(ioctl(oss_mixer_fd, SOUND_MIXER_READ(oss_mixer_channel), &r) < 0)
     error(errno, "error getting volume");
   else {
     *left = r & 0xff;