Enlightenment CVS committal

Author  : englebass
Project : e_modules
Module  : mixer

Dir     : e_modules/mixer


Modified Files:
        alsa_mixer.c 


Log Message:
Fix compiler warnings.
Clean up whitespace.

===================================================================
RCS file: /cvs/e/e_modules/mixer/alsa_mixer.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -3 -r1.42 -r1.43
--- alsa_mixer.c        24 Dec 2007 05:15:40 -0000      1.42
+++ alsa_mixer.c        10 Jan 2008 18:26:03 -0000      1.43
@@ -8,14 +8,14 @@
 static int   _alsa_get_hash         (const char *name);
 static int   _alsa_get_system_id    (const char *name);
 static int   _alsa_get_card_id      (const char *name);
-static int   _alsa_get_mixer_id     (const char *name); 
+static int   _alsa_get_mixer_id     (const char *name);
 static void *_alsa_card_get_channel (void *data, int channel_id);
 
 static Ecore_Hash *vols = NULL;
 static int muted = 0;
 
 Evas_List *
-alsa_get_cards() 
+alsa_get_cards()
 {
    Evas_List *cards = NULL;
    snd_ctl_t *control;
@@ -24,21 +24,21 @@
    char buf[1024];
 
    snd_ctl_card_info_alloca(&hw_info);
-   
-   for (i = 0; i < 32; i++) 
+
+   for (i = 0; i < 32; i++)
      {
        Mixer_Card *card;
-       
+
        snprintf(buf, sizeof(buf), "hw:%d", i);
        if ((err = snd_ctl_open(&control, buf, 0)) < 0) break;
-       if ((err = snd_ctl_card_info(control, hw_info)) < 0) 
+       if ((err = snd_ctl_card_info(control, hw_info)) < 0)
          {
-            printf("Cannot get hardware info: %s: %s\n", buf, 
+            printf("Cannot get hardware info: %s: %s\n", buf,
                    snd_strerror(err));
             snd_ctl_close(control);
             continue;
          }
-       
+
        snd_ctl_close(control);
        card = E_NEW(Mixer_Card, 1);
        if (!card) continue;
@@ -50,26 +50,26 @@
    return cards;
 }
 
-void 
-alsa_free_cards(void *data) 
+void
+alsa_free_cards(void *data)
 {
    Evas_List *cards;
 
    if (!(cards = data)) return;
-   while (cards) 
+   while (cards)
      {
        Mixer_Card *card;
 
        if (!(card = cards->data)) return;
        if (card->name) evas_stringshare_del(card->name);
        if (card->real) evas_stringshare_del(card->real);
-       while (card->channels) 
+       while (card->channels)
          {
             Mixer_Channel *chan;
 
             if (!(chan = card->channels->data)) continue;
             if (chan->name) evas_stringshare_del(chan->name);
-            card->channels = 
+            card->channels =
               evas_list_remove_list(card->channels, card->channels);
             E_FREE(chan);
          }
@@ -79,17 +79,15 @@
 }
 
 void *
-alsa_get_card(int id) 
+alsa_get_card(int id)
 {
-   Evas_List *cards = NULL;
-   snd_mixer_t *handle;
    snd_ctl_t *control;
    snd_ctl_card_info_t *hw_info;
    int err, i, cid;
    char buf[1024];
    const char *name;
 
-   for (i = 0; i < 32; i++) 
+   for (i = 0; i < 32; i++)
      {
        Mixer_Card *card;
 
@@ -97,14 +95,14 @@
 
        snprintf(buf, sizeof(buf), "hw:%d", i);
        if ((err = snd_ctl_open(&control, buf, 0)) < 0) break;
-       if ((err = snd_ctl_card_info(control, hw_info)) < 0) 
+       if ((err = snd_ctl_card_info(control, hw_info)) < 0)
          {
-            printf("Cannot get hardware info: %s: %s\n", buf, 
+            printf("Cannot get hardware info: %s: %s\n", buf,
                    snd_strerror(err));
             snd_ctl_close(control);
             continue;
          }
-       
+
        snd_ctl_close(control);
 
        name = snd_ctl_card_info_get_name(hw_info);
@@ -123,7 +121,7 @@
 }
 
 Evas_List *
-alsa_card_get_channels(void *data) 
+alsa_card_get_channels(void *data)
 {
    Mixer_Card *card;
    Evas_List *channels = NULL;
@@ -138,54 +136,54 @@
    snd_mixer_selem_id_alloca(&sid);
    snd_ctl_card_info_alloca(&hw_info);
 
-   if ((err = snd_ctl_open(&control, card->name, 0)) < 0) 
+   if ((err = snd_ctl_open(&control, card->name, 0)) < 0)
      {
        printf("Cannot Open Card: %s %s\n", card->name, snd_strerror(err));
        return NULL;
      }
-   if ((err = snd_ctl_card_info(control, hw_info)) < 0) 
+   if ((err = snd_ctl_card_info(control, hw_info)) < 0)
      {
-       printf("Cannot get hardware info: %s %s\n", card->name, 
+       printf("Cannot get hardware info: %s %s\n", card->name,
               snd_strerror(err));
        snd_ctl_close(control);
        return NULL;
      }
    snd_ctl_close(control);
-   
-   if ((err = snd_mixer_open(&handle, 0)) < 0) 
+
+   if ((err = snd_mixer_open(&handle, 0)) < 0)
      {
        printf("Cannot Open Mixer: %s\n", snd_strerror(err));
        return NULL;
      }
-   if ((err = snd_mixer_attach(handle, card->name)) < 0) 
+   if ((err = snd_mixer_attach(handle, card->name)) < 0)
      {
        printf("Cannot Attach Mixer: %s\n", snd_strerror(err));
        snd_mixer_close(handle);
        return NULL;
      }
-   if ((err = snd_mixer_selem_register(handle, NULL, NULL)) < 0) 
+   if ((err = snd_mixer_selem_register(handle, NULL, NULL)) < 0)
      {
        printf("Cannot Register Mixer: %s\n", snd_strerror(err));
        snd_mixer_close(handle);
        return NULL;
      }
-   if ((err = snd_mixer_load(handle)) < 0) 
+   if ((err = snd_mixer_load(handle)) < 0)
      {
        printf("Cannot Load Mixer: %s\n", snd_strerror(err));
        snd_mixer_close(handle);
        return NULL;
      }
 
-   for (i = 0, elem = snd_mixer_first_elem(handle); elem; elem = 
snd_mixer_elem_next(elem)) 
+   for (i = 0, elem = snd_mixer_first_elem(handle); elem; elem = 
snd_mixer_elem_next(elem))
      {
        snd_mixer_selem_get_id(elem, sid);
        if (!snd_mixer_selem_is_active(elem)) continue;
-       
-       if (snd_mixer_selem_has_playback_volume(elem)) 
+
+       if (snd_mixer_selem_has_playback_volume(elem))
          {
             Mixer_Channel *ac;
             const char *name;
-            
+
             name = snd_mixer_selem_id_get_name(sid);
             ac = E_NEW(Mixer_Channel, 1);
             if (!ac) continue;
@@ -194,12 +192,12 @@
             channels = evas_list_append(channels, ac);
          }
      }
-   snd_mixer_close(handle);   
+   snd_mixer_close(handle);
    return channels;
 }
 
 void *
-alsa_card_get_channel(void *data, int channel_id) 
+alsa_card_get_channel(void *data, int channel_id)
 {
    Mixer_Card *card;
    Mixer_Channel *chan;
@@ -211,68 +209,68 @@
    return chan;
 }
 
-int 
-alsa_get_volume(int card_id, int channel_id) 
+int
+alsa_get_volume(int card_id, int channel_id)
 {
    Mixer_Card *card;
    snd_mixer_t *handle;
    snd_mixer_elem_t *elem;
    snd_mixer_selem_id_t *sid;
-   int err, range, ret = 0, mute;
+   int err, range, ret = 0;
    long min, max, vol;
 
-   if (muted) 
+   if (muted)
      {
        int v;
-       if (!vols) 
+       if (!vols)
          {
             vols = ecore_hash_new(ecore_direct_hash, ecore_direct_compare);
             ecore_hash_free_key_cb_set(vols, NULL);
             ecore_hash_free_value_cb_set(vols, NULL);
          }
 
-       if (v = (unsigned int)(ecore_hash_get(vols, (int*)(card_id << 16) + 
channel_id))) 
+       if ((v = (unsigned int)(ecore_hash_get(vols, (int*)(card_id << 16) + 
channel_id))))
          return v;
      }
-   
+
    card = alsa_get_card(card_id);
    if (!card) return 0;
 
-   if ((err = snd_mixer_open(&handle, 0)) < 0) 
+   if ((err = snd_mixer_open(&handle, 0)) < 0)
      {
        printf("Cannot open mixer: %s\n", snd_strerror(err));
         goto error;
      }
-   if ((err = snd_mixer_attach(handle, (char *)card->name)) < 0) 
+   if ((err = snd_mixer_attach(handle, (char *)card->name)) < 0)
      {
        printf("Cannot Attach Mixer: %s\n", snd_strerror(err));
        snd_mixer_close(handle);
         goto error;
      }
-   if ((err = snd_mixer_selem_register(handle, NULL, NULL)) < 0) 
+   if ((err = snd_mixer_selem_register(handle, NULL, NULL)) < 0)
      {
        printf("Cannot Register Mixer: %s\n", snd_strerror(err));
        snd_mixer_close(handle);
         goto error;
      }
-   if ((err = snd_mixer_load(handle)) < 0) 
+   if ((err = snd_mixer_load(handle)) < 0)
      {
        printf("Cannot Load Mixer: %s\n", snd_strerror(err));
        snd_mixer_close(handle);
         goto error;
      }
 
-   for (elem = snd_mixer_first_elem(handle); elem; elem = 
snd_mixer_elem_next(elem)) 
+   for (elem = snd_mixer_first_elem(handle); elem; elem = 
snd_mixer_elem_next(elem))
      {
        snd_mixer_selem_id_alloca(&sid);
        snd_mixer_selem_get_id(elem, sid);
        if (!snd_mixer_selem_is_active(elem)) continue;
 
-       if (snd_mixer_selem_has_playback_volume(elem)) 
+       if (snd_mixer_selem_has_playback_volume(elem))
          {
             const char *name;
             int id;
-            
+
             name = snd_mixer_selem_id_get_name(sid);
             id = _alsa_get_mixer_id(name);
             if (id == channel_id)
@@ -280,16 +278,16 @@
                  snd_mixer_selem_get_playback_volume(elem, 0, &vol);
                  snd_mixer_selem_get_playback_volume_range(elem, &min, &max);
                  range = max - min;
-                 if (range == 0) 
+                 if (range == 0)
                    vol = 0;
                  else
                    vol -= min;
                  ret = rint(((double)vol / ((double)range) * 100));
                  break;
-              }             
+              }
          }
      }
-   
+
    snd_mixer_close(handle);
    if (card->name) evas_stringshare_del(card->name);
    if (card->real) evas_stringshare_del(card->real);
@@ -303,8 +301,8 @@
    return 0;
 }
 
-int 
-alsa_set_volume(int card_id, int channel_id, double vol) 
+int
+alsa_set_volume(int card_id, int channel_id, double vol)
 {
    Mixer_Card *card;
    snd_mixer_t *handle;
@@ -316,31 +314,31 @@
    card = alsa_get_card(card_id);
    if (!card) return 0;
 
-   if ((err = snd_mixer_open(&handle, 0)) < 0) 
+   if ((err = snd_mixer_open(&handle, 0)) < 0)
      {
        printf("Cannot open mixer: %s\n", snd_strerror(err));
         goto error;
      }
-   if ((err = snd_mixer_attach(handle, (char *)card->name)) < 0) 
+   if ((err = snd_mixer_attach(handle, (char *)card->name)) < 0)
      {
        printf("Cannot Attach Mixer: %s\n", snd_strerror(err));
        snd_mixer_close(handle);
         goto error;
      }
-   if ((err = snd_mixer_selem_register(handle, NULL, NULL)) < 0) 
+   if ((err = snd_mixer_selem_register(handle, NULL, NULL)) < 0)
      {
        printf("Cannot Register Mixer: %s\n", snd_strerror(err));
        snd_mixer_close(handle);
         goto error;
      }
-   if ((err = snd_mixer_load(handle)) < 0) 
+   if ((err = snd_mixer_load(handle)) < 0)
      {
        printf("Cannot Load Mixer: %s\n", snd_strerror(err));
        snd_mixer_close(handle);
         goto error;
      }
 
-   for (elem = snd_mixer_first_elem(handle); elem; elem = 
snd_mixer_elem_next(elem)) 
+   for (elem = snd_mixer_first_elem(handle); elem; elem = 
snd_mixer_elem_next(elem))
      {
        snd_mixer_selem_id_alloca(&sid);
        snd_mixer_selem_get_id(elem, sid);
@@ -349,42 +347,42 @@
        if ((muted) && (!snd_mixer_selem_has_playback_switch(elem)))
          ecore_hash_set(vols, (int*)(card_id << 16) + channel_id, 
(int*)alsa_get_volume(card_id, channel_id));
 
-       if (snd_mixer_selem_has_playback_volume(elem)) 
+       if (snd_mixer_selem_has_playback_volume(elem))
          {
             const char *name;
             int id;
-            
+
             name = snd_mixer_selem_id_get_name(sid);
             id = _alsa_get_mixer_id(name);
             if (id == channel_id)
               {
                  snd_mixer_selem_get_playback_volume_range(elem, &min, &max);
                  range = max - min;
-                 if (range == 0) 
+                 if (range == 0)
                    {
                       snd_mixer_close(handle);
                        goto error;
                    }
-                 
+
                  v = (vol < 0) ? -vol: vol;
-                 if (v > 0) 
+                 if (v > 0)
                    {
                       if (v > 100)
                         v = max;
                       else
                         v = (((range * (v)) + (range /2)) / (100 + min));
-                      
+
                       v -= min;
                       if (v <= 0) v = 1;
                       if (vol < 0) v = -v;
                    }
-                 
+
                  snd_mixer_selem_set_playback_volume(elem, 0, v);
                  if (!snd_mixer_selem_is_playback_mono(elem))
                    snd_mixer_selem_set_playback_volume(elem, 1, v);
 
                  break;
-              }             
+              }
          }
      }
 
@@ -401,44 +399,44 @@
    return 0;
 }
 
-int 
-alsa_get_mute(int card_id, int channel_id) 
+int
+alsa_get_mute(int card_id, int channel_id)
 {
    Mixer_Card *card;
    snd_mixer_t *handle;
    snd_mixer_elem_t *elem;
    snd_mixer_selem_id_t *sid;
-   int id, err, vol;
+   int id, err;
    const char *name;
 
    card = alsa_get_card(card_id);
    if (!card) return 0;
 
-   if ((err = snd_mixer_open(&handle, 0)) < 0) 
+   if ((err = snd_mixer_open(&handle, 0)) < 0)
      {
        printf("Cannot open mixer: %s\n", snd_strerror(err));
         goto error;
      }
-   if ((err = snd_mixer_attach(handle, (char *)card->name)) < 0) 
+   if ((err = snd_mixer_attach(handle, (char *)card->name)) < 0)
      {
        printf("Cannot Attach Mixer: %s\n", snd_strerror(err));
        snd_mixer_close(handle);
         goto error;
      }
-   if ((err = snd_mixer_selem_register(handle, NULL, NULL)) < 0) 
+   if ((err = snd_mixer_selem_register(handle, NULL, NULL)) < 0)
      {
        printf("Cannot Register Mixer: %s\n", snd_strerror(err));
        snd_mixer_close(handle);
         goto error;
      }
-   if ((err = snd_mixer_load(handle)) < 0) 
+   if ((err = snd_mixer_load(handle)) < 0)
      {
        printf("Cannot Load Mixer: %s\n", snd_strerror(err));
        snd_mixer_close(handle);
         goto error;
      }
 
-   for (elem = snd_mixer_first_elem(handle); elem; elem = 
snd_mixer_elem_next(elem)) 
+   for (elem = snd_mixer_first_elem(handle); elem; elem = 
snd_mixer_elem_next(elem))
      {
        snd_mixer_selem_id_alloca(&sid);
        snd_mixer_selem_get_id(elem, sid);
@@ -448,12 +446,12 @@
        id = _alsa_get_mixer_id(name);
        if (id == channel_id)
          {
-            if (snd_mixer_selem_has_playback_switch(elem)) 
-              { 
+            if (snd_mixer_selem_has_playback_switch(elem))
+              {
                  snd_mixer_selem_get_playback_switch(elem, id, &muted);
                  muted = muted ? 0 : 1;
               }
-         }          
+         }
      }
 
    snd_mixer_close(handle);
@@ -469,8 +467,8 @@
    return 0;
 }
 
-int 
-alsa_set_mute(int card_id, int channel_id, int mute) 
+int
+alsa_set_mute(int card_id, int channel_id, int mute)
 {
    Mixer_Card *card;
    snd_mixer_t *handle;
@@ -482,31 +480,31 @@
    card = alsa_get_card(card_id);
    if (!card) return 0;
 
-   if ((err = snd_mixer_open(&handle, 0)) < 0) 
+   if ((err = snd_mixer_open(&handle, 0)) < 0)
      {
        printf("Cannot open mixer: %s\n", snd_strerror(err));
         goto error;
      }
-   if ((err = snd_mixer_attach(handle, (char *)card->name)) < 0) 
+   if ((err = snd_mixer_attach(handle, (char *)card->name)) < 0)
      {
        printf("Cannot Attach Mixer: %s\n", snd_strerror(err));
        snd_mixer_close(handle);
         goto error;
      }
-   if ((err = snd_mixer_selem_register(handle, NULL, NULL)) < 0) 
+   if ((err = snd_mixer_selem_register(handle, NULL, NULL)) < 0)
      {
        printf("Cannot Register Mixer: %s\n", snd_strerror(err));
        snd_mixer_close(handle);
         goto error;
      }
-   if ((err = snd_mixer_load(handle)) < 0) 
+   if ((err = snd_mixer_load(handle)) < 0)
      {
        printf("Cannot Load Mixer: %s\n", snd_strerror(err));
        snd_mixer_close(handle);
         goto error;
      }
 
-   for (elem = snd_mixer_first_elem(handle); elem; elem = 
snd_mixer_elem_next(elem)) 
+   for (elem = snd_mixer_first_elem(handle); elem; elem = 
snd_mixer_elem_next(elem))
      {
        snd_mixer_selem_id_alloca(&sid);
        snd_mixer_selem_get_id(elem, sid);
@@ -516,16 +514,16 @@
        id = _alsa_get_mixer_id(name);
        if (id == channel_id)
          {
-            if (snd_mixer_selem_has_playback_switch(elem)) 
-              { 
+            if (snd_mixer_selem_has_playback_switch(elem))
+              {
                  snd_mixer_selem_set_playback_switch(elem, id, (mute == 1 ? 0: 
1));
                  muted = mute;
               }
-            else 
+            else
               {
                   /*Create hash to store combos.  Could possibly be changed to 
a single int,
                   but this should allow to easily support multiple mixers 
later.*/
-                  if (!vols) 
+                  if (!vols)
                    {
                        vols = ecore_hash_new(ecore_direct_hash, 
ecore_direct_compare);
                        ecore_hash_free_key_cb_set(vols, NULL);
@@ -540,7 +538,7 @@
                  else
                    {
                       muted = 0;
-                      if (vol = (unsigned int)(ecore_hash_get(vols, 
(int*)(card_id << 16) + channel_id))) 
+                      if ((vol = (unsigned int)(ecore_hash_get(vols, 
(int*)(card_id << 16) + channel_id))))
                         {
                            alsa_set_volume(card_id, channel_id, vol);
                            ecore_hash_remove(vols, (int*)(card_id << 16) + 
channel_id);
@@ -555,7 +553,7 @@
                  return 1;
               }
             break;
-         }          
+         }
      }
 
    snd_mixer_close(handle);
@@ -572,42 +570,42 @@
 }
 
 /* Privates */
-static int 
-_alsa_get_hash(const char *name) 
+static int
+_alsa_get_hash(const char *name)
 {
    /* Ripped from evas_hash.c */
    unsigned int num = 0, i;
    const unsigned char *ptr;
-   
+
    if (!name) return 0;
-   for (i = 0, ptr = (unsigned char *)name; *ptr; ptr++, i++) 
+   for (i = 0, ptr = (unsigned char *)name; *ptr; ptr++, i++)
        num ^= ((int)(*ptr) | ((int)(*ptr) << 8)) >> (i % 2);
    num = (num & 0xFF) + (num >> 4 & 0xF0) + (num >> 8 & 0x4F);
    num = num & 0xFF;
-   
+
    return (int)num;
 }
 
-static int 
-_alsa_get_system_id(const char *name) 
+static int
+_alsa_get_system_id(const char *name)
 {
    return _alsa_get_hash(name) << 16;
 }
 
-static int 
-_alsa_get_card_id(const char *name) 
+static int
+_alsa_get_card_id(const char *name)
 {
    return _alsa_get_hash(name) << 8;
 }
 
-static int 
-_alsa_get_mixer_id(const char *name) 
+static int
+_alsa_get_mixer_id(const char *name)
 {
    return _alsa_get_hash(name);
 }
 
 static void *
-_alsa_card_get_channel(void *data, int channel_id) 
+_alsa_card_get_channel(void *data, int channel_id)
 {
    Mixer_Card *card;
    Evas_List *c;
@@ -618,11 +616,11 @@
      card->channels = alsa_card_get_channels(card);
 
    if (!card->channels) return NULL;
-   
-   for (c = card->channels; c; c = c->next) 
+
+   for (c = card->channels; c; c = c->next)
      {
        Mixer_Channel *chan;
-       
+
        chan = c->data;
        if (!chan) continue;
        if (chan->id == channel_id) return chan;



-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to