]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Merge branch 'master' into next
authorAndre Noll <maan@systemlinux.org>
Sat, 25 Jul 2009 13:52:09 +0000 (15:52 +0200)
committerAndre Noll <maan@systemlinux.org>
Sat, 25 Jul 2009 13:52:09 +0000 (15:52 +0200)
1  2 
NEWS
fade.c

diff --combined NEWS
index 68c3f406ece95d109e2b74283144d8d047763e1e,6e403d92cbe528ab677b25caf85cf058fcdf4b9f..a4e06762097f9cdb243d119e037f60a8a6349144
--- 1/NEWS
--- 2/NEWS
+++ b/NEWS
@@@ -1,25 -1,6 +1,25 @@@
  NEWS
  ====
  
 +---------------------------------------------------
 +0.4.0 (to be announced) "simultaneous independence"
 +---------------------------------------------------
 +
 +Two significant changes which require the new version number: The
 +improved authentication dialog and the fact that the database code
 +has been moved to a library, libosl. To use the new version, you have
 +to generate new RSA keys, see INSTALL for details. A shell script is
 +provided for conversion of the 0.3 database to the new 0.4 format.
 +
 +      - stronger crypto for client authentication
 +      - the database code has been moved to a library
 +      - improved status item handling
 +      - the new parser-friendly listing mode for the ls and stat commands
 +      - mandatory rc4 encryption
 +      - major audio format handler cleanups
 +      - improved tag handling
 +      - lots of new mood methods
 +
  -------------------------------------------------
  0.3.5 (to be announced) "symplectic separability"
  -------------------------------------------------
@@@ -33,6 -14,7 +33,7 @@@
        - new ls option: -d (print dates as seconds after the epoch)
        - update to gengetopt 2.22.2
        - support for RSA keys of size > 512 bits
+       - new option "mixer_channel" for para_fade
  
  -----------------------------------------
  0.3.4 (2009-05-07) "elliptic inheritance"
