Пример #1
0
void
gam_app_update_visibility (GamApp *gam_app, GtkWidget *widget, 
        snd_mixer_elem_t *elem, gboolean saved_state){
    
    g_return_if_fail (GAM_IS_APP (gam_app));
    
    GamMixer *gam_mixer=gam_app_get_current_mixer(gam_app);
    
    int is_playback= snd_mixer_selem_has_playback_volume(elem)
                  || snd_mixer_selem_has_playback_switch(elem)
                  || (snd_mixer_selem_is_enumerated(elem) 
                    && snd_mixer_selem_is_enum_playback(elem));
    int is_capture = snd_mixer_selem_has_capture_volume(elem)
                  || snd_mixer_selem_has_capture_switch(elem)
                  || (snd_mixer_selem_is_enumerated(elem) 
                    && snd_mixer_selem_is_enum_capture(elem));
    //If nothing showed set show all
    if(!(gam_mixer_get_show_playback_elements(gam_mixer)||gam_mixer_get_show_capture_elements(gam_mixer)))
       gam_mixer_set_capture_playback(gam_app_get_current_mixer(gam_app), TRUE, TRUE);
    
    if(saved_state
       && ((is_playback && gam_mixer_get_show_playback_elements(gam_mixer))
       || (is_capture && gam_mixer_get_show_capture_elements(gam_mixer))))
      gtk_widget_show(widget);
    else        
      gtk_widget_hide(widget);
}
Пример #2
0
/*
 * The purpose of this function is to let the user to select 
 *   the input where he plugged his signals.
 * Now if user select "default", as device, we have to select the input
 *   on the mixer of the card used by  "default".
 * What is the card used by device  "default" ?
 */ 
static void
as_setup_input_combo (GtkWidget *combo, SoundParams *sparams)
{
   snd_mixer_t *handle;
   int i ;
   snd_mixer_selem_id_t *sid;
   snd_mixer_elem_t *elem;
   snd_mixer_selem_id_alloca(&sid);
   char *devname;
   char name[32];

   devname = sparams->device_name;
   if ( *sparams->indexstr == '-' ) {
      sprintf(name, "hw:%d", sparams->firstcard);
      devname = name;
   }
   handle = sound_open_mixer(devname);
   if ( handle == NULL ){
      return ;
   }   

   for (elem = snd_mixer_first_elem(handle); elem; elem = snd_mixer_elem_next(elem)) {
      snd_mixer_selem_get_id(elem, sid);
      if (! snd_mixer_selem_is_active(elem)) {
	 continue;
      }
      const char *control_name = snd_mixer_selem_id_get_name(sid);
//      printf("Simple mixer control '%s',%i\n", control_name,  snd_mixer_selem_id_get_index(sid));
      if (snd_mixer_selem_is_enum_capture(elem)) {
	 int items;
	 char itemname[40];
	 app_free(sparams->control_name);
	 sparams->control_name = app_strdup(control_name);
	 items = snd_mixer_selem_get_enum_items(elem);
//	 printf("  Items:");
	 for (i = 0; i < items; i++) {
	    snd_mixer_selem_get_enum_item_name(elem, i, sizeof(itemname) - 1, itemname);
//	    printf(" '%s'", itemname);
            gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), itemname );
	    if ( i == sparams->input ) {
	       gtk_combo_box_set_active (GTK_COMBO_BOX (combo), i);
	    }
	 }
//	 printf("\n");
      }
   }
   snd_mixer_close(handle);
   return ;
}
Пример #3
0
MixerElem *lamixer_volelem_new(snd_mixer_elem_t *elem)
{
	MixerElem *mixer_elem;
	guint voltype=0, elemidx=0, mono;
	long minrange=0,maxrange=0,rangevalue_left=0,rangevalue_right=0;
	const char* selem_name = NULL;
	char elem_name[64];
	
	mixer_elem = g_malloc(sizeof(MixerElem));
	mixer_elem->elem = elem;
	mixer_elem->playback = NULL;
	mixer_elem->capture = NULL;
	mixer_elem->pswitch = NULL;
	mixer_elem->cswitch = NULL;
	mixer_elem->penum = NULL;
	mixer_elem->cenum = NULL;
	
	elemidx = snd_mixer_selem_get_index(elem);
	selem_name = snd_mixer_selem_id_get_name(sid);
	strcpy(elem_name, selem_name);
	if(elemidx > 0) {
		sprintf(elem_name,"%s %i",elem_name, elemidx);
	}
	
	if (!snd_mixer_selem_is_enumerated(elem)) {
		if (snd_mixer_selem_has_playback_volume(elem)) {
			voltype = 1;
			snd_mixer_selem_get_playback_volume_range (elem, &minrange, &maxrange);
			mono = snd_mixer_selem_is_playback_mono(elem);
			snd_mixer_selem_get_playback_volume (elem, SND_MIXER_SCHN_FRONT_LEFT, &rangevalue_left);
			
			if(!mono)
				snd_mixer_selem_get_playback_volume (elem, SND_MIXER_SCHN_FRONT_RIGHT, &rangevalue_right);
			
			mixer_elem->playback = lamixer_volbox_new(elem_name,mono, \
			                                                (snd_mixer_selem_has_playback_switch(elem) || snd_mixer_selem_has_playback_switch_joined(elem)), minrange, maxrange, elem, voltype);
		}
		else if (snd_mixer_selem_has_playback_switch(elem)) {
			voltype = 1;
			mixer_elem->pswitch = lamixer_switchbox_add(elem_name, elem, voltype);
		}
		
		if (snd_mixer_selem_has_capture_volume(elem)) {
			voltype = 2;
			snd_mixer_selem_get_capture_volume_range (elem, &minrange, &maxrange);
			mono = snd_mixer_selem_is_capture_mono(elem);
			snd_mixer_selem_get_capture_volume (elem, SND_MIXER_SCHN_FRONT_LEFT, &rangevalue_left);
			
			if(!mono)
				snd_mixer_selem_get_capture_volume (elem, SND_MIXER_SCHN_FRONT_RIGHT, &rangevalue_right);
			
			mixer_elem->capture = lamixer_volbox_new(elem_name,mono, \
									(snd_mixer_selem_has_capture_switch(elem) || snd_mixer_selem_has_capture_switch_joined(elem)), minrange, maxrange, elem, voltype);
		}
		else if (snd_mixer_selem_has_capture_switch(elem)) {
			voltype = 2;
			mixer_elem->cswitch = lamixer_switchbox_add(elem_name, elem, voltype);
		}
	}
	else {
		if (snd_mixer_selem_is_enum_playback(elem)) {
			voltype = 1;
			mixer_elem->penum = lamixer_enumbox_add(elem_name, elem, voltype);
		}
		else if (snd_mixer_selem_is_enum_capture(elem)) {
			voltype = 2;
			mixer_elem->cenum = lamixer_enumbox_add(elem_name, elem, voltype);
		}
	}
		
	return mixer_elem;
}