Changeset 3688

Show
Ignore:
Timestamp:
02/20/06 19:15:38 (8 years ago)
Author:
piers
Message:

Updates to allow use of Audigy (emu10k1) style cards which don't have have a device
named "Capture" - and generate an error when attempts are made to call:
open_volume_ctl(RAT_ALSA_MIXER_CAPTURE_NAME, &gain) so this is call now doesn't
cause a return FALSE. Instead one has to use volume controls on individual inputs
and/or the "Mix" inputs. Also these cards don't have "capture_switches" - as
inputs are just controlled by mixer levels.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • rat/trunk/auddev_alsa.c

    r3687 r3688  
    367367{ 
    368368  snd_mixer_selem_id_t *sid; 
    369   int err=NULL; 
     369  int err=0; 
    370370 
    371371  snd_mixer_selem_id_alloca(&sid); 
     
    380380  //CHECKOPENERR("Couldn't find mixer control element"); 
    381381  if (*ctl == NULL ) { 
    382    fprintf(stderr,"ALSA:Couldn't find mixer control element (name:%s)\n",name); 
     382   debug_msg("Couldn't find mixer control element (name:%s)\n",name); 
    383383   return FALSE; 
    384384  } 
    385385 
    386   printf("open_volume_ctl err2:%d\n",err); 
    387386  if (snd_mixer_selem_has_playback_volume(*ctl)) { 
    388387    debug_msg("Got volume control %s of type PLAY\n", name); 
     
    423422    int err; 
    424423    unsigned i; 
     424    int need_cap_switch=1; 
    425425     
    426426    err = snd_mixer_open (&current.mixer, 0); 
     
    441441 
    442442    // Get the playback and capture volume controls 
    443     if ((!open_volume_ctl(RAT_ALSA_MIXER_PCM_NAME, &current.txgain)) || 
     443    /*if ((!open_volume_ctl(RAT_ALSA_MIXER_PCM_NAME, &current.txgain)) || 
    444444        (!open_volume_ctl(RAT_ALSA_MIXER_CAPTURE_NAME, &current.rxgain))) 
    445             return FALSE;        
     445            return FALSE;       */ 
     446    if (!open_volume_ctl(RAT_ALSA_MIXER_PCM_NAME, &current.txgain))  
     447            return FALSE; 
     448    if (!open_volume_ctl(RAT_ALSA_MIXER_CAPTURE_NAME, &current.rxgain)) 
     449      need_cap_switch=0; 
    446450 
    447451    num_iports = 0; 
     
    454458        elem = snd_mixer_elem_next (elem)) 
    455459    { 
    456       if (snd_mixer_selem_is_active (elem) && 
    457           snd_mixer_selem_has_capture_switch(elem) && 
    458           snd_mixer_selem_has_capture_switch_exclusive(elem)) 
     460        int gid = snd_mixer_selem_get_capture_group(elem); 
     461        const char *name = snd_mixer_selem_get_name(elem); 
     462        debug_msg("Trying CAPTURE element '%s' of group %d \n", name, gid); 
     463 
     464      if (snd_mixer_selem_has_capture_volume(elem) || 
     465          snd_mixer_selem_has_capture_switch(elem) ) 
     466      //    snd_mixer_selem_is_active (elem) && 
     467      //    (snd_mixer_selem_has_capture_switch(elem)) && 
     468      //    snd_mixer_selem_has_capture_switch_exclusive(elem)) 
    459469      { 
    460470        // FIXME: It's theoretically possible that there would be more 
    461471        // than one capture group, but RAT isn't really equipped to handle 
    462472        // the case so we'll just ignore it for now. 
    463         int gid = snd_mixer_selem_get_capture_group(elem); 
    464  
    465         const char *name = snd_mixer_selem_get_name(elem); 
     473 
    466474 
    467475        debug_msg("Got CAPTURE element '%s' of group %d\n", name, gid); 
     
    594602    err = snd_pcm_drain(current.rx.handle); 
    595603    VCHECKERR("Problem draining input"); 
    596     } 
     604} 
    597605     
    598606 
     
    606614    debug_msg("Set igain %d %d\n", ad, gain); 
    607615 
     616    //err = snd_mixer_selem_set_capture_volume_all(current.rxgain, gain); 
    608617    err = snd_mixer_selem_set_capture_volume_all(current.rxgain, gain); 
    609618    VCHECKERR("Couldn't set capture volume"); 
     
    620629    debug_msg("Get igain %d\n", ad); 
    621630 
     631    //err = snd_mixer_selem_get_capture_volume(current.rxgain, 
    622632    err = snd_mixer_selem_get_capture_volume(current.rxgain, 
    623633                                             SND_MIXER_SCHN_MONO, &igain); 
     
    639649    int err; 
    640650 
    641     debug_msg("Set igain %d %d\n", ad, vol); 
     651    debug_msg("Set ogain %d %d\n", ad, vol); 
    642652 
    643653    err = snd_mixer_selem_set_playback_switch_all(current.txgain, 1); 
     
    658668    int err; 
    659669 
    660     debug_msg("Get igain %d\n", ad); 
     670    debug_msg("Get ogain %d\n", ad); 
    661671    err = snd_mixer_selem_get_playback_volume(current.txgain, 
    662672                                             SND_MIXER_SCHN_MONO, &ogain); 
     
    814824    debug_msg("oport_set %d %d\n", ad, port); 
    815825} 
     826 
    816827audio_port_t 
    817828alsa_audio_oport_get(audio_desc_t ad) 
     
    828839} 
    829840 
    830 const audio_port_details_t* alsa_audio_oport_details(audio_desc_t ad, int idx) 
     841const audio_port_details_t* 
     842alsa_audio_oport_details(audio_desc_t ad, int idx) 
    831843{ 
    832844        debug_msg("oport details ad=%d idx=%d\n", ad, idx); 
     
    849861            iports[i].mixer, (i==port)); 
    850862    } 
     863    if (err<0)  
     864      current.rxgain=iports[port].mixer; 
     865 
    851866    VCHECKERR("Failed to set record switch"); 
    852867}