Enlightenment CVS committal

Author  : mekius
Project : e_modules
Module  : mixer

Dir     : e_modules/mixer


Modified Files:
        alsa_mixer.c 


Log Message:
For cards without playback switch, restore volume to previous level on unmute.

===================================================================
RCS file: /cvs/e/e_modules/mixer/alsa_mixer.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -3 -r1.29 -r1.30
--- alsa_mixer.c        19 Nov 2007 11:04:59 -0000      1.29
+++ alsa_mixer.c        20 Nov 2007 09:35:13 -0000      1.30
@@ -505,9 +505,10 @@
    snd_mixer_t          *handle;
    snd_mixer_elem_t     *elem;
    snd_mixer_selem_id_t *sid;
-   int                   id, err;
+   int                   id, err, vol;
    const char           *name;
-   
+   static Ecore_Hash    *vols;
+
    card = alsa_get_card(card_id);
    if (!card) return 0;
 
@@ -552,11 +553,31 @@
               snd_mixer_selem_set_playback_switch(elem, id, (mute == 1 ? 0: 
1));
             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) 
+                   {
+                        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);
+                   }
+                  
                  snd_mixer_close(handle);
                  if (mute)
-                   alsa_set_volume(card_id, channel_id, (0.0 * 100));
+                   {                    
+                       ecore_hash_set(vols, (int*)(card_id<<16)+channel_id, 
(int*)alsa_get_volume(card_id,channel_id));
+                       alsa_set_volume(card_id, channel_id, (0.0 * 100));
+                   }
                  else
-                   alsa_set_volume(card_id, channel_id, (0.5 * 100));
+                   {                                            
+                       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);
+                         }
+                        else
+                          alsa_set_volume(card_id, channel_id, (0.5 * 100));
+                   }
                   E_FREE(card);
                  return 1;
               }



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to