-/*
- * Open the mixer device.
- */
-static int open_mixer(void)
-{
- PARA_INFO_LOG("opening %s\n", conf.mixer_device_arg);
- return para_open(conf.mixer_device_arg, O_RDWR, 42);
-}
-
-/*
- * Get channel volume via mixer_fd.
- */
-static int get_mixer_channel(int mixer_fd)
-{
- int volume;
-
- 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.
- */
-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 = get_mixer_channel(mixer_fd);
- close(mixer_fd);
- return volume;
-}
-
-/*
- * Set channel volume via mixer_fd.
- */
-static int set_mixer_channel(int mixer_fd, int volume)
-{
- int tmp = (volume << 8) + volume;
-
- 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.
- */
-static int open_and_set_mixer_channel(int volume)
-{
- int mixer_fd, ret = open_mixer();
-
- if (ret < 0)
- return ret;
- mixer_fd = ret;
- ret = set_mixer_channel(mixer_fd, volume);
- close(mixer_fd);
- return ret;
-}
-
-static void fixup_mixer_channel_arg(void)
-{
- int val = SOUND_MIXER_VOLUME; /* STFU, gcc */
-
- 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;
- default: break;
- }
- conf.mixer_channel_arg = val;
-}
-
-/*
- * Open mixer, get volume, fade to new_vol in secs seconds and
- * close mixer.
- */
-static int fade(int new_vol, int fade_time)