Ticket #69: alsa_mix_index.diff

File alsa_mix_index.diff, 2.5 KB (added by reimar, 15 years ago)

some last minor corrections

  • DOCS/man/en/mplayer.1

    RCS file: /cvsroot/mplayer/main/DOCS/man/en/mplayer.1,v
    retrieving revision 1.722
    diff -u -r1.722 mplayer.1
     
    16691669For ALSA this is the mixer name.
    16701670.
    16711671.TP
    1672 .B \-mixer-channel <mixer line> (\-ao oss and \-ao alsa only)
     1672.B \-mixer-channel <mixer line>[,mixer index] (\-ao oss and \-ao alsa only)
    16731673This option will tell MPlayer to use a different channel for controlling
    16741674volume than the default PCM.
    16751675Options for OSS include
     
    16781678/usr/\:include/\:linux/\:soundcard.h.
    16791679For ALSA you can use the names e.g.\& alsamixer displays, like
    16801680.B Master, Line, PCM.
     1681.br
     1682.I NOTE: 
     1683ALSA mixer channel names followed by a number must be specified in the <name,number>
     1684format, i.e. a channel labled 'PCM 1' in alsamixer must be converted to
     1685.B PCM,1.
    16811686.
    16821687.TP
    16831688.B \-nowaveheader (\-ao pcm only)
  • libao2/ao_alsa.c

    RCS file: /cvsroot/mplayer/main/libao2/ao_alsa.c,v
    retrieving revision 1.7
    diff -u -r1.7 ao_alsa.c
     
    101101
    102102      static char *mix_name = "PCM";
    103103      static char *card = "default";
     104      static int mix_index = 0;
    104105
    105106      long pmin, pmax;
    106107      long get_vol, set_vol;
    107108      float f_multi;
    108109
    109       if(mixer_channel) mix_name = mixer_channel;
     110      if(mixer_channel) {
     111         char *test_mix_index;
     112
     113         mix_name = strdup(mixer_channel);
     114         if (test_mix_index = strchr(mix_name, ',')){
     115                *test_mix_index = 0;
     116                test_mix_index++;
     117                mix_index = strtol(test_mix_index, &test_mix_index, 0);
     118
     119                if (*test_mix_index){
     120                  mp_msg(MSGT_AO,MSGL_ERR,"alsa-control: invalid mixer index. Defaulting to 0\n");
     121                  mix_index = 0 ;
     122                }
     123         }
     124      }
    110125      if(mixer_device) card = mixer_device;
    111126
    112127      if(ao_data.format == AFMT_AC3)
     
    116131      snd_mixer_selem_id_alloca(&sid);
    117132       
    118133      //sets simple-mixer index and name
    119       snd_mixer_selem_id_set_index(sid, 0);
     134      snd_mixer_selem_id_set_index(sid, mix_index);
    120135      snd_mixer_selem_id_set_name(sid, mix_name);
    121136
     137      if (mixer_channel) {
     138        free(mix_name);
     139        mix_name = NULL;
     140      }
     141
    122142      if ((err = snd_mixer_open(&handle, 0)) < 0) {
    123143        mp_msg(MSGT_AO,MSGL_ERR,"alsa-control: mixer open error: %s\n", snd_strerror(err));
    124144        return CONTROL_ERROR;