diff --combined fade.c
index 868ada4120b55c67fd3260ea93f6d81ba42b9f9d,1e37efd5def104763d6137d32642858b9cd96d93..eaeaf0563e51788a6140e42e472036e84a34deea
--- 1/fade.c
--- 2/fade.c
+++ b/fade.c
@@@ -6,9 -6,13 +6,9 @@@
  
  /** \file fade.c A volume fader and alarm clock for linux. */
  
 +#include <regex.h>
  #include <sys/types.h>
  #include <dirent.h>
 -
 -#include "fade.cmdline.h"
 -#include "para.h"
 -#include "fd.h"
 -
  #include <sys/ioctl.h>
  #include <ctype.h>
  #include <stdlib.h> /* EXIT_SUCCESS */
  #include <string.h>
  #include <limits.h>
  #include <sys/soundcard.h>
 +
 +#include "fade.cmdline.h"
 +#include "para.h"
 +#include "fd.h"
  #include "string.h"
  #include "error.h"
  
 -
  INIT_FADE_ERRLISTS;
 -struct fade_args_info conf;
 +static struct fade_args_info conf;
  
  __printf_2_3 void para_log(__a_unused int ll, const char *fmt, ...)
  {
@@@ -50,22 -51,22 +50,22 @@@ static int open_mixer(void
  }
  
  /*
-  * get volume via mixer_fd
+  * Get channel volume via mixer_fd.
   */
- static int do_get_vol(int mixer_fd)
+ static int get_mixer_channel(int mixer_fd)
  {
        int volume;
  
-       if (ioctl(mixer_fd, MIXER_READ(SOUND_MIXER_VOLUME), &volume) < 0)
+       if (ioctl(mixer_fd, MIXER_READ(conf.mixer_channel_arg), &volume) < 0)
                return -ERRNO_TO_PARA_ERROR(errno);
        /* take the mean value of left and right volume */
        return (volume % 256 + (volume >> 8)) / 2;
  }
  
  /*
-  * open mixer, get volume and close mixer
+  * Open mixer, get volume and close mixer.
   */
- static int get_vol(void)
+ static int open_and_get_mixer_channel(void)
  {
        int mixer_fd;
        int volume;
        mixer_fd = open_mixer();
        if (mixer_fd < 0)
                return mixer_fd;
-       volume = do_get_vol(mixer_fd);
+       volume = get_mixer_channel(mixer_fd);
        close(mixer_fd);
        return volume;
  }
  
  /*
-  * set volume via mixer_fd
+  * Set channel volume via mixer_fd.
   */
- static int do_set_vol(int mixer_fd, int volume)
+ static int set_mixer_channel(int mixer_fd, int volume)
  {
        int tmp = (volume << 8) + volume;
  
-       if (ioctl(mixer_fd, MIXER_WRITE(SOUND_MIXER_VOLUME), &tmp) < 0)
+       if (ioctl(mixer_fd, MIXER_WRITE(conf.mixer_channel_arg), &tmp) < 0)
                return -ERRNO_TO_PARA_ERROR(errno);
        return 1;
  }
  
  /*
-  * open mixer, set volume and close mixer
+  * Open mixer, set volume and close mixer.
   */
- static int set_vol(int volume)
+ static int open_and_set_mixer_channel(int volume)
  {
        int mixer_fd, ret = open_mixer();
  
        if (ret < 0)
                return ret;
        mixer_fd = ret;
-       ret = do_set_vol(mixer_fd, volume);
+       ret = set_mixer_channel(mixer_fd, volume);
        close(mixer_fd);
        return ret;
  }
  
+ static void fixup_mixer_channel_arg(void)
+ {
+       int val;
+       switch (conf.mixer_channel_arg) {
+               case mixer_channel_arg_volume: val = SOUND_MIXER_VOLUME; break;
+               case mixer_channel_arg_bass: val = SOUND_MIXER_BASS; break;
+               case mixer_channel_arg_treble: val = SOUND_MIXER_TREBLE; break;
+               case mixer_channel_arg_synth: val = SOUND_MIXER_SYNTH; break;
+               case mixer_channel_arg_pcm: val = SOUND_MIXER_PCM; break;
+               case mixer_channel_arg_speaker: val = SOUND_MIXER_SPEAKER; break;
+               case mixer_channel_arg_line: val = SOUND_MIXER_LINE; break;
+               case mixer_channel_arg_mic: val = SOUND_MIXER_MIC; break;
+               case mixer_channel_arg_cd: val = SOUND_MIXER_CD; break;
+               case mixer_channel_arg_imix: val = SOUND_MIXER_IMIX; break;
+               case mixer_channel_arg_altpcm: val = SOUND_MIXER_ALTPCM; break;
+               case mixer_channel_arg_reclev: val = SOUND_MIXER_RECLEV; break;
+               case mixer_channel_arg_igain: val = SOUND_MIXER_IGAIN; break;
+               case mixer_channel_arg_ogain: val = SOUND_MIXER_OGAIN; break;
+       }
+       conf.mixer_channel_arg = val;
+ }
  /*
   * Open mixer, get volume, fade to new_vol in secs seconds and
   * close mixer
@@@ -124,7 -148,7 +147,7 @@@ static int fade(int new_vol, int fade_t
        if (ret < 0)
                return ret;
        mixer_fd = ret;
-       ret = do_get_vol(mixer_fd);
+       ret = get_mixer_channel(mixer_fd);
        if (ret < 0)
                goto out;
        vol = ret;
                ts.tv_sec = tmp / 1000; /* really nec ?*/
                //printf("ts.tv_sec: %i\n", ts.tv_nsec);
                vol += incr;
-               ret = do_set_vol(mixer_fd, vol);
+               ret = set_mixer_channel(mixer_fd, vol);
                if (ret < 0)
                        goto out;
                //printf("vol = %i\n", vol);
@@@ -225,7 -249,7 +248,7 @@@ static int sweet_dreams(void
        sleep(1);
        if (sf) {
                PARA_INFO_LOG("initial volume: %d\n", iv);
-               ret = set_vol(iv);
+               ret = open_and_set_mixer_channel(iv);
                if (ret < 0)
                        return ret;
                change_afs_mode_and_play(fa_mode);
                if (ret < 0)
                        return ret;
        } else {
-               ret = set_vol(sf);
+               ret = open_and_set_mixer_channel(sf);
                if (ret < 0)
                        return ret;
        }
@@@ -267,8 -291,8 +290,8 @@@ static int snooze(void
        if (conf.snooze_time_arg <= 0)
                return 1;
        sleep_time = conf.snooze_time_arg;
-       if (get_vol() < conf.snooze_out_vol_arg)
-               ret = set_vol(conf.snooze_out_vol_arg);
+       if (open_and_get_mixer_channel() < conf.snooze_out_vol_arg)
+               ret = open_and_set_mixer_channel(conf.snooze_out_vol_arg);
        else
                ret = fade(conf.snooze_out_vol_arg, conf.snooze_out_fade_arg);
        if (ret < 0)
@@@ -317,6 -341,7 +340,7 @@@ int main(int argc, char *argv[]
                fade_cmdline_parser_config_file(conf.config_file_arg,
                        &conf, &params);
        }
+       fixup_mixer_channel_arg();
        if (!strcmp(conf.mode_arg, "sleep")) {
                ret = sweet_dreams();
                goto out;