mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-11-08 21:45:44 +01:00
Mux fixes...
This commit is contained in:
parent
095f7b89b3
commit
b25dbffc41
7 changed files with 149 additions and 93 deletions
|
@ -1,3 +1,15 @@
|
|||
1999-08-04 Fumihiko Murata <fmurata@p1.tcnet.ne.jp>
|
||||
|
||||
* probe.c: fixed multi haven element problem.
|
||||
|
||||
1999-08-03 Fumihiko Murata <fmurata@p1.tcnet.ne.jp>
|
||||
|
||||
* catch.c: fixed mux lock.
|
||||
|
||||
1999-07-30 Fumihiko Murata <fmurata@p1.tcnet.ne.jp>
|
||||
|
||||
* conf_w.c: fixed case of cards[i].mixer[j].ee_n = 0.
|
||||
|
||||
1999-07-19 Fumihiko Murata <fmurata@p1.tcnet.ne.jp>
|
||||
|
||||
* probe.c: fixed multi mixerdevices.
|
||||
|
|
9
gamix/README
Normal file
9
gamix/README
Normal file
|
@ -0,0 +1,9 @@
|
|||
GTK ALSA audio mixer gamix by Fumihiko Murata <fmurata@p1.tcnet.ne.jp>
|
||||
DaiCom Software
|
||||
|
||||
This is a mixer application for ALSA using GTK.
|
||||
|
||||
If you wait to use internationalized version (supported only Japanese).
|
||||
Check
|
||||
http://www1.tcnet.ne.jp/fmurata/linux/down/
|
||||
and download lastest gamix-*.tar.gz. * is version no.
|
|
@ -13,7 +13,7 @@ static void cb_rb(void *pd ) {
|
|||
}
|
||||
|
||||
static void element_callback(void *pd,int cmd,snd_mixer_eid_t *eid) {
|
||||
int i,j,k;
|
||||
int i,j;
|
||||
gint ccc;
|
||||
s_group *group;
|
||||
s_element *e;
|
||||
|
@ -30,6 +30,20 @@ static void element_callback(void *pd,int cmd,snd_mixer_eid_t *eid) {
|
|||
}
|
||||
*/
|
||||
//printf("hoe '%s',%d,%d\n",eid->name,eid->index,eid->type);
|
||||
for( i=0 ; i < mixer->ee_n ; i++ ) {
|
||||
ee=&mixer->ee[i];
|
||||
if( strcmp(ee->e.e.eid.name,eid->name)==0 &&
|
||||
ee->e.e.eid.index==eid->index ) {
|
||||
snd_mixer_element_read(mixer->handle,&ee->e.e);
|
||||
if( ee->enabled ) {
|
||||
ccc=ee->chain;
|
||||
ee->chain=FALSE;
|
||||
s_e_chk(&ee->e);
|
||||
ee->chain=ccc;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
for( i=0 ; i<mixer->groups.groups ; i++ ) {
|
||||
group=&mixer->group[i];
|
||||
for( j=0 ; j<group->g.elements ; j++ ) {
|
||||
|
@ -47,20 +61,6 @@ static void element_callback(void *pd,int cmd,snd_mixer_eid_t *eid) {
|
|||
}
|
||||
}
|
||||
}
|
||||
for( i=0 ; i < mixer->ee_n ; i++ ) {
|
||||
ee=&mixer->ee[i];
|
||||
if( strcmp(ee->e.e.eid.name,eid->name)==0 &&
|
||||
ee->e.e.eid.index==eid->index ) {
|
||||
snd_mixer_element_read(mixer->handle,&ee->e.e);
|
||||
if( ee->enabled ) {
|
||||
ccc=ee->chain;
|
||||
ee->chain=FALSE;
|
||||
s_e_chk(&ee->e);
|
||||
ee->chain=ccc;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
printf("elem hoe %d %s %d %d\n",cmd,eid->name,eid->index,eid->type);
|
||||
|
@ -80,14 +80,14 @@ gint time_callback(gpointer data) {
|
|||
for( i=0 ; i<card_num ; i++ ) {
|
||||
for( j=0 ; j<cards[i].info.mixerdevs ; j++ ) {
|
||||
cb_mix.private_data=(void *)&cards[i].mixer[j];
|
||||
snd_mixer_read(cards[i].mixer[j].handle,&cb_mix);
|
||||
err=snd_mixer_read(cards[i].mixer[j].handle,&cb_mix);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void s_e_chk( s_element *e ) {
|
||||
int i,j,err;
|
||||
int i,j;
|
||||
switch( e->e.eid.type ) {
|
||||
case SND_MIXER_ETYPE_VOLUME1:
|
||||
for( i=0 ; i<e->e.data.volume1.voices; i++ ) {
|
||||
|
|
|
@ -84,7 +84,7 @@ gint conf_win( void ) {
|
|||
GtkWidget *b;
|
||||
GtkWidget *vbox,*box,*frame,*hbox,*hhbox,*box1,*box2;
|
||||
GtkWidget *nb,*n_label;
|
||||
unsigned char gname[256];
|
||||
unsigned char gname[40];
|
||||
GSList *gp;
|
||||
|
||||
ok_pushed=FALSE;
|
||||
|
@ -199,6 +199,7 @@ gint conf_win( void ) {
|
|||
gtk_widget_show(b);
|
||||
if( k==0 ) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(b),
|
||||
TRUE);
|
||||
|
||||
gp=gtk_radio_button_group(GTK_RADIO_BUTTON(b));
|
||||
|
||||
b=gtk_radio_button_new_with_label(gp,_("space"));
|
||||
|
@ -262,45 +263,48 @@ gint conf_win( void ) {
|
|||
l++;
|
||||
gtk_widget_show(hbox);
|
||||
}
|
||||
ccard[i].m[j].ee_en=(gint *)g_malloc(cards[i].mixer[j].ee_n *
|
||||
sizeof(gint));
|
||||
if( cards[i].mixer[j].ee_n && ccard[i].m[j].ee_en == NULL) {
|
||||
fprintf(stderr,nomem_msg);
|
||||
g_free(ccard[i].m[j].g_en);
|
||||
g_free(ccard[i].m);
|
||||
g_free(ccard);
|
||||
return -1;
|
||||
}
|
||||
for( k=0 ; k<cards[i].mixer[j].ee_n ; k++ ) {
|
||||
ccard[i].m[j].ee_en[k]=cards[i].mixer[j].ee[k].enable;
|
||||
hbox=gtk_hbox_new(FALSE,2);
|
||||
b=gtk_toggle_button_new();
|
||||
gtk_widget_set_usize(b,10,10);
|
||||
gtk_box_pack_start(GTK_BOX(hbox),b,FALSE,FALSE,0);
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(b),
|
||||
ccard[i].m[j].ee_en[k]);
|
||||
gtk_signal_connect(GTK_OBJECT(b),"toggled",
|
||||
GTK_SIGNAL_FUNC(tb_callback),
|
||||
(gpointer)&ccard[i].m[j].ee_en[k]);
|
||||
gtk_widget_show(b);
|
||||
if( cards[i].mixer[j].ee[k].e.e.eid.index > 0 ) {
|
||||
sprintf(gname,"%s %d",
|
||||
cards[i].mixer[j].ee[k].e.e.eid.name,
|
||||
cards[i].mixer[j].ee[k].e.e.eid.index);
|
||||
} else {
|
||||
strcpy(gname,cards[i].mixer[j].ee[k].e.e.eid.name);
|
||||
if( cards[i].mixer[j].ee_n ) {
|
||||
ccard[i].m[j].ee_en=(gint *)g_malloc(cards[i].mixer[j].ee_n *
|
||||
sizeof(gint));
|
||||
if( ccard[i].m[j].ee_en == NULL ) {
|
||||
fprintf(stderr,nomem_msg);
|
||||
g_free(ccard[i].m[j].g_en);
|
||||
g_free(ccard[i].m);
|
||||
g_free(ccard);
|
||||
return -1;
|
||||
}
|
||||
n_label=gtk_label_new(gname);
|
||||
gtk_box_pack_start(GTK_BOX(hbox),n_label,FALSE,FALSE,0);
|
||||
gtk_widget_show(n_label);
|
||||
if( (l&1) ) {
|
||||
gtk_box_pack_start(GTK_BOX(box2),hbox,FALSE,FALSE,0);
|
||||
} else {
|
||||
gtk_box_pack_start(GTK_BOX(box1),hbox,FALSE,FALSE,0);
|
||||
for( k=0 ; k<cards[i].mixer[j].ee_n ; k++ ) {
|
||||
ccard[i].m[j].ee_en[k]=cards[i].mixer[j].ee[k].enable;
|
||||
hbox=gtk_hbox_new(FALSE,2);
|
||||
b=gtk_toggle_button_new();
|
||||
gtk_widget_set_usize(b,10,10);
|
||||
gtk_box_pack_start(GTK_BOX(hbox),b,FALSE,FALSE,0);
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(b),
|
||||
ccard[i].m[j].ee_en[k]);
|
||||
gtk_signal_connect(GTK_OBJECT(b),"toggled",
|
||||
GTK_SIGNAL_FUNC(tb_callback),
|
||||
(gpointer)&ccard[i].m[j].ee_en[k]);
|
||||
gtk_widget_show(b);
|
||||
if( cards[i].mixer[j].ee[k].e.e.eid.index > 0 ) {
|
||||
sprintf(gname,"%s %d",
|
||||
cards[i].mixer[j].ee[k].e.e.eid.name,
|
||||
cards[i].mixer[j].ee[k].e.e.eid.index);
|
||||
} else {
|
||||
strcpy(gname,cards[i].mixer[j].ee[k].e.e.eid.name);
|
||||
}
|
||||
n_label=gtk_label_new(gname);
|
||||
gtk_box_pack_start(GTK_BOX(hbox),n_label,FALSE,FALSE,0);
|
||||
gtk_widget_show(n_label);
|
||||
if( (l&1) ) {
|
||||
gtk_box_pack_start(GTK_BOX(box2),hbox,FALSE,FALSE,0);
|
||||
} else {
|
||||
gtk_box_pack_start(GTK_BOX(box1),hbox,FALSE,FALSE,0);
|
||||
}
|
||||
l++;
|
||||
gtk_widget_show(hbox);
|
||||
}
|
||||
l++;
|
||||
gtk_widget_show(hbox);
|
||||
}
|
||||
|
||||
gtk_widget_show(box1);
|
||||
gtk_widget_show(box2);
|
||||
gtk_widget_show(hhbox);
|
||||
|
@ -596,8 +600,6 @@ void conf_write(void) {
|
|||
|
||||
static void chk_cfile( void ) {
|
||||
int i,j,k,err;
|
||||
FILE *fp;
|
||||
DIR *dp;
|
||||
gchar *name;
|
||||
|
||||
k=strlen(g_get_home_dir());
|
||||
|
|
|
@ -19,7 +19,7 @@ static void exit_gtk(GtkWidget *w,gpointer data) {
|
|||
}
|
||||
|
||||
int main( int argc , char **argv ) {
|
||||
int i,j;
|
||||
int i;
|
||||
gchar *dirname,*filename;
|
||||
|
||||
i=probe_mixer();
|
||||
|
@ -141,7 +141,7 @@ void disp_toolbar(void) {
|
|||
}
|
||||
|
||||
static void sel_mctype(GtkWidget *w,gpointer n) {
|
||||
int i,j;
|
||||
int i;
|
||||
GtkRequisition rq;
|
||||
|
||||
i=(int)n;
|
||||
|
@ -157,7 +157,7 @@ static void sel_mctype(GtkWidget *w,gpointer n) {
|
|||
int disp_mixer( void ) {
|
||||
int i,j;
|
||||
GtkWidget *n_label;
|
||||
GtkWidget *sep,*frame;
|
||||
GtkWidget *frame;
|
||||
GtkRequisition rq;
|
||||
|
||||
switch( conf.wmode ) {
|
||||
|
|
|
@ -19,7 +19,7 @@ static void chain_callback2(GtkToggleButton *,s_eelements *);
|
|||
static gint mk_element(s_element *,GtkBox *);
|
||||
|
||||
static void close_callback(GtkWidget *w,s_mixer *mixer) {
|
||||
int i,j,err;
|
||||
int i;
|
||||
s_group *g;
|
||||
s_eelements *ee;
|
||||
|
||||
|
@ -85,7 +85,7 @@ static void volume1_callback(GtkAdjustment *adj,s_element *e) {
|
|||
}
|
||||
|
||||
static void switch1_callback(GtkToggleButton *b,s_element *e ) {
|
||||
int i,j,k,err;
|
||||
int i,j;
|
||||
|
||||
for( i=0 ; i<e->e.data.switch1.sw; i++ ) {
|
||||
if( b == (GtkToggleButton *)e->w[i] ) break;
|
||||
|
@ -108,7 +108,7 @@ static void switch2_callback(GtkToggleButton *b,s_element *e ) {
|
|||
int err;
|
||||
|
||||
e->e.data.switch2.sw=b->active;
|
||||
snd_mixer_element_write(cards[e->card].mixer[e->mdev].handle,&e->e);
|
||||
err=snd_mixer_element_write(cards[e->card].mixer[e->mdev].handle,&e->e);
|
||||
}
|
||||
|
||||
static void chain_callback(GtkToggleButton *b,s_group *g ) {
|
||||
|
@ -150,7 +150,7 @@ static void mux1_callback(GtkItem *item,s_element *e ) {
|
|||
e->mux[no].index == e->e.data.mux1.poutput[ch].index &&
|
||||
e->mux[no].type == e->e.data.mux1.poutput[ch].type ) return;
|
||||
|
||||
if( e->chain ) {
|
||||
if( *e->chain ) {
|
||||
for( i=0 ; i<e->e.data.mux1.output ; i++ ) {
|
||||
e->e.data.mux1.poutput[i]=e->mux[no];
|
||||
if( ch != i ) gtk_option_menu_set_history(
|
||||
|
@ -166,7 +166,7 @@ static void mux1_callback(GtkItem *item,s_element *e ) {
|
|||
}
|
||||
|
||||
static void mux2_callback(GtkItem *item,s_element *e ) {
|
||||
int i,no,err;
|
||||
int no,err;
|
||||
|
||||
no=(int)gtk_object_get_data(GTK_OBJECT(item),"no");
|
||||
|
||||
|
@ -238,7 +238,7 @@ static void chain_callback2(GtkToggleButton *b,s_eelements *ee ) {
|
|||
}
|
||||
|
||||
GtkWidget *make_mixer( gint c_n , gint m_n ) {
|
||||
int i,j,k,l,err;
|
||||
int i,j,err;
|
||||
GtkWidget *mv_box,*m_name;
|
||||
GtkWidget *s_win;
|
||||
GtkWidget *mh_box;
|
||||
|
@ -246,9 +246,9 @@ GtkWidget *make_mixer( gint c_n , gint m_n ) {
|
|||
GtkWidget *iv_box;
|
||||
GtkWidget *ih_box;
|
||||
GtkWidget *c_l;
|
||||
char gname[128];
|
||||
char gname[40];
|
||||
s_mixer *mixer;
|
||||
s_group *group;
|
||||
s_group *group=NULL;
|
||||
s_element *e;
|
||||
s_eelements *ee;
|
||||
|
||||
|
@ -440,7 +440,7 @@ GtkWidget *make_mixer( gint c_n , gint m_n ) {
|
|||
}
|
||||
|
||||
gint mk_element(s_element *e,GtkBox *iv_box) {
|
||||
int i,j,k,err;
|
||||
int i,j,k;
|
||||
GtkWidget *ih_box;
|
||||
GtkWidget *menu,*c_l,*item;
|
||||
|
||||
|
|
|
@ -4,19 +4,20 @@
|
|||
int card_num,mdev_num;
|
||||
s_card *cards;
|
||||
|
||||
static int search_es(snd_mixer_eid_t *,snd_mixer_elements_t *);
|
||||
static gint ab_chk( s_mixer *,snd_mixer_eid_t * );
|
||||
static int s_element_build(snd_mixer_t *,s_element *,snd_mixer_elements_t *,
|
||||
snd_mixer_eid_t ,int , int);
|
||||
static gint mk_mux_lst(snd_mixer_t *,snd_mixer_elements_t *,snd_mixer_element_info_t *,snd_mixer_eid_t **);
|
||||
|
||||
gint probe_mixer( void ) {
|
||||
int err,i,j,k,l;
|
||||
int err,i,j,k,l,m;
|
||||
snd_ctl_t *p_handle;
|
||||
snd_mixer_t *m_handle;
|
||||
snd_mixer_elements_t es;
|
||||
snd_mixer_element_t ee;
|
||||
s_mixer *mixer;
|
||||
s_group *group;
|
||||
int *es_nums;
|
||||
|
||||
card_num=snd_cards();
|
||||
cards=(s_card *)g_malloc(sizeof(s_card)*card_num);
|
||||
|
@ -121,6 +122,14 @@ gint probe_mixer( void ) {
|
|||
snd_mixer_close(m_handle);
|
||||
return -1;
|
||||
}
|
||||
es_nums = (int *)g_malloc(es.elements * sizeof(int));
|
||||
if( es_nums == NULL ) {
|
||||
fprintf(stderr,nomem_msg);
|
||||
snd_ctl_close(p_handle);
|
||||
snd_mixer_close(m_handle);
|
||||
return -1;
|
||||
}
|
||||
bzero(es_nums,es.elements * sizeof(int));
|
||||
//printf("Card %d mixer %d\n",i,j);
|
||||
for( k=0 ; k<mixer->groups.groups ; k++ ) {
|
||||
group=&mixer->group[k];
|
||||
|
@ -162,6 +171,11 @@ gint probe_mixer( void ) {
|
|||
return -1;
|
||||
}
|
||||
for( l=0 ; l<group->g.elements ; l++ ) {
|
||||
m=search_es( &group->g.pelements[l],&es );
|
||||
if( m>-1 ) {
|
||||
if( es_nums[m] ) group->g.pelements[l].type=0;
|
||||
es_nums[m]++;
|
||||
}
|
||||
err=s_element_build(m_handle,&group->e[l],&es,
|
||||
group->g.pelements[l],i,j);
|
||||
if( err<0 ) {
|
||||
|
@ -171,6 +185,24 @@ gint probe_mixer( void ) {
|
|||
}
|
||||
}
|
||||
}
|
||||
for( k=0 ; k<es.elements ; k++ ) {
|
||||
if( es_nums[k] > 1 ) {
|
||||
for( l=0 ; l<mixer->groups.groups ; l++ ) {
|
||||
group=&mixer->group[l];
|
||||
for( m=0 ; m<group->g.elements; m++ ) {
|
||||
if( strcmp( es.pelements[k].name,group->g.pelements[m].name)==0 &&
|
||||
es.pelements[k].index == group->g.pelements[m].index &&
|
||||
es.pelements[k].type == group->g.pelements[m].type ) {
|
||||
group->e[m].e.eid.type=0;
|
||||
group->e[m].info.eid.type=0;
|
||||
l=mixer->groups.groups;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
l=0;
|
||||
for( k=0 ; k<es.elements ; k++ ) {
|
||||
/*
|
||||
|
@ -179,15 +211,16 @@ gint probe_mixer( void ) {
|
|||
mixer->es.pelements[k].index,
|
||||
mixer->es.pelements[k].type);
|
||||
*/
|
||||
//if( mixer->es.pelements[k].type > 99 ) {
|
||||
if( ab_chk(mixer,&es.pelements[k]) ) {
|
||||
l++;
|
||||
/*
|
||||
printf("Element '%s',%d,%d\n",
|
||||
es.pelements[k].name,
|
||||
es.pelements[k].index,
|
||||
es.pelements[k].type);
|
||||
*/
|
||||
if( es_nums[k] == 0 || es_nums[k]>1 ) {
|
||||
if( ab_chk(mixer,&es.pelements[k]) ) {
|
||||
l++;
|
||||
/*
|
||||
printf("Element '%s',%d,%d\n",
|
||||
es.pelements[k].name,
|
||||
es.pelements[k].index,
|
||||
es.pelements[k].type);
|
||||
*/
|
||||
} else es_nums[k]=1;
|
||||
}
|
||||
}
|
||||
mixer->ee_n=l;
|
||||
|
@ -203,7 +236,7 @@ gint probe_mixer( void ) {
|
|||
k=0;
|
||||
while(l>0) {
|
||||
l--;
|
||||
while( !ab_chk(mixer,&es.pelements[k]) ) k++;
|
||||
while( es_nums[k]==1 ) k++;
|
||||
err=s_element_build(m_handle,&mixer->ee[l].e,&es,
|
||||
es.pelements[k],i,j);
|
||||
|
||||
|
@ -213,16 +246,25 @@ gint probe_mixer( void ) {
|
|||
}
|
||||
}
|
||||
g_free(es.pelements);
|
||||
g_free(es_nums);
|
||||
snd_mixer_close(m_handle);
|
||||
}
|
||||
snd_ctl_close(p_handle);
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int search_es(snd_mixer_eid_t *eid,snd_mixer_elements_t *es) {
|
||||
int i;
|
||||
for( i=0 ; i<es->elements ; i++ ) {
|
||||
if( strcmp( es->pelements[i].name , eid->name ) == 0 &&
|
||||
es->pelements[i].index == eid->index &&
|
||||
es->pelements[i].type == eid->type ) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
static gint ab_chk( s_mixer *mixer,snd_mixer_eid_t *eid ) {
|
||||
int i,j;
|
||||
|
||||
switch( eid->type ) {
|
||||
case SND_MIXER_ETYPE_SWITCH1:
|
||||
|
@ -238,16 +280,6 @@ static gint ab_chk( s_mixer *mixer,snd_mixer_eid_t *eid ) {
|
|||
default:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
for( i=0 ; i<mixer->groups.groups ; i++ ) {
|
||||
if( strncmp(mixer->groups.pgroups[i].name,eid->name,2) == 0 ) {
|
||||
for( j=0 ; j<mixer->group[i].g.elements ; j++ ) {
|
||||
if( strcmp(mixer->group[i].e[j].e.eid.name , eid->name) == 0 &&
|
||||
mixer->group[i].e[j].e.eid.index == eid->index &&
|
||||
mixer->group[i].e[j].e.eid.type == eid->type ) return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -260,7 +292,8 @@ static int s_element_build(snd_mixer_t *handle,s_element *e,
|
|||
e->e.eid = eid;
|
||||
e->info.eid = eid;
|
||||
if( eid.type != SND_MIXER_ETYPE_SWITCH1 &&
|
||||
eid.type != SND_MIXER_ETYPE_SWITCH2 ) {
|
||||
eid.type != SND_MIXER_ETYPE_SWITCH2 &&
|
||||
eid.type > 0 ) {
|
||||
err=snd_mixer_element_info_build(handle,&e->info);
|
||||
if( err<0 ) {
|
||||
preid(eid);
|
||||
|
|
Loading…
Reference in a new issue