GTK mixer programs xamixer2 & gamix were removed.

The reason is the difficult maintaince.
This commit is contained in:
Jaroslav Kysela 2000-01-05 13:46:58 +00:00
parent fa88a97078
commit 8e2b523a92
43 changed files with 6 additions and 6486 deletions

View file

@ -1,15 +1,5 @@
INCLUDES=-I$(top_srcdir)/include INCLUDES=-I$(top_srcdir)/include
SUBDIRS1=include alsactl alsamixer amixer aplay seq utils SUBDIRS=include alsactl alsamixer amixer aplay seq utils
if COND_XAMIXER2
SUBDIRS2=$(SUBDIRS1) xamixer2
else
SUBDIRS2=$(SUBDIRS1)
endif
if COND_GAMIX
SUBDIRS=$(SUBDIRS2) gamix
else
SUBDIRS=$(SUBDIRS2)
endif
EXTRA_DIST=ChangeLog INSTALL README configure cvscompile EXTRA_DIST=ChangeLog INSTALL README configure cvscompile
rpm: dist rpm: dist

View file

@ -5,7 +5,7 @@ AM_INIT_AUTOMAKE(alsa-utils, 0.5.0)
dnl Checks for programs. dnl Checks for programs.
AC_PROG_CC AC_PROG_CC
AC_PROG_CXX dnl AC_PROG_CXX
AC_PROG_INSTALL AC_PROG_INSTALL
AC_PROG_LN_S AC_PROG_LN_S
AC_PROG_YACC AC_PROG_YACC
@ -24,10 +24,8 @@ AC_SUBST(CURSESINC)
AC_SUBST(CURSESLIB) AC_SUBST(CURSESLIB)
dnl Check for Gtk+ dnl Check for Gtk+
AM_PATH_GTK(1.0.1) dnl AM_PATH_GTK(1.0.1)
CFLAGS="$CFLAGS $GTK_CFLAGS" dnl CFLAGS="$CFLAGS $GTK_CFLAGS"
# LDFLAGS="$LDFLAGS $GTK_LIBS"
AM_CONFIG_HEADER(include/aconfig.h) AM_CONFIG_HEADER(include/aconfig.h)
@ -41,14 +39,6 @@ AC_PROG_GCC_TRADITIONAL
SAVE_UTIL_VERSION SAVE_UTIL_VERSION
AM_CONDITIONAL(COND_XAMIXER2, test "x$GTK_LIBS" != "x")
if test "x$GTK_LIBS" = "x"; then
AC_MSG_RESULT(Not building XAmixer2 as Gtk+ was not found.)
fi
AM_CONDITIONAL(COND_GAMIX, test "x$GTK_LIBS" != "x")
if test "x$GTK_LIBS" = "x"; then
AC_MSG_RESULT(Not building gamix as Gtk+ was not found.)
fi
AC_OUTPUT(Makefile alsactl/Makefile alsamixer/Makefile amixer/Makefile aplay/Makefile \ AC_OUTPUT(Makefile alsactl/Makefile alsamixer/Makefile amixer/Makefile aplay/Makefile \
include/Makefile utils/Makefile utils/alsa-utils.spec xamixer2/Makefile include/Makefile utils/Makefile utils/alsa-utils.spec \
gamix/Makefile seq/Makefile seq/aconnect/Makefile seq/aseqnet/Makefile) seq/Makefile seq/aconnect/Makefile seq/aseqnet/Makefile)

View file

@ -1,66 +0,0 @@
1999-11-03 Fumihiko Murata <fmurata@p1.tcnet.ne.jp>
* main.c: add some messages.
1999-10-19 Fumihiko Murata <fmurata@p1.tcnet.ne.jp>
* conf_w.c: imprement mixer reorder.
1999-10-16 Fumihiko Murata <fmurata@p1.tcnet.ne.jp>
* main.c: add "-h" option.
1999-10-11 Fumihiko Murata <fmurata@p1.tcnet.ne.jp>
* main.c: imprement config select "-c" option.
1999-10-08 Fumihiko Murata <fmurata@p1.tcnet.ne.jp>
* supported dynamic element.
1999-10-01 Fumihiko Murata <fmurata@p1.tcnet.ne.jp>
* conf_w.c: fix spacing mode.
1999-09-26 Fumihiko Murata <fmurata@p1.tcnet.ne.jp>
* change array to chain.
1999-09-25 Fumihiko Murata <fmurata@p1.tcnet.ne.jp>
* conf_w.c: fix read config file.
1999-09-14 Fumihiko Murata <fmurata@p1.tcnet.ne.jp>
* start support element type pc1.
1999-09-06 Fumihiko Murata <fmurata@p1.tcnet.ne.jp>
* probe.c : free none used mux memory.
1999-08-16 Fumihiko Murata <fmurata@p1.tcnet.ne.jp>
* catch.c : add element tone control.
* mkmixer.c : add element tone control.
1999-08-11 Fumihiko Murata <fmurata@p1.tcnet.ne.jp>
* catch.c : add 3d effect 7th param.
* mkmixer.c : add 3d effect 7th param.
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.

View file

@ -1,9 +0,0 @@
bin_PROGRAMS = gamix
INCLUDES = -DLOCALEDIR=\""$(datadir)/locale"\"
DEFS := $(DEFS) -DPACKAGE=\""alsa-utils\"" -DVERSION=\""$(VERSION)\""
gamix_SOURCES = gamix.h main.c mkmixer.c probe.c catch.c conf_w.c
gamix_LDFLAGS = $(GTK_LIBS)
EXTRA_DIST = ChangeLog

View file

@ -1,10 +0,0 @@
GTK ALSA audio mixer gamix ver. 1.09p4
by Fumihiko Murata <fmurata@p1.tcnet.ne.jp>
DaiCom Software
This is a mixer application for ALSA using GTK.
If you want to use international version (supported Japanese only),
check original source
http://www1.tcnet.ne.jp/fmurata/linux/down/
and download last gamix-*.tar.gz. * is version number.

View file

@ -1,651 +0,0 @@
#include "gamix.h"
typedef struct e_q_cell e_q_cell_t;
struct e_q_cell {
snd_mixer_eid_t eid;
e_q_cell_t *next;
};
typedef struct g_q_cell g_q_cell_t;
struct g_q_cell {
snd_mixer_gid_t gid;
g_q_cell_t *next;
};
static snd_mixer_callbacks_t cb_mix;
static char *cmd_name[]={"rebuild","element value","element change",
"element route","element add","element remove",
"group value","group change","group add",
"group remove"
};
static struct {
e_q_cell_t *q;
int q_n;
} e_q;
static struct {
g_q_cell_t *q;
int q_n;
} g_q;
static void cb_rb(void *);
static void element_callback(void *,int,snd_mixer_eid_t *);
static void cb_gp(void *,int,snd_mixer_gid_t *);
static void search_obj_elem(s_obj_t **,s_element_t **,snd_mixer_eid_t *);
static void s_e_chk(s_element_t *);
static void rmw_elem(s_element_t *);
static int que_e( snd_mixer_eid_t * );
static int que_g( snd_mixer_gid_t * );
static int chk_group( s_mixer_t * );
static void element_free(s_element_t *);
static gboolean chk_eid(s_obj_t *,snd_mixer_eid_t * );
extern GtkWidget *main_vbox;
extern GtkWidget *mixer_container;
static void cb_rb(void *pd ) {
printf("cb rb hoe\n");
}
static void element_callback(void *pd,int cmd,snd_mixer_eid_t *eid) {
int i,j;
gint ccc;
s_group_t *group;
s_element_t *e;
s_eelements_t *ee;
s_mixer_t *mixer=(s_mixer_t *)pd;
s_obj_t *obj=mixer->obj;
if( !is_etype(eid->type) ) return;
search_obj_elem(&obj,&e,eid);
switch( cmd ) {
case SND_MIXER_READ_ELEMENT_VALUE:
if( obj == NULL || e == NULL ) break;
snd_mixer_element_read(mixer->handle,&e->e);
if( obj->enabled ) {
ccc=obj->chain;
obj->chain=FALSE;
s_e_chk(e);
obj->chain=ccc;
}
return;
break;
case SND_MIXER_READ_ELEMENT_REMOVE:
if( obj == NULL || e == NULL ) break;
if( obj->enabled ) rmw_elem(e);
return;
break;
case SND_MIXER_READ_ELEMENT_ADD:
if( obj && e ) {
return;
} else {
if( que_e(eid) == 0 ) return;
}
break;
case SND_MIXER_READ_ELEMENT_CHANGE:
case SND_MIXER_READ_ELEMENT_ROUTE:
default:
printf("eb el cmd %s eid '%s',%d,%d\n",cmd_name[cmd],eid->name,eid->index,eid->type);
return;
}
printf("cb_el cmd %s %s %d %d\n",cmd_name[cmd],eid->name,eid->index,
eid->type);
}
static void search_obj_elem( s_obj_t **objs,s_element_t **e_r,
snd_mixer_eid_t *eid) {
s_element_t *e;
s_eelements_t *ee;
s_group_t *group;
s_obj_t *obj;
int j;
for( obj=*objs ; obj != NULL ; obj=obj->next ) {
if( obj->e ) {
ee=obj->e;
if( strcmp(ee->e.e.eid.name,eid->name)==0 &&
ee->e.e.eid.index==eid->index ) {
*objs=obj;
*e_r=&ee->e;
return;
}
}
if( obj->g ) {
group=obj->g;
for( j=0 ; j<group->g.elements ; j++ ) {
e=&group->e[j];
if( strcmp(e->e.eid.name,eid->name) == 0 &&
e->e.eid.index == eid->index && e->e.eid.type != 0 ) {
*objs=obj;
*e_r=e;
return;
}
}
}
}
*objs=NULL;
*e_r=NULL;
}
static int que_e(snd_mixer_eid_t *eid ) {
e_q_cell_t *p;
if( e_q.q == NULL ) {
e_q.q=(e_q_cell_t *)malloc(sizeof(e_q_cell_t));
if( e_q.q == NULL ) {
fprintf(stderr,nomem_msg);
return -1;
}
p=e_q.q;
p->eid=*eid;
p->next=NULL;
e_q.q_n=1;
return 0;
}
p=e_q.q;
while( p->next != NULL ) {
if( strcmp(p->eid.name,eid->name) == 0 && p->eid.index == eid->index )
return 0;
p=p->next;
}
if( strcmp(p->eid.name,eid->name) == 0 && p->eid.index == eid->index )
return 0;
p->next=(e_q_cell_t *)malloc(sizeof(e_q_cell_t));
if( p->next==NULL ) {
fprintf(stderr,nomem_msg);
return -1;
}
p=p->next;
p->eid=*eid;
p->next=NULL;
e_q.q_n++;
return 0;
}
static void cb_gp(void *pd,int cmd,snd_mixer_gid_t *gid) {
s_mixer_t *mixer=(s_mixer_t *)pd;
s_obj_t *obj=mixer->obj,*o1;
s_group_t *g;
int i;
for( ; obj != NULL ; obj=obj->next ) {
if( obj->g ) {
g=obj->g;
if( strcmp(g->g.gid.name,gid->name) == 0 &&
g->g.gid.index == gid->index ) {
break;
}
}
}
switch(cmd) {
case SND_MIXER_READ_GROUP_REMOVE:
if( obj ) {
if( obj->enabled ) {
gtk_widget_destroy(obj->v_frame);
}
obj->dyn_e=2;
obj->enabled=FALSE;
return;
}
break;
case SND_MIXER_READ_GROUP_CHANGE:
if( que_g(gid)== 0 ) return;
break;
case SND_MIXER_READ_GROUP_ADD:
if( obj ) {
obj->dyn_e=3;
return;
}
o1=NULL;
obj_ins_new_g(&mixer->obj,&o1,gid);
mixer->o_nums++;
o1->dyn_e=3;
break;
default:
}
printf("cb_gp cmd %s gid '%s',%d\n",cmd_name[cmd],gid->name,gid->index);
}
static int que_g(snd_mixer_gid_t *gid ) {
g_q_cell_t *p;
if( g_q.q == NULL ) {
g_q.q=(g_q_cell_t *)malloc(sizeof(g_q_cell_t));
if( g_q.q == NULL ) {
fprintf(stderr,nomem_msg);
return -1;
}
p=g_q.q;
p->gid=*gid;
p->next=NULL;
g_q.q_n=1;
return 0;
}
p=g_q.q;
while( p->next != NULL ) {
if( strcmp(p->gid.name,gid->name) == 0 && p->gid.index == gid->index )
return 0;
p=p->next;
}
if( strcmp(p->gid.name,gid->name) == 0 && p->gid.index == gid->index )
return 0;
p->next=(g_q_cell_t *)malloc(sizeof(g_q_cell_t));
if( p->next==NULL ) {
fprintf(stderr,nomem_msg);
return -1;
}
p=p->next;
p->gid=*gid;
p->next=NULL;
g_q.q_n++;
return 0;
}
void tc_init( void ) {
cb_mix.rebuild=*cb_rb;
cb_mix.element=*element_callback;
cb_mix.group=*cb_gp;
}
gint time_callback(gpointer data) {
GtkRequisition rq;
int i,j,k,err;
e_q_cell_t *eq;
g_q_cell_t *gq;
k=0;
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];
e_q.q=NULL;
e_q.q_n=0;
g_q.q=NULL;
g_q.q_n=0;
err=snd_mixer_read(cards[i].mixer[j].handle,&cb_mix);
//if( err ) printf("count %d\n",err);
if( g_q.q_n ) k+=chk_group( &cards[i].mixer[j] );
for( eq=e_q.q ; eq != NULL ; eq=eq->next )
printf("que eid '%s',%d,%d\n",eq->eid.name,eq->eid.index,eq->eid.type);
/*
for( gq=g_q.q ; gq != NULL ; gq=gq->next )
printf("que gid '%s',%d\n",gq->gid.name,gq->gid.index);
*/
}
}
if( k ) {
gtk_container_remove(GTK_CONTAINER(main_vbox),mixer_container);
disp_mixer();
}
return 1;
}
static int chk_group( s_mixer_t *mixer ) {
s_obj_t *obj;
s_group_t *group;
s_element_t *e;
g_q_cell_t *gq,*gq2;
snd_mixer_group_t m_g;
int i,j,k,l,err,rt=0;
gq=g_q.q;
while( gq ) {
for( obj=mixer->obj ; obj != NULL ; obj=obj->next ) {
if( obj->g ) {
if( strcmp( obj->g->g.gid.name , gq->gid.name ) == 0 &&
obj->g->g.gid.index == gq->gid.index ) break;
}
}
if( obj ) {
group=obj->g;
bzero(&m_g,sizeof(snd_mixer_group_t));
m_g.gid=gq->gid;
if( (err=snd_mixer_group_read(mixer->handle,&m_g))<0 ) {
fprintf(stderr,_("Mixer group '%s',%d err 1: %s\n"),
m_g.gid.name,m_g.gid.index,snd_strerror(err));
goto __next;
}
m_g.pelements = (snd_mixer_eid_t *)malloc(m_g.elements_over*
sizeof(snd_mixer_eid_t));
if( m_g.pelements == NULL ) {
fprintf(stderr,nomem_msg);
goto __next;
}
m_g.elements_size=m_g.elements_over;
m_g.elements=m_g.elements_over=0;
if( (err=snd_mixer_group_read(mixer->handle,&m_g))<0 ) {
fprintf(stderr,_("Mixer group '%s',%d err 2: %s\n"),
m_g.gid.name,m_g.gid.index,snd_strerror(err));
free(m_g.pelements);
goto __next;
}
j=0;
if( group->g.elements == 0 ) {
j=1;
} else if( group->g.elements != m_g.elements ) {
j=1;
} else {
k=0;
for( i=0 ; i<m_g.elements ; i++ ) {
for( l=k ; l<m_g.elements ; l++ ) {
if( strcmp(m_g.pelements[i].name,
group->g.pelements[l].name)==0 &&
m_g.pelements[i].index ==
group->g.pelements[l].index ) {
if( l=k ) k++;
break;
}
}
if( l==m_g.elements ) {
j=1;
break;
}
}
}
if( j ) {
for( i=0 ; i<group->g.elements ; i++ ) {
element_free(&group->e[i]);
}
if( group->g.pelements ) free(group->g.pelements);
if( group->e ) free(group->e);
group->g=m_g;
group->e=(s_element_t *)g_malloc0(group->g.elements*
sizeof(s_element_t));
if( group->e == NULL ) {
fprintf(stderr,nomem_msg);
goto __next;
}
for( i=0 ; i<group->g.elements ; i++ ) {
if( chk_eid(mixer->obj,&m_g.pelements[i]) ) {
/*
printf("%d: build '%s',%d,%d\n",i,
m_g.pelements[i].name,m_g.pelements[i].index,
m_g.pelements[i].type);
*/
s_element_build(mixer->handle,&group->e[i],NULL,
group->g.pelements[i],mixer->c_dev,
mixer->m_dev);
} else {
group->g.pelements[i].type=0;
group->e[i].e.eid=group->g.pelements[i];
group->e[i].info.eid=group->g.pelements[i];
}
}
} else {
free(m_g.pelements);
}
if( obj->enable ) rt=1;
} else {
fprintf(stderr,_("not added gid before change.\n"));
}
__next:
gq2 = gq->next;
free(gq);
gq=gq2;
}
return rt;
}
static void element_free(s_element_t *e) {
if( e->w ) g_free(e->w);
if( e->adj ) g_free(e->adj);
if( e->mux ) free(e->mux);
snd_mixer_element_free(&e->e);
snd_mixer_element_info_free(&e->info);
}
static gboolean chk_eid(s_obj_t *obj,snd_mixer_eid_t *eid ) {
e_q_cell_t *eq,*ep;
s_element_t *e;
int i;
if( !is_etype(eid->type) ) return FALSE;
for( eq=e_q.q; eq != NULL ; eq=eq->next ) {
if( strcmp(eq->eid.name,eid->name) == 0 &&
eq->eid.index == eid->index && eq->eid.type == eq->eid.type ) {
if( eq == e_q.q ) {
e_q.q=e_q.q->next;
} else {
for(ep=e_q.q;ep->next !=eq ; ep=ep->next );
ep->next=eq->next;
}
free(eq);
return TRUE;
}
}
for( ; obj != NULL ; obj=obj->next ) {
if(obj->g) {
for( i=0 ; obj->g->g.elements ; i++ ) {
e=&obj->g->e[i];
if( strcmp( e->e.eid.name,eid->name ) == 0 &&
e->e.eid.index == eid->index &&
e->e.eid.type == eid->type ) return FALSE;
}
}
if(obj->e) {
e=&obj->e->e;
if( strcmp( e->e.eid.name,eid->name ) == 0 &&
e->e.eid.index == eid->index &&
e->e.eid.type == eid->type ) return FALSE;
}
}
return TRUE;
}
void s_e_chk( s_element_t *e ) {
int i,j;
switch( e->e.eid.type ) {
case SND_MIXER_ETYPE_VOLUME1:
for( i=0 ; i<e->e.data.volume1.voices; i++ ) {
if( (e->info.data.volume1.prange[i].max-
e->info.data.volume1.prange[i].min) == 1 ) {
gtk_toggle_button_set_active(
GTK_TOGGLE_BUTTON(e->w[i]),
e->e.data.volume1.pvoices[i]);
} else {
e->adj[i]->value=(gfloat)
-e->e.data.volume1.pvoices[i];
gtk_signal_emit_by_name(GTK_OBJECT(e->adj[i]),"value_changed");
}
}
break;
case SND_MIXER_ETYPE_SWITCH1:
for( i=0 ; i<e->e.data.switch1.sw; i++) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(e->w[i]),
snd_mixer_get_bit(e->e.data.switch1.psw,i)
);
}
break;
case SND_MIXER_ETYPE_SWITCH2:
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(e->w[0]),
e->e.data.switch2.sw);
break;
case SND_MIXER_ETYPE_ACCU3:
for( i=0 ; i<e->e.data.accu3.voices ; i++ ) {
e->adj[i]->value=(gfloat)
-e->e.data.volume1.pvoices[i];
gtk_signal_emit_by_name(GTK_OBJECT(e->adj[i]),"value_changed");
}
break;
case SND_MIXER_ETYPE_MUX1:
for( i=0 ; i<e->e.data.mux1.output ; i++ ) {
for( j=0; j<e->mux_n ; j++ ) {
if( strcmp(e->mux[j].name,e->e.data.mux1.poutput[i].name)==0 &&
e->mux[j].index == e->e.data.mux1.poutput[i].index &&
e->mux[j].type == e->e.data.mux1.poutput[i].type ) break;
}
if( j < e->mux_n )
gtk_option_menu_set_history(GTK_OPTION_MENU(e->w[i]),j);
}
break;
case SND_MIXER_ETYPE_MUX2:
for( i=0; i<e->mux_n ; i++ ) {
if( strcmp(e->mux[i].name,e->e.data.mux2.output.name)==0 &&
e->mux[i].index == e->e.data.mux2.output.index &&
e->mux[i].type == e->e.data.mux2.output.type )
break;
}
if( i < e->mux_n )
gtk_option_menu_set_history(GTK_OPTION_MENU(e->w[0]),i);
break;
case SND_MIXER_ETYPE_3D_EFFECT1:
if( e->info.data.teffect1.effect & SND_MIXER_EFF1_SW ) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(e->w[0]),
e->e.data.teffect1.sw);
}
if( e->info.data.teffect1.effect & SND_MIXER_EFF1_MONO_SW ) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(e->w[1]),
e->e.data.teffect1.sw);
}
if( e->info.data.teffect1.effect & SND_MIXER_EFF1_WIDE ) {
e->adj[0]->value=(gfloat)e->e.data.teffect1.wide;
gtk_signal_emit_by_name(GTK_OBJECT(e->adj[0]),"value_changed");
}
if( e->info.data.teffect1.effect & SND_MIXER_EFF1_VOLUME ) {
e->adj[1]->value=(gfloat)e->e.data.teffect1.volume;
gtk_signal_emit_by_name(GTK_OBJECT(e->adj[1]),"value_changed");
}
if( e->info.data.teffect1.effect & SND_MIXER_EFF1_CENTER ) {
e->adj[2]->value=(gfloat)e->e.data.teffect1.center;
gtk_signal_emit_by_name(GTK_OBJECT(e->adj[2]),
"value_changed");
}
if( e->info.data.teffect1.effect & SND_MIXER_EFF1_SPACE ) {
e->adj[3]->value=(gfloat)e->e.data.teffect1.space;
gtk_signal_emit_by_name(GTK_OBJECT(e->adj[3]),"value_changed");
}
if( e->info.data.teffect1.effect & SND_MIXER_EFF1_DEPTH ) {
e->adj[4]->value=(gfloat)e->e.data.teffect1.depth;
gtk_signal_emit_by_name(GTK_OBJECT(e->adj[4]),"value_changed");
}
if( e->info.data.teffect1.effect & SND_MIXER_EFF1_DELAY ) {
e->adj[5]->value=(gfloat)e->e.data.teffect1.delay;
gtk_signal_emit_by_name(GTK_OBJECT(e->adj[5]),"value_changed");
}
if( e->info.data.teffect1.effect & SND_MIXER_EFF1_FEEDBACK ) {
e->adj[6]->value=(gfloat)e->e.data.teffect1.feedback;
gtk_signal_emit_by_name(GTK_OBJECT(e->adj[6]),"value_changed");
}
if( e->info.data.teffect1.effect & SND_MIXER_EFF1_DEPTH_REAR ) {
e->adj[7]->value=(gfloat)e->e.data.teffect1.depth_rear;
gtk_signal_emit_by_name(GTK_OBJECT(e->adj[7]),"value_changed");
}
break;
case SND_MIXER_ETYPE_TONE_CONTROL1:
if( e->info.data.tc1.tc & SND_MIXER_TC1_SW ) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(e->w[0]),
e->e.data.tc1.sw);
}
if( e->info.data.tc1.tc & SND_MIXER_TC1_BASS ) {
e->adj[0]->value=-(gfloat)e->e.data.tc1.bass;
gtk_signal_emit_by_name(GTK_OBJECT(e->adj[0]),"value_changed");
}
if( e->info.data.tc1.tc & SND_MIXER_TC1_TREBLE ) {
e->adj[1]->value=-(gfloat)e->e.data.tc1.treble;
gtk_signal_emit_by_name(GTK_OBJECT(e->adj[1]),"value_changed");
}
break;
case SND_MIXER_ETYPE_PAN_CONTROL1:
printf("catch pan ");
for( i=0 ; i<e->e.data.pc1.pan ; i++ ) {
printf(" %d",e->e.data.pc1.ppan[i]);
e->adj[i]->value=(gfloat)e->e.data.pc1.ppan[i];
gtk_signal_emit_by_name(GTK_OBJECT(e->adj[i]),"value_changed");
}
printf("\n");
break;
}
}
static void rmw_elem(s_element_t *e) {
int i,j;
switch( e->e.eid.type ) {
case SND_MIXER_ETYPE_VOLUME1:
for( i=0 ; i<e->e.data.volume1.voices; i++ ) {
if( (e->info.data.volume1.prange[i].max-
e->info.data.volume1.prange[i].min) == 1 ) {
gtk_widget_destroy( e->w[i] );
} else {
//gtk_widget_destroy(e->adj[i]);
gtk_widget_destroy(e->w[i]);
}
}
break;
case SND_MIXER_ETYPE_SWITCH1:
for( i=0 ; i<e->e.data.switch1.sw; i++) {
gtk_widget_destroy(e->w[i]);
}
break;
case SND_MIXER_ETYPE_SWITCH2:
gtk_widget_destroy(e->w[0]);
break;
case SND_MIXER_ETYPE_ACCU3:
for( i=0 ; i<e->e.data.accu3.voices ; i++ ) {
gtk_widget_destroy(e->w[i]);
}
break;
case SND_MIXER_ETYPE_MUX1:
for( i=0 ; i<e->e.data.mux1.output ; i++ ) {
gtk_widget_destroy(e->w[i]);
}
break;
case SND_MIXER_ETYPE_MUX2:
gtk_widget_destroy(e->w[0]);
break;
case SND_MIXER_ETYPE_3D_EFFECT1:
if( e->info.data.teffect1.effect & SND_MIXER_EFF1_SW ) {
gtk_widget_destroy(e->w[0]);
}
if( e->info.data.teffect1.effect & SND_MIXER_EFF1_MONO_SW ) {
gtk_widget_destroy(e->w[1]);
}
if( e->info.data.teffect1.effect & SND_MIXER_EFF1_WIDE ) {
gtk_widget_destroy(e->w[2]);
}
if( e->info.data.teffect1.effect & SND_MIXER_EFF1_VOLUME ) {
gtk_widget_destroy(e->w[3]);
}
if( e->info.data.teffect1.effect & SND_MIXER_EFF1_CENTER ) {
gtk_widget_destroy(e->w[4]);
}
if( e->info.data.teffect1.effect & SND_MIXER_EFF1_SPACE ) {
gtk_widget_destroy(e->w[5]);
}
if( e->info.data.teffect1.effect & SND_MIXER_EFF1_DEPTH ) {
gtk_widget_destroy(e->w[6]);
}
if( e->info.data.teffect1.effect & SND_MIXER_EFF1_DELAY ) {
gtk_widget_destroy(e->w[7]);
}
if( e->info.data.teffect1.effect & SND_MIXER_EFF1_FEEDBACK ) {
gtk_widget_destroy(e->w[8]);
}
if( e->info.data.teffect1.effect & SND_MIXER_EFF1_DEPTH_REAR ) {
gtk_widget_destroy(e->w[9]);
}
break;
case SND_MIXER_ETYPE_TONE_CONTROL1:
if( e->info.data.tc1.tc & SND_MIXER_TC1_SW ) {
gtk_widget_destroy(e->w[0]);
}
if( e->info.data.tc1.tc & SND_MIXER_TC1_BASS ) {
gtk_widget_destroy(e->w[1]);
}
if( e->info.data.tc1.tc & SND_MIXER_TC1_TREBLE ) {
gtk_widget_destroy(e->w[2]);
}
break;
case SND_MIXER_ETYPE_PAN_CONTROL1:
j=0;
for( i=0 ; i<e->e.data.pc1.pan ; i++ ) {
gtk_widget_destroy(e->w[j++]);
gtk_widget_destroy(e->w[j++]);
gtk_widget_destroy(e->w[j++]);
gtk_widget_destroy(e->w[j++]);
}
break;
}
}

View file

@ -1,850 +0,0 @@
#include "gamix.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <errno.h>
s_conf conf;
static GtkWidget *c_win;
typedef struct {
gboolean m_en;
gboolean *obj_en;
GSList *gp;
gboolean p_e;
gboolean p_f;
GtkCList *cl;
int *ord_l;
int o_nums;
} c_mixer;
typedef struct {
c_mixer *m;
} c_card;
static c_card *ccard;
static gboolean scrolled;
static gboolean ok_pushed;
static gboolean Esaved;
static gboolean Tosave;
static gboolean sv_wsized;
static void close_win(GtkWidget *,gpointer);
static void cancel_b(GtkWidget *,gpointer);
static void ok_b(GtkWidget *,gpointer);
static void tb_callback(GtkToggleButton *,gint *);
static void sl1_callback(GtkWidget *,gint,gint,GdkEventButton *,gpointer);
static void sl2_callback(GtkWidget *,gint,gint,GdkEventButton *,gpointer);
static int sel_num(GtkCList *,gint);
static void cread_err(gchar *,int );
static void chk_cfile(void);
static void swap_obj(s_obj_t **,s_obj_t *,s_obj_t *);
static s_obj_t *obj_new( s_obj_t **,s_obj_t *);
static void close_win(GtkWidget *w,gpointer data) {
gtk_grab_remove(c_win);
gtk_main_quit();
}
static void cancel_b(GtkWidget *w,gpointer data) {
gtk_widget_destroy(c_win);
}
static void ok_b(GtkWidget *w,gpointer data) {
int i,j,k;
GSList *n;
GtkWidget *b;
gchar *s;
Tosave=(gboolean)data;
ok_pushed=TRUE;
for( i=0 ; i<card_num ; i++ ) {
for( j=0 ; j<cards[i].info.mixerdevs; j++ ) {
for( k=0 ; (n = g_slist_nth(ccard[i].m[j].gp,k)) != NULL ; k++ ) {
b=(GtkWidget *)n->data;
if( GTK_TOGGLE_BUTTON(b)->active ) break;
}
switch(k) {
case 2:
ccard[i].m[j].p_e=FALSE;
ccard[i].m[j].p_f=FALSE;
break;
case 1:
ccard[i].m[j].p_e=TRUE;
ccard[i].m[j].p_f=FALSE;
break;
case 0:
ccard[i].m[j].p_e=TRUE;
ccard[i].m[j].p_f=TRUE;
break;
}
for( k=0 ; k<ccard[i].m[j].o_nums ; k++ ) {
gtk_clist_get_text(ccard[i].m[j].cl,k,0,&s);
ccard[i].m[j].ord_l[k]=atoi(s)-1;
}
}
}
gtk_widget_destroy(c_win);
}
gint conf_win( void ) {
int i,j,k,l,m,sf;
gint changed,*o_l;
GtkWidget *b;
GtkWidget *vbox,*box,*frame,*hbox,*hhbox;
GtkWidget *clist;
GtkWidget *nb,*n_label;
GtkStyle *style;
unsigned char gname[40];
GSList *gp;
//s_group_t *group;
//s_eelements_t *ee;
s_obj_t *obj,*obj_b,*obj2,*obj2_b;
gchar *cl_data[3],cl_num[6];
GtkRequisition rq;
ok_pushed=FALSE;
c_win=gtk_window_new(GTK_WINDOW_DIALOG);
gtk_signal_connect(GTK_OBJECT(c_win),"destroy",GTK_SIGNAL_FUNC(close_win),
NULL);
//gtk_widget_show(c_win);
style=gtk_widget_get_style(c_win);
vbox=gtk_vbox_new(FALSE,10);
gtk_container_add(GTK_CONTAINER(c_win),vbox);
/* options */
nb=gtk_notebook_new();
gtk_notebook_set_tab_pos(GTK_NOTEBOOK(nb),GTK_POS_TOP);
gtk_box_pack_start(GTK_BOX(vbox),nb,FALSE,FALSE,0);
/* OPT */
frame=gtk_frame_new(NULL);
gtk_frame_set_shadow_type(GTK_FRAME(frame),GTK_SHADOW_IN);
gtk_container_set_border_width(GTK_CONTAINER(frame),20);
box=gtk_vbox_new(FALSE,10);
gtk_container_set_border_width(GTK_CONTAINER(box),10);
gtk_container_add(GTK_CONTAINER(frame),box);
hbox=gtk_hbox_new(FALSE,4);
gtk_box_pack_start(GTK_BOX(box),hbox,FALSE,FALSE,0);
scrolled=conf.scroll;
b=gtk_toggle_button_new();
gtk_widget_set_usize(b,10,10);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(b),conf.scroll);
gtk_box_pack_start(GTK_BOX(hbox),b,FALSE,FALSE,0);
gtk_signal_connect(GTK_OBJECT(b),"toggled",GTK_SIGNAL_FUNC(tb_callback),
(gpointer)&scrolled);
gtk_widget_show(b);
n_label=gtk_label_new(_("Scroll window enable"));
gtk_box_pack_start(GTK_BOX(hbox),n_label,FALSE,FALSE,0);
gtk_widget_show(n_label);
gtk_widget_show(hbox);
hbox=gtk_hbox_new(FALSE,4);
gtk_box_pack_start(GTK_BOX(box),hbox,FALSE,FALSE,0);
Esaved=conf.Esave;
b=gtk_toggle_button_new();
gtk_widget_set_usize(b,10,10);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(b),conf.Esave);
gtk_box_pack_start(GTK_BOX(hbox),b,FALSE,FALSE,0);
gtk_signal_connect(GTK_OBJECT(b),"toggled",GTK_SIGNAL_FUNC(tb_callback),
(gpointer)&Esaved);
gtk_widget_show(b);
n_label=gtk_label_new(_("Config save when exit"));
gtk_box_pack_start(GTK_BOX(hbox),n_label,FALSE,FALSE,0);
gtk_widget_show(n_label);
gtk_widget_show(hbox);
hbox=gtk_hbox_new(FALSE,4);
gtk_box_pack_start(GTK_BOX(box),hbox,FALSE,FALSE,0);
sv_wsized=conf.sv_wsize;
b=gtk_toggle_button_new();
gtk_widget_set_usize(b,10,10);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(b),conf.sv_wsize);
gtk_box_pack_start(GTK_BOX(hbox),b,FALSE,FALSE,0);
gtk_signal_connect(GTK_OBJECT(b),"toggled",GTK_SIGNAL_FUNC(tb_callback),
(gpointer)&sv_wsized);
gtk_widget_show(b);
n_label=gtk_label_new(_("Save window size"));
gtk_box_pack_start(GTK_BOX(hbox),n_label,FALSE,FALSE,0);
gtk_widget_show(n_label);
gtk_widget_show(hbox);
n_label=gtk_label_new("OPT");
gtk_widget_show(box);
gtk_widget_show(frame);
gtk_notebook_append_page(GTK_NOTEBOOK(nb),frame,n_label);
/* Mixer */
ccard=(c_card *)g_malloc(card_num*sizeof(c_card));
if( ccard == NULL ) {
fprintf(stderr,nomem_msg);
return -1;
}
for( i=0 ; i<card_num ; i++ ) {
ccard[i].m=(c_mixer *)g_malloc(cards[i].info.mixerdevs*sizeof(c_mixer));
if( ccard[i].m == NULL ) {
fprintf(stderr,nomem_msg);
return -1;
}
for( j=0 ; j<cards[i].info.mixerdevs; j++ ) {
n_label=gtk_label_new(cards[i].mixer[j].info.name);
frame=gtk_frame_new(NULL);
gtk_frame_set_shadow_type(GTK_FRAME(frame),GTK_SHADOW_IN);
gtk_container_set_border_width(GTK_CONTAINER(frame),20);
gtk_notebook_append_page(GTK_NOTEBOOK(nb),frame,n_label);
box=gtk_vbox_new(FALSE,2);
gtk_container_set_border_width(GTK_CONTAINER(box),10);
gtk_container_add(GTK_CONTAINER(frame),box);
hbox=gtk_hbox_new(FALSE,4);
gtk_box_pack_start(GTK_BOX(box),hbox,FALSE,FALSE,0);
ccard[i].m[j].m_en=cards[i].mixer[j].enable;
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].m_en);
gtk_signal_connect(GTK_OBJECT(b),"toggled",
GTK_SIGNAL_FUNC(tb_callback),
(gpointer)&ccard[i].m[j].m_en);
gtk_widget_show(b);
n_label=gtk_label_new(cards[i].mixer[j].info.name);
gtk_box_pack_start(GTK_BOX(hbox),n_label,FALSE,FALSE,0);
gtk_widget_show(n_label);
gtk_widget_show(hbox);
if( cards[i].mixer[j].p_e ) {
if( cards[i].mixer[j].p_f ) k=2; else k=1;
} else k=0;
hbox=gtk_hbox_new(FALSE,4);
gtk_box_pack_start(GTK_BOX(box),hbox,FALSE,FALSE,0);
n_label=gtk_label_new(_("Spacing: "));
gtk_box_pack_start(GTK_BOX(hbox),n_label,FALSE,FALSE,0);
gtk_widget_show(n_label);
b=gtk_radio_button_new_with_label(NULL,_("NONE"));
gtk_box_pack_start(GTK_BOX(hbox),b,FALSE,FALSE,0);
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"));
gtk_box_pack_start(GTK_BOX(hbox),b,FALSE,FALSE,0);
gtk_widget_show(b);
if( k==1 ) 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,_("expand"));
gtk_box_pack_start(GTK_BOX(hbox),b,FALSE,FALSE,0);
gtk_widget_show(b);
if( k==2 ) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(b),
TRUE);
ccard[i].m[j].gp=gtk_radio_button_group(GTK_RADIO_BUTTON(b));
gtk_widget_show(hbox);
clist=gtk_clist_new(3);
gtk_clist_freeze(GTK_CLIST(clist));
gtk_clist_set_selection_mode(GTK_CLIST(clist),
GTK_SELECTION_MULTIPLE);
gtk_clist_set_column_width(GTK_CLIST(clist),0,20);
gtk_clist_set_column_width(GTK_CLIST(clist),1,6);
gtk_clist_set_column_width(GTK_CLIST(clist),2,18);
gtk_clist_set_column_justification(GTK_CLIST(clist),
0,GTK_JUSTIFY_RIGHT);
gtk_clist_set_column_justification(GTK_CLIST(clist),
3,GTK_JUSTIFY_LEFT);
hhbox=gtk_scrolled_window_new(NULL,NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(hhbox),
GTK_POLICY_NEVER,
GTK_POLICY_AUTOMATIC);
gtk_widget_show(hhbox);
ccard[i].m[j].o_nums=cards[i].mixer[j].o_nums;
ccard[i].m[j].obj_en=(gboolean *)g_malloc(ccard[i].m[j].o_nums
* sizeof(gboolean));
ccard[i].m[j].ord_l=(gint *)g_malloc(ccard[i].m[j].o_nums
* sizeof(gint));
if( ccard[i].m[j].obj_en == NULL || ccard[i].m[j].ord_l == NULL ) {
fprintf(stderr,nomem_msg);
g_free(ccard);
return -1;
}
cl_data[0]=" ";
cl_data[1]=" ";
cl_data[2]=" ";
obj=cards[i].mixer[j].obj;
for( k=0 ; k<ccard[i].m[j].o_nums ; k++ ) {
sprintf(cl_num,"%d",k+1);
if( obj->g ) {
if( obj->g->g.gid.index > 0 ) {
sprintf(gname,"%s %d",
obj->g->g.gid.name,
obj->g->g.gid.index);
} else {
strcpy(gname,obj->g->g.gid.name);
}
}
if( obj->e ) {
if( obj->e->e.e.eid.index > 0 ) {
sprintf(gname,"%s %d",
obj->e->e.e.eid.name,
obj->e->e.e.eid.index);
} else {
strcpy(gname,obj->e->e.e.eid.name);
}
}
cl_data[0]=cl_num;
if( obj->dyn_e ) {
cl_data[1]="D";
} else {
cl_data[1]=" ";
}
cl_data[2]=gname;
gtk_clist_append(GTK_CLIST(clist),cl_data);
ccard[i].m[j].obj_en[k]=obj->enable;
if( obj->enable ) {
gtk_clist_select_row(GTK_CLIST(clist),k,0);
} else {
gtk_clist_unselect_row(GTK_CLIST(clist),k,0);
}
obj=obj->next;
}
ccard[i].m[j].cl=GTK_CLIST(clist);
gtk_clist_set_reorderable(GTK_CLIST(clist),TRUE);
gtk_signal_connect(GTK_OBJECT(clist),"select_row",
GTK_SIGNAL_FUNC(sl1_callback),
(gpointer)&ccard[i].m[j]);
gtk_signal_connect(GTK_OBJECT(clist),"unselect_row",
GTK_SIGNAL_FUNC(sl2_callback),
(gpointer)&ccard[i].m[j]);
gtk_widget_show(clist);
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(hhbox),
clist);
gtk_container_set_border_width(GTK_CONTAINER(hhbox),8);
gtk_widget_size_request(hhbox,&rq);
gtk_widget_set_usize(hhbox,rq.width,rq.height*2);
gtk_box_pack_start(GTK_BOX(box),hhbox,FALSE,FALSE,0);
gtk_widget_show(hhbox);
gtk_widget_show(box);
gtk_widget_show(frame);
gtk_clist_thaw(GTK_CLIST(clist));
}
}
gtk_widget_show(nb);
/* buttons */
box=gtk_hbutton_box_new();
gtk_button_box_set_layout(GTK_BUTTON_BOX(box),GTK_BUTTONBOX_END);
gtk_button_box_set_spacing(GTK_BUTTON_BOX(box),5);
gtk_box_pack_end(GTK_BOX(vbox),box,FALSE,FALSE,0);
b=gtk_button_new_with_label(_("OK"));
gtk_box_pack_start(GTK_BOX(box),b,TRUE,TRUE,0);
gtk_signal_connect(GTK_OBJECT(b),"clicked",GTK_SIGNAL_FUNC(ok_b),
(gpointer)FALSE);
GTK_WIDGET_SET_FLAGS(b,GTK_CAN_DEFAULT);
gtk_widget_show(b);
gtk_widget_grab_default(b);
Tosave=FALSE;
b=gtk_button_new_with_label(_("SAVE"));
gtk_box_pack_start(GTK_BOX(box),b,TRUE,TRUE,0);
gtk_signal_connect(GTK_OBJECT(b),"clicked",GTK_SIGNAL_FUNC(ok_b),
(gpointer)TRUE);
GTK_WIDGET_SET_FLAGS(b,GTK_CAN_DEFAULT);
gtk_widget_show(b);
b=gtk_button_new_with_label(_("CANCEL"));
gtk_box_pack_start(GTK_BOX(box),b,TRUE,TRUE,0);
gtk_signal_connect(GTK_OBJECT(b),"clicked",GTK_SIGNAL_FUNC(cancel_b),NULL);
GTK_WIDGET_SET_FLAGS(b,GTK_CAN_DEFAULT);
gtk_widget_show(b);
gtk_widget_show(box);
gtk_widget_show(vbox);
gtk_widget_show(c_win);
gtk_grab_add(c_win);
gtk_main();
changed=FALSE;
if( ok_pushed ) {
if ( conf.scroll != scrolled ) changed=TRUE;
conf.scroll=scrolled;
conf.Esave = Esaved;
conf.sv_wsize=sv_wsized;
}
for( i=0 ; i<card_num ; i++ ) {
for( j=0 ; j<cards[i].info.mixerdevs ; j++ ) {
if( ok_pushed ) {
if( !changed ) {
if( cards[i].mixer[j].enable != ccard[i].m[j].m_en )
changed = TRUE;
}
cards[i].mixer[j].enable=ccard[i].m[j].m_en;
cards[i].mixer[j].enabled=FALSE;
if( !changed ) {
if( cards[i].mixer[j].p_e != ccard[i].m[j].p_e ||
cards[i].mixer[j].p_f != ccard[i].m[j].p_f )
changed=TRUE;
}
cards[i].mixer[j].p_e=ccard[i].m[j].p_e;
cards[i].mixer[j].p_f=ccard[i].m[j].p_f;
k=0;
sf=0;
for( obj=cards[i].mixer[j].obj ; obj != NULL ;
obj=obj->next ) {
if( !changed ) {
if( ccard[i].m[j].ord_l[k] != k ) changed=TRUE;
if( obj->enable != ccard[i].m[j].obj_en[ccard[i].m[j].ord_l[k]] ) {
changed = TRUE;
}
}
if( ccard[i].m[j].ord_l[k] != k ) sf=1;
obj->enable=ccard[i].m[j].obj_en[k];
obj->enabled=FALSE;
k++;
}
if( sf ) {
o_l=(gint *)g_malloc(sizeof(gint)*ccard[i].m[j].o_nums);
if( o_l != NULL ) {
for( k=0 ; k<ccard[i].m[j].o_nums ; k++ ) o_l[k]=k;
obj_b=NULL;
obj=cards[i].mixer[j].obj;
for( k=0 ; k<ccard[i].m[j].o_nums ; k++ ) {
if( ccard[i].m[j].ord_l[k] != o_l[k] ) {
obj2=obj;
for( l=k ; ccard[i].m[j].ord_l[k]!=o_l[l] ; l++ ) {
obj2_b=obj2;
obj2=obj2->next;
}
for( m=l ; m>k ; m-- ) o_l[m]=o_l[m-1];
o_l[m]=k;
if( obj_b == NULL ) {
cards[i].mixer[j].obj=obj2;
} else {
obj_b->next=obj2;
}
obj2_b->next=obj2->next;
obj2->next=obj;
obj=obj2;
}
obj_b=obj;
obj=obj->next;
}
g_free(o_l);
}
}
/*
for( obj=cards[i].mixer[j].obj ; obj != NULL ; obj=obj->next) {
if( obj->g ) {
printf("G %s %d\n",obj->g->g.gid.name,obj->g->g.gid.index);
}
if( obj->e ) {
printf("E '$s',%d,%d\n",obj->e->e.e.eid.name,
obj->e->e.e.eid.index,obj->e->e.e.eid.type);
}
}
*/
}
g_free(ccard[i].m[j].obj_en);
g_free(ccard[i].m[j].ord_l);
}
g_free(ccard[i].m);
}
g_free(ccard);
if( Tosave ) {
conf_write();
conf.F_save=FALSE;
}
return changed;
}
static void tb_callback(GtkToggleButton *b,gint *c) {
*c=b->active;
}
static void sl1_callback(GtkWidget *w,gint row,gint col,
GdkEventButton *ev,gpointer data) {
int i;
c_mixer *m=(c_mixer *)data;
i=sel_num(GTK_CLIST(w),row);
m->obj_en[i]=TRUE;
}
static void sl2_callback(GtkWidget *w,gint row,gint col,
GdkEventButton *ev,gpointer data) {
int i;
c_mixer *m=(c_mixer *)data;
i=sel_num(GTK_CLIST(w),row);
m->obj_en[i]=FALSE;
}
static int sel_num(GtkCList *cl,gint row) {
int rt;
gchar *s;
gtk_clist_get_text(cl,row,0,&s);
rt=atoi(s)-1;
return rt;
}
void conf_read( void ) {
int i,j,k,err,ln;
FILE *fp;
gchar rbuf[256],*s;
s_mixer_t *m=NULL;
snd_mixer_gid_t gid;
snd_mixer_eid_t eid;
s_group_t *group;
s_eelements_t *ee;
s_obj_t *obj,*obj_n;
fp=fopen(conf.fna,"rt");
if( fp == NULL ) {
conf.F_save=TRUE;
return;
}
ln=1;
err=0;
while( !feof(fp) && err>-5 ) {
fgets(rbuf,255,fp);
rbuf[255]=0;
s=rbuf+2;
err=0;
switch( rbuf[0] ) {
case 'S':
conf.scroll=atoi(s)?TRUE:FALSE;
break;
case 'C':
i=atoi(s);
if( i<0 || i>2 ) {
err=-1;
} else conf.wmode=i;
break;
case 'Y':
conf.sv_wsize=atoi(s)?TRUE:FALSE;
break;
case 'W':
sscanf(s,"%d,%d\n",&conf.width,&conf.height);
break;
case 'A':
conf.Esave=atoi(s)?TRUE:FALSE;
break;
case 'M':
sscanf(s,"%d,%d=%d\n",&i,&j,&k);
if( i<0 || i>=card_num ) {
cread_err(_("Invalied card No."),ln);
err=-10;
break;
}
if( j<0 || j>=cards[i].info.mixerdevs ) {
cread_err(_("Invalied mixer device No."),ln);
err=-10;
}
m=&cards[i].mixer[j];
m->enable=k?TRUE:FALSE;
obj_n=m->obj;
break;
case 'X':
if( m == NULL ) {
cread_err(_("No mixer selected"),ln);
err=-1;
}
switch(atoi(s)) {
case 0:
m->p_e=FALSE;
m->p_f=FALSE;
break;
case 1:
m->p_e=TRUE;
m->p_f=FALSE;
break;
case 2:
m->p_e=TRUE;
m->p_f=TRUE;
break;
default:
cread_err(_("Invalied value for X"),ln);
err=-1;
break;
}
break;
case 'G':
if( m == NULL ) {
cread_err(_("No mixer selected"),ln);
err=-1;
}
s++;
for( i=0 ; *s!='\'' && *s>0 ; i++ ) gid.name[i]=*(s++);
gid.name[i]=0;
if( *s == 0 ) {
cread_err(_("Invalied argument"),ln);
err=-1;
break;
}
s+=2;
sscanf(s,"%d=%d\n",&gid.index,&i);
for( obj=m->obj ; obj != NULL ; obj=obj->next ) {
if( obj->g ) {
group=obj->g;
if( strcmp(gid.name,group->g.gid.name) == 0 &&
gid.index == group->g.gid.index ) {
obj->enable=i&1?TRUE:FALSE;
obj->dyn_e=i&2?3:0;
break;
}
}
}
if( obj ) {
if( obj != obj_n ) swap_obj(&m->obj,obj_n,obj);
obj_n=obj->next;
} else {
if( i&2 ) {
if( obj_ins_new_g(&m->obj,&obj_n,&gid) == 0 ) {
obj_n->enable=i&1?TRUE:FALSE;
obj_n->dyn_e=i&2?2:0;
obj_n=obj_n->next;
m->o_nums++;
} else {
err=-1;
}
} else {
cread_err(_("There is no such mixer group"),ln);
err=-1;
}
}
break;
case 'E':
if( m == NULL ) {
cread_err(_("No mixer selected"),ln);
err=-1;
}
s++;
for( i=0 ; *s!='\'' && *s>0 ; i++ ) eid.name[i]=*(s++);
eid.name[i]=0;
if( *s == 0 ) {
cread_err(_("Invalied argument"),ln);
err=-1;
break;
}
s+=2;
sscanf(s,"%d,%d=%d\n",&eid.index,&eid.type,&i);
for( obj=m->obj ; obj != NULL ; obj=obj->next ) {
if( obj->e ) {
ee=obj->e;
if( strcmp(eid.name,ee->e.e.eid.name) == 0 &&
eid.index == ee->e.e.eid.index &&
eid.type == ee->e.e.eid.type ) {
obj->enable=i&1?TRUE:FALSE;
obj->dyn_e=i&2?TRUE:FALSE;
break;
}
}
}
if( obj ) {
if( obj != obj_n ) swap_obj(&m->obj,obj_n,obj);
obj_n=obj->next;
} else {
if( i&2 ) {
} else {
cread_err(_("There is no such mixer element"),ln);
err=-1;
}
}
break;
}
if( err<0 ) conf.F_save=TRUE;
ln++;
}
fclose(fp);
}
static void cread_err(gchar *s,int n ) {
fprintf(stderr,_("config %d:%s\n"),n,s);
}
static void swap_obj( s_obj_t **obj,s_obj_t *o1,s_obj_t *o2 ) {
s_obj_t *p,*q;
if( o1 == NULL ) return;
q=o1;
while( q->next != o2 ) q=q->next;
q->next=o2->next;
if( *obj == o1 ) {
*obj=o2;
o2->next=o1;
} else {
p=*obj;
while( p->next != o1 ) p=p->next;
p->next=o2;
o2->next=o1;
}
}
void conf_write(void) {
int i,j,k;
FILE *fp;
s_mixer_t *m;
s_group_t *g;
s_eelements_t *ee;
s_obj_t *obj;
fp=fopen(conf.fna,"wt");
if( fp == NULL ) {
chk_cfile();
fp=fopen(conf.fna,"wt");
}
if( fp == NULL ) {
fprintf(stderr,_("gamix: config file not saved.\n"));
return;
}
fprintf(fp,"# OPT\n");
fprintf(fp,"S %d\n",conf.scroll);
fprintf(fp,"C %d\n",conf.wmode);
fprintf(fp,"A %d\n",conf.Esave);
gdk_window_get_size(window->window,&i,&j);
fprintf(fp,"Y %d\n",conf.sv_wsize);
if( conf.sv_wsize ) fprintf(fp,"W %d,%d\n",i,j);
for( i=0 ; i<card_num ; i++ ) {
for( j=0 ; j<cards[i].info.mixerdevs ; j++ ) {
m=&cards[i].mixer[j];
fprintf(fp,"# Card: %s\n# Mixer: %s\n",cards[i].info.name,
m->info.name);
fprintf(fp,"M %d,%d=%d\n",i,j,m->enable);
if( m->p_e ) {
if( m->p_f ) k=2; else k=1;
} else k=0;
fprintf(fp,"X %d\n",k);
for( obj=m->obj ; obj != NULL ; obj=obj->next ) {
if( obj->g ) {
g=obj->g;
fprintf(fp,"G '%s',%d=%d\n",g->g.gid.name,g->g.gid.index,
(obj->enable?1:0)|(obj->dyn_e?2:0));
}
if( obj->e ) {
ee=obj->e;
fprintf(fp,"E '%s',%d,%d=%d\n",
ee->e.e.eid.name,ee->e.e.eid.index,ee->e.e.eid.type,
obj->enable);
}
}
}
}
fclose(fp);
}
static void chk_cfile( void ) {
int i,j,k,err;
gchar *name;
k=strlen(g_get_home_dir());
name=g_strdup(conf.fna);
i=1;
j=strlen(name)-1;
err=-1;
while( i>0 ) {
if( err<0 ) {
while( name[j] != '/' ) j--;
name[j]=0;
if( j <= k ) {
fprintf(stderr,"Can not make dir ~/.gamix\n");
g_free(name);
return;
}
} else {
while( name[j] != 0 ) j++;
name[j]='/';
}
err=mkdir(name,S_IRUSR|S_IWUSR|S_IXUSR|
S_IRGRP|S_IXGRP| S_IROTH|S_IXOTH);
if( err<0 ) {
if( errno == ENOENT ) {
i++;
} else {
fprintf(stderr,"Can not make dir %s\n",name);
g_free(name);
return;
}
} else {
i--;
}
}
}
static s_obj_t *obj_new( s_obj_t **objs,s_obj_t *o ) {
s_obj_t *p,*q;
q=(s_obj_t *)g_malloc0(sizeof(s_obj_t));
if( q == NULL ) {
fprintf(stderr,nomem_msg);
return NULL;
}
if( *objs == o ) {
q->next=*objs;
*objs=q;
} else {
p=*objs;
while( p->next != o ) p=p->next;
q->next=p->next;
p->next=q;
}
return q;
}
gint obj_ins_new_g( s_obj_t **objs,s_obj_t **o1,snd_mixer_gid_t *gid ) {
s_obj_t *p;
s_group_t *g;
p=obj_new(objs,*o1);
if( p == NULL ) return -1;
g=(s_group_t *)g_malloc0(sizeof(s_group_t));
if( g == NULL ) {
fprintf(stderr,nomem_msg);
return -1;
}
g->g.gid=*gid;
p->g=g;
*o1=p;
return 0;
}
gint obj_ins_new_e( s_obj_t **objs,s_obj_t **o1,snd_mixer_eid_t *eid ) {
s_obj_t *p;
s_eelements_t *e;
p=obj_new(objs,*o1);
if( p == NULL ) return -1;
e=(s_eelements_t *)g_malloc0(sizeof(s_eelements_t));
if( e == NULL ) {
fprintf(stderr,nomem_msg);
return -1;
}
e->e.e.eid=*eid;
p->e=e;
*o1=p;
return 0;
}

View file

@ -1,121 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <glib.h>
#include <sys/asoundlib.h>
#ifdef ENABLE_NLS
# include <libintl.h>
# undef _
# undef N_
# define _(String) dgettext(PACKAGE,String)
# ifdef gettext_noop
# define N_(String) gettext_noop(String)
# else
# define N_(String) (String)
# endif
#else
# define textdomain(String) (String)
# define gettext(String) (String)
# define dgettext(Domain,Message) (Message)
# define dcgettext(Domain,Message,Type) (Message)
# define bindtextdomain(Domain,Directory) (Domain)
# define _(String) (String)
# define N_(String) (String)
#endif
#define preid(eid) printf("'%s',%d,%d\n",(eid).name,(eid).index,(eid).type)
typedef struct {
snd_mixer_element_t e;
snd_mixer_element_info_t info;
GtkWidget **w;
GtkAdjustment **adj;
gint card,mdev;
gint *chain_en;
gint *chain;
gint mux_n;
snd_mixer_eid_t *mux;
} s_element_t;
typedef struct s_eelements {
s_element_t e;
} s_eelements_t;
typedef struct s_group {
snd_mixer_group_t g;
s_element_t *e;
} s_group_t;
typedef struct s_obj s_obj_t;
struct s_obj {
s_group_t *g;
s_eelements_t *e;
GtkWidget *v_frame;
gint enable;
gint enabled;
gint chain;
gint chain_en;
gint dyn_e;
GtkWidget *cwb;
s_obj_t *next;
};
typedef struct {
snd_mixer_t *handle;
snd_mixer_info_t info;
int c_dev,m_dev;
gint o_nums;
s_obj_t *obj;
GtkWidget *w;
gboolean enable;
gboolean enabled;
gboolean p_e;
gboolean p_f;
} s_mixer_t;
typedef struct {
snd_ctl_hw_info_t info;
s_mixer_t *mixer;
} s_card_t;
typedef struct {
gint wmode;
gboolean scroll;
gchar *fna;
gboolean F_save;
gboolean Esave;
gboolean sv_wsize;
gint width;
gint height;
} s_conf;
extern GtkWidget *window;
extern int card_num,mdev_num;
extern gint card,mdev;
extern s_card_t *cards;
extern s_conf conf;
extern unsigned char *nomem_msg;
/* probe.c */
gint probe_mixer( void );
gboolean is_etype( int );
int s_element_build(snd_mixer_t *,s_element_t *,snd_mixer_elements_t *,
snd_mixer_eid_t ,int , int);
/* mkmixer.c */
GtkWidget *make_mixer( gint , gint );
/* catch.c */
void tc_init(void);
gint time_callback(gpointer);
/* conf_w.c */
gint conf_win( void );
void conf_read( void );
void conf_write( void );
gint obj_ins_new_g( s_obj_t **,s_obj_t **,snd_mixer_gid_t *);
gint obj_ins_new_e( s_obj_t **,s_obj_t **,snd_mixer_eid_t *);

View file

@ -1,293 +0,0 @@
#include "gamix.h"
GtkWidget *window;
GtkWidget *main_vbox;
GtkWidget *mixer_container;
GtkWidget *exit_item;
unsigned char *nomem_msg = N_("No enough memory.\n");
int main(int , char **);
int disp_mixer( void );
void disp_toolbar(void);
static void exit_gtk(GtkWidget *,gpointer);
static void sel_mctype(GtkWidget *,gpointer);
static void conf_callback(GtkWidget *,gpointer);
static void exit_gtk(GtkWidget *w,gpointer data) {
gtk_main_quit();
}
int main( int argc , char **argv ) {
int h,i;
gchar *dirname,*filename,*cname=NULL;
i=probe_mixer();
if( i < 0 ) {
fprintf(stderr,_("Can not make mixer.\n"));
return -1;
}
#ifdef ENABLE_NLS
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
#endif
gtk_set_locale();
gtk_init( &argc,&argv);
h=0;
while( (i=getopt(argc,argv,"c:h")) != -1 ) {
switch(i) {
case 'c':
cname = g_strdup(optarg);
break;
case 'h':
h=1;
break;
case ':':
fprintf(stderr,"hoe?\n");
break;
case '?':
//fprintf(stderr,_("unknown option: %c\n"),optopt);
h=1;
break;
}
}
if( h ) {
printf("gamix ");
if( strcmp(PACKAGE,"alsa-utils") == 0 ) {
printf(" alsa utils version.");
} else if( strcmp(PACKAGE,"gamix") == 0 ) {
printf("%s original version.",VERSION);
}
putchar('\n');
printf(_("Usage: gamix [OPTION]\n"));
printf(_(" -h print this help.\n"));
printf(_(" -c [file] change config file.\n"));
exit(0);
}
dirname = g_strconcat(g_get_home_dir(),"/.gamix",NULL);
filename = g_strconcat(dirname, "/gtkrc", NULL);
gtk_rc_init();
gtk_rc_parse(filename);
g_free(filename);
conf.scroll=TRUE;
conf.wmode=1;
conf.F_save=FALSE;
conf.Esave=FALSE;
if( cname ) {
if( cname[0] == '/' ) {
conf.fna = g_strdup(cname);
} else {
conf.fna = g_strconcat(dirname,"/",cname,NULL);
}
} else {
conf.fna = g_strconcat(dirname,"/Config",NULL);
}
conf.sv_wsize=TRUE;
conf.width=0;
conf.height=0;
g_free(dirname);
conf_read();
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_signal_connect(GTK_OBJECT(window),"destroy",
GTK_SIGNAL_FUNC(gtk_main_quit),NULL);
main_vbox=gtk_vbox_new(FALSE,0);
gtk_container_add(GTK_CONTAINER(window),main_vbox);
disp_toolbar();
tc_init();
gtk_timeout_add(100,(GtkFunction)time_callback,NULL);
gtk_widget_show(main_vbox);
gtk_widget_show(window);
if( disp_mixer()<0 ) return 0;
gtk_main();
if( conf.F_save || conf.Esave ) {
conf_write();
}
g_free(conf.fna);
return 0;
}
void disp_toolbar(void) {
GtkWidget *menu,*sub_menu,*sub_item;
GtkWidget *frame;
frame=gtk_frame_new(NULL);
gtk_frame_set_shadow_type(GTK_FRAME(frame),GTK_SHADOW_OUT);
gtk_box_pack_start(GTK_BOX(main_vbox),frame,FALSE,FALSE,0);
gtk_widget_show(frame);
menu=gtk_menu_bar_new();
gtk_container_add(GTK_CONTAINER(frame),menu);
gtk_widget_show(menu);
/* Prg menu */
sub_menu=gtk_menu_new();
sub_item=gtk_menu_item_new_with_label(_("config"));
exit_item=sub_item;
gtk_menu_append(GTK_MENU(sub_menu),sub_item);
gtk_signal_connect(GTK_OBJECT(sub_item),"activate",
GTK_SIGNAL_FUNC(conf_callback),NULL);
gtk_widget_show(sub_item);
sub_item=gtk_menu_item_new_with_label(_("exit"));
exit_item=sub_item;
gtk_menu_append(GTK_MENU(sub_menu),sub_item);
gtk_signal_connect(GTK_OBJECT(sub_item),"activate",
GTK_SIGNAL_FUNC(exit_gtk),NULL);
gtk_widget_show(sub_item);
sub_item=gtk_menu_item_new_with_label(_("Prog"));
gtk_widget_show(sub_item);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(sub_item),sub_menu);
gtk_menu_bar_append(GTK_MENU_BAR(menu),sub_item);
/* mixer container type menu*/
if( mdev_num > 1 ) {
sub_menu=gtk_menu_new();
sub_item=gtk_menu_item_new_with_label(_("Horizontal"));
gtk_menu_append(GTK_MENU(sub_menu),sub_item);
gtk_signal_connect(GTK_OBJECT(sub_item),"activate",
GTK_SIGNAL_FUNC(sel_mctype),0);
gtk_widget_show(sub_item);
sub_item=gtk_menu_item_new_with_label(_("Vertical"));
gtk_menu_append(GTK_MENU(sub_menu),sub_item);
gtk_signal_connect(GTK_OBJECT(sub_item),"activate",
GTK_SIGNAL_FUNC(sel_mctype),(gpointer)1);
gtk_widget_show(sub_item);
sub_item=gtk_menu_item_new_with_label(_("note book"));
gtk_menu_append(GTK_MENU(sub_menu),sub_item);
gtk_signal_connect(GTK_OBJECT(sub_item),"activate",
GTK_SIGNAL_FUNC(sel_mctype),(gpointer)2);
gtk_widget_show(sub_item);
sub_item=gtk_menu_item_new_with_label(_("C-type"));
gtk_widget_show(sub_item);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(sub_item),sub_menu);
gtk_menu_bar_append(GTK_MENU_BAR(menu),sub_item);
}
}
static void sel_mctype(GtkWidget *w,gpointer n) {
int i;
i=(int)n;
if( i == conf.wmode ) return;
conf.wmode=i;
conf.width=0;
conf.height=0;
gtk_container_remove(GTK_CONTAINER(main_vbox),mixer_container);
if( (i=disp_mixer()) < 0 ) gtk_signal_emit_by_name(GTK_OBJECT(exit_item),
"activate");
}
int disp_mixer( void ) {
int i,j;
GtkWidget *n_label;
GtkWidget *frame;
GtkRequisition rq;
switch( conf.wmode ) {
case 0: /* H */
if( conf.scroll ) {
mixer_container=gtk_hbox_new(TRUE,0);
} else {
mixer_container=gtk_hbox_new(FALSE,0);
}
for( i=0 ; i<card_num ; i++ ) {
for( j=0 ; j<cards[i].info.mixerdevs ; j++ ) {
if( cards[i].mixer[j].enable ) {
cards[i].mixer[j].w=gtk_frame_new(NULL);
gtk_frame_set_shadow_type(GTK_FRAME(cards[i].mixer[j].w),
GTK_SHADOW_ETCHED_IN);
gtk_widget_show(cards[i].mixer[j].w);
frame=make_mixer(i,j);
if( !frame ) return -1;
gtk_container_add(GTK_CONTAINER(cards[i].mixer[j].w),
frame);
gtk_box_pack_start(GTK_BOX(mixer_container),
cards[i].mixer[j].w,TRUE,TRUE,2);
}
}
}
break;
case 1: /* V */
mixer_container=gtk_vbox_new(FALSE,0);
for( i=0 ; i<card_num ; i++ ) {
for( j=0 ; j<cards[i].info.mixerdevs ; j++ ) {
if( cards[i].mixer[j].enable ) {
cards[i].mixer[j].w=make_mixer(i,j);
if( !cards[i].mixer[j].w ) return -1;
gtk_box_pack_start(GTK_BOX(mixer_container),
cards[i].mixer[j].w,TRUE,TRUE,0);
}
}
}
break;
case 2: /* NoteBook */
mixer_container=gtk_notebook_new();
gtk_notebook_set_tab_pos(GTK_NOTEBOOK(mixer_container),GTK_POS_TOP);
for( i=0 ; i<card_num ; i++ )
for( j=0 ; j<cards[i].info.mixerdevs ; j++ ) {
if( cards[i].mixer[j].enable ) {
cards[i].mixer[j].w=make_mixer(i,j);
if( !cards[i].mixer[j].w ) return -1;
n_label=gtk_label_new(cards[i].mixer[j].info.name);
gtk_notebook_append_page(GTK_NOTEBOOK(mixer_container),
cards[i].mixer[j].w,n_label);
}
}
break;
}
gtk_widget_show(mixer_container);
gtk_widget_size_request(mixer_container,&rq);
//printf("MIXER X %3d Y %3d\n",rq.width,rq.height);
gtk_widget_size_request(window,&rq);
//printf("WINDOW X %3d Y %3d\n",rq.width,rq.height);
if( rq.width > 0 && rq.height > 0 )
gdk_window_resize(window->window,rq.width,rq.height);
gtk_box_pack_start(GTK_BOX(main_vbox),mixer_container,TRUE,TRUE,0);
/*
gtk_widget_size_request(window,&rq);
printf("WINDOW X %3d Y %3d\n",rq.width,rq.height);
*/
if( conf.width>0 && conf.height >0 && !conf.F_save ) {
gtk_widget_size_request(window,&rq);
gdk_window_resize(window->window,conf.width,conf.height);
//conf.width=0;
//conf.height=0;
}
return 0;
}
static void conf_callback(GtkWidget *w ,gpointer data) {
gint err;
GtkRequisition rq;
err=conf_win();
if( err < 0 ) gtk_signal_emit_by_name(GTK_OBJECT(exit_item),"activate");
if( err ) {
gtk_container_remove(GTK_CONTAINER(main_vbox),mixer_container);
if( disp_mixer() < 0 ) gtk_signal_emit_by_name(
GTK_OBJECT(exit_item),"activate");
gtk_widget_size_request(window,&rq);
gdk_window_resize(window->window,rq.width,rq.height);
}
}

View file

@ -1,942 +0,0 @@
#include "gamix.h"
static gchar *label_3d[]={
"wide","volume","center","space","depth","delay","feedback","depth rear"};
static gchar *label_tone[]={"B","T"};
static gchar *pc1_ptc1[]={"L","F","B"};
static gchar *pc1_ptc2[]={"R","R","U"};
static void close_callback(GtkWidget *,s_mixer_t *);
static void volume1_callback(GtkAdjustment *,s_element_t *);
static void volume1_sw_callback(GtkToggleButton *,s_element_t *);
static void switch1_callback(GtkToggleButton *,s_element_t *);
static void switch2_callback(GtkToggleButton *,s_element_t *);
static void chain_callback(GtkToggleButton *,s_obj_t *);
static void accu3_callback(GtkAdjustment *,s_element_t *);
static void mux1_callback(GtkItem *,s_element_t *);
static void mux2_callback(GtkItem *,s_element_t *);
static void sw_3d_callback(GtkToggleButton *,s_element_t *);
static void vol_3d_callback(GtkAdjustment *,s_element_t *);
static void sw_tone_callback(GtkToggleButton *,s_element_t *);
static void vol_tone_callback(GtkAdjustment *,s_element_t *);
static void pc1_callback(GtkAdjustment *,s_element_t *);
static void pc1_ss_callback(GtkWidget *,s_element_t *);
static gint mk_element(s_element_t *,GtkBox *);
static void close_callback(GtkWidget *w,s_mixer_t *mixer) {
int i;
s_obj_t *obj;
/*
for( i=0 ; i<mixer->groups.groups ; i++ ) {
g=&mixer->group[i];
g->enabled=FALSE;
}
for( i=0 ; i<mixer->ee_n ; i++ ) {
ee=&mixer->ee[i];
ee->enabled=FALSE;
}
for( g=mixer->group; g != NULL ; g=g->next ) g->enabled=FALSE;
for( ee=mixer->ee; ee != NULL ; ee=ee->next ) ee->enabled=FALSE;
*/
for( obj=mixer->obj ; obj != NULL ; obj=obj->next ) obj->enabled=FALSE;
snd_mixer_close(mixer->handle);
mixer->handle=NULL;
}
static void volume1_sw_callback(GtkToggleButton *b,s_element_t *e) {
int i,j,value,err;
for( i=0 ; i<e->e.data.volume1.voices; i++ ) {
if( b == GTK_TOGGLE_BUTTON(e->w[i]) ) break;
}
value=b->active?1:0;
if( e->e.data.volume1.pvoices[i] == value ) return;
if( e->e.data.volume1.voices > 1 && *e->chain ) {
for( j=0 ; j<e->e.data.volume1.voices; j++ ) {
e->e.data.volume1.pvoices[j]=value;
if( j!= i ) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(e->w[j]),b->active);
}
}
} else {
e->e.data.volume1.pvoices[i]=value;
}
err=snd_mixer_element_write(cards[e->card].mixer[e->mdev].handle,&e->e);
if( err < 0 ) {
fprintf(stderr,_("mixer element write error: %s\n"),snd_strerror(err));
}
}
static void volume1_callback(GtkAdjustment *adj,s_element_t *e) {
int i,j,value,err;
for( i=0 ; i<e->e.data.volume1.voices; i++ ) {
if( adj == e->adj[i] ) break;
}
value=-(int)adj->value;
if( e->e.data.volume1.pvoices[i] == value ) return;
if( e->e.data.volume1.voices > 1 && *e->chain ) {
for( j=0 ; j<e->e.data.volume1.voices; j++ ) {
e->e.data.volume1.pvoices[j]=value;
if( j!= i ) {
e->adj[j]->value=adj->value;
gtk_signal_emit_by_name(GTK_OBJECT(e->adj[j]),"value_changed");
}
}
} else {
e->e.data.volume1.pvoices[i]=value;
}
err=snd_mixer_element_write(cards[e->card].mixer[e->mdev].handle,&e->e);
if( err < 0 ) {
fprintf(stderr,_("mixer element write error: %s\n"),snd_strerror(err));
}
}
static void switch1_callback(GtkToggleButton *b,s_element_t *e ) {
int i,j;
for( i=0 ; i<e->e.data.switch1.sw; i++ ) {
if( b == (GtkToggleButton *)e->w[i] ) break;
}
if( (snd_mixer_get_bit(e->e.data.switch1.psw,i)?TRUE:FALSE) == b->active )
return;
if( e->e.data.switch1.sw > 1 && *e->chain ) {
for( j=0 ; j<e->e.data.switch1.sw; j++ ) {
snd_mixer_set_bit(e->e.data.switch1.psw,j,b->active);
if( j != i )
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(e->w[j]),b->active);
}
} else {
snd_mixer_set_bit(e->e.data.switch1.psw,i,b->active);
}
snd_mixer_element_write(cards[e->card].mixer[e->mdev].handle,&e->e);
}
static void switch2_callback(GtkToggleButton *b,s_element_t *e ) {
int err;
e->e.data.switch2.sw=b->active;
err=snd_mixer_element_write(cards[e->card].mixer[e->mdev].handle,&e->e);
}
static void chain_callback(GtkToggleButton *b,s_obj_t *obj ) {
obj->chain = b->active;
/*
printf("obj ");
if( obj->g ) printf("gid '%s',%d ",obj->g->g.gid.name,obj->g->g.gid.index);
if( obj->e ) printf("eid '%s',%d,%d ",obj->e->e.e.eid.name,
obj->e->e.e.eid.index,obj->e->e.e.eid.type);
printf(" %s\n",obj->chain?"TRUE":"FALSE");
*/
}
static void accu3_callback(GtkAdjustment *adj,s_element_t *e) {
int i,j,value,err;
for( i=0 ; i<e->e.data.accu3.voices; i++ ) {
if( adj == e->adj[i] ) break;
}
value=-(int)adj->value;
if( e->e.data.accu3.pvoices[i] == value ) return;
if( e->e.data.accu3.voices > 1 && *e->chain ) {
for( j=0 ; j<e->e.data.accu3.voices; j++ ) {
e->e.data.accu3.pvoices[j]=value;
if( j!= i ) {
e->adj[j]->value=adj->value;
gtk_signal_emit_by_name(GTK_OBJECT(e->adj[j]),"value_changed");
}
}
} else {
e->e.data.accu3.pvoices[i]=value;
}
err=snd_mixer_element_write(cards[e->card].mixer[e->mdev].handle,&e->e);
if( err < 0 ) {
fprintf(stderr,_("mixer element write error: %s\n"),snd_strerror(err));
}
}
static void mux1_callback(GtkItem *item,s_element_t *e ) {
int i,ch,no,err;
ch=(int)gtk_object_get_data(GTK_OBJECT(item),"ch");
no=(int)gtk_object_get_data(GTK_OBJECT(item),"no");
if( strcmp(e->mux[no].name,e->e.data.mux1.poutput[ch].name) == 0 &&
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 ) {
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(
GTK_OPTION_MENU(e->w[i]),no);
}
} else {
e->e.data.mux1.poutput[ch]=e->mux[no];
}
err=snd_mixer_element_write(cards[e->card].mixer[e->mdev].handle,&e->e);
if( err< 0 ) {
fprintf(stderr,_("mixer mux1 element write error: %s\n"),snd_strerror(err));
}
}
static void mux2_callback(GtkItem *item,s_element_t *e ) {
int no,err;
no=(int)gtk_object_get_data(GTK_OBJECT(item),"no");
if( strcmp(e->mux[no].name,e->e.data.mux2.output.name) == 0 &&
e->mux[no].index == e->e.data.mux2.output.index &&
e->mux[no].type == e->e.data.mux2.output.type ) return;
e->e.data.mux2.output=e->mux[no];
err=snd_mixer_element_write(cards[e->card].mixer[e->mdev].handle,&e->e);
if( err< 0 ) {
fprintf(stderr,_("mixer mux1 element write error: %s\n"),snd_strerror(err));
}
}
static void sw_3d_callback(GtkToggleButton *b,s_element_t *e ) {
int err;
if( b == (GtkToggleButton *)e->w[0] ) {
e->e.data.teffect1.sw = b->active;
} else {
e->e.data.teffect1.mono_sw = b->active;
}
err=snd_mixer_element_write(cards[e->card].mixer[e->mdev].handle,&e->e);
}
static void vol_3d_callback(GtkAdjustment *adj,s_element_t *e) {
int i,err,*v,value;
for( i=0 ; i<7 ; i++ ) {
if( adj == e->adj[i] ) break;
}
v=NULL;
switch( i ) {
case 0:
v=&e->e.data.teffect1.wide;
break;
case 1:
v=&e->e.data.teffect1.volume;
break;
case 2:
v=&e->e.data.teffect1.center;
break;
case 3:
v=&e->e.data.teffect1.space;
break;
case 4:
v=&e->e.data.teffect1.depth;
break;
case 5:
v=&e->e.data.teffect1.delay;
break;
case 6:
v=&e->e.data.teffect1.feedback;
break;
case 7:
v=&e->e.data.teffect1.depth_rear;
break;
}
value=(int)adj->value;
if( v ) {
if( value == *v ) return;
*v=value;
} else return;
err=snd_mixer_element_write(cards[e->card].mixer[e->mdev].handle,&e->e);
if( err<0 ) {
fprintf(stderr,_("3D effect write error: %s\n"),snd_strerror(err));
}
}
static void sw_tone_callback(GtkToggleButton *b,s_element_t *e ) {
int err;
e->e.data.tc1.sw = b->active;
e->e.data.tc1.tc=SND_MIXER_TC1_SW;
err=snd_mixer_element_write(cards[e->card].mixer[e->mdev].handle,&e->e);
}
static void vol_tone_callback(GtkAdjustment *adj,s_element_t *e) {
int i,err,*v,value;
for( i=0 ; i<2 ; i++ ) {
if( adj == e->adj[i] ) break;
}
v=NULL;
switch( i ) {
case 0:
v=&e->e.data.tc1.bass;
e->e.data.tc1.tc=SND_MIXER_TC1_BASS;
break;
case 1:
v=&e->e.data.tc1.treble;
e->e.data.tc1.tc=SND_MIXER_TC1_TREBLE;
break;
}
value=-(int)adj->value;
if( v ) {
if( value == *v ) return;
*v=value;
} else return;
err=snd_mixer_element_write(cards[e->card].mixer[e->mdev].handle,&e->e);
if( err<0 ) {
fprintf(stderr,_("Tone controll write error: %s\n"),snd_strerror(err));
}
}
static void pc1_callback(GtkAdjustment *adj,s_element_t *e) {
int i,err,value;
value=(int)adj->value;
for( i=0 ; i<e->e.data.pc1.pan; i++ ) {
if( adj == e->adj[i] ) break;
}
if( i==e->e.data.pc1.pan ) {
fprintf(stderr,"Pan err.\n");
return;
}
if( e->e.data.pc1.ppan[i]==value ) return;
e->e.data.pc1.ppan[i]=value;
err=snd_mixer_element_write(cards[e->card].mixer[e->mdev].handle,&e->e);
if( err<0 ) {
fprintf(stderr,_("PAN controll write error: %s\n"),snd_strerror(err));
}
}
static void pc1_ss_callback(GtkWidget *w,s_element_t *e) {
int i,j,k,err;
gfloat v=0;
j=1;
for( i=0 ; i<e->e.data.pc1.pan; i++ ) {
if( w == e->w[j] ) {
k=e->info.data.pc1.prange[i].min;
break;
}
j++;
if( w == e->w[j] ) {
k=(e->info.data.pc1.prange[i].min+e->info.data.pc1.prange[i].max)/2;
break;
}
j++;
if( w == e->w[j] ) {
k=e->info.data.pc1.prange[i].max;
break;
}
j+=2;
}
if( i<e->e.data.pc1.pan ) {
if( e->e.data.pc1.ppan[i] == k ) return;
e->adj[i]->value=(gfloat)k;
gtk_signal_emit_by_name(GTK_OBJECT(e->adj[i]),"value_changed");
}
}
GtkWidget *make_mixer( gint c_n , gint m_n ) {
int i,j,k,err;
GtkWidget *mv_box,*m_name;
GtkWidget *s_win;
GtkWidget *mh_box;
GtkWidget *frame;
GtkWidget *iv_box;
GtkWidget *ih_box;
GtkWidget *c_l;
char gname[128];
s_mixer_t *mixer;
s_group_t *group=NULL;
s_element_t *e;
s_eelements_t *ee;
s_obj_t *obj;
if( cards[c_n].mixer[m_n].handle ) {
snd_mixer_close(cards[c_n].mixer[m_n].handle);
}
if( (err=snd_mixer_open(&cards[c_n].mixer[m_n].handle,c_n,m_n)) < 0 ) {
return NULL;
}
mixer = &cards[c_n].mixer[m_n];
mv_box=gtk_vbox_new(FALSE,0);
gtk_widget_show(mv_box);
sprintf(gname,"%s:%s",cards[c_n].info.name,
cards[c_n].mixer[m_n].info.name);
m_name=gtk_label_new(gname);
gtk_box_pack_start(GTK_BOX(mv_box),m_name,FALSE,FALSE,0);
gtk_widget_show(m_name);
mh_box=gtk_hbox_new(FALSE,2);
if( conf.scroll ) {
s_win=gtk_scrolled_window_new(NULL,NULL);
gtk_box_pack_start(GTK_BOX(mv_box),s_win,TRUE,TRUE,0);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(s_win),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_NEVER);
gtk_widget_show(s_win);
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(s_win),
mh_box);
//gtk_container_add(GTK_CONTAINER(s_win),mh_box);
} else {
gtk_box_pack_start(GTK_BOX(mv_box),mh_box,TRUE,TRUE,4);
}
gtk_widget_show(mh_box);
for( obj=mixer->obj ; obj != NULL ; obj=obj->next ) {
if( obj->g ) {
group=obj->g;
k=0;
for( j=0 ; j<group->g.elements ; j++ ) {
if( group->e[j].e.eid.type ) k++;
}
if( k==0 && obj->dyn_e == 0) obj->enable=FALSE;
if( obj->enable && (obj->dyn_e == 0 || obj->dyn_e == 3) ) {
obj->v_frame=frame=gtk_frame_new(NULL);
gtk_frame_set_shadow_type(GTK_FRAME(frame),GTK_SHADOW_OUT);
gtk_box_pack_start(GTK_BOX(mh_box),frame,
mixer->p_e,mixer->p_f,0);
iv_box=gtk_vbox_new(FALSE,0);
gtk_container_add(GTK_CONTAINER(frame),iv_box);
obj->chain_en=FALSE;
for( j=0 ; j<group->g.elements ; j++ ) {
e=&group->e[j];
e->chain = &obj->chain;
e->chain_en = &obj->chain_en;
if( mk_element(e,GTK_BOX(iv_box))<0 ) return NULL;
}
if( group->g.gid.index > 0 ) {
sprintf(gname,"%s %d",group->g.gid.name,
group->g.gid.index);
} else {
sprintf(gname,"%s",group->g.gid.name);
}
ih_box=gtk_hbox_new(FALSE,2);
gtk_box_pack_start(GTK_BOX(iv_box),ih_box,FALSE,FALSE,0);
if( obj->chain_en ) {
obj->cwb=gtk_toggle_button_new();
gtk_box_pack_start(GTK_BOX(ih_box),obj->cwb,
FALSE,FALSE,4);
gtk_widget_set_usize(obj->cwb,10,10);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(obj->cwb)
,obj->chain);
gtk_widget_show(obj->cwb);
gtk_signal_connect(GTK_OBJECT(obj->cwb),"toggled",
GTK_SIGNAL_FUNC(chain_callback),
(gpointer)obj);
c_l=gtk_label_new(_("Lock"));
gtk_box_pack_start(GTK_BOX(ih_box),c_l,FALSE,FALSE,0);
gtk_widget_show(c_l);
gtk_widget_show(ih_box);
if( strlen(gname) > 10 ) {
j=0;
while( gname[j]!=' ' && gname[j]!=0 ) j++;
if( gname[j]!=0 ) {
gname[j+3]=0;
}
if( group->g.gid.index > 0 )
sprintf(gname,"%s %d",gname,group->g.gid.index);
}
} else {
c_l=gtk_label_new(" ");
gtk_box_pack_start(GTK_BOX(ih_box),c_l,FALSE,FALSE,0);
gtk_widget_show(c_l);
if( strlen(gname) > 5 ) {
j=0;
while( gname[j]!=' ' && gname[j]!=0 ) j++;
if( gname[j]!=0 ) {
gname[j+3]=0;
}
if( group->g.gid.index > 0 )
sprintf(gname,"%s %d",gname,group->g.gid.index);
}
}
gtk_frame_set_label(GTK_FRAME(frame),gname);
gtk_widget_show(ih_box);
gtk_widget_show(iv_box);
gtk_widget_show(frame);
obj->enabled=TRUE;
} else {
obj->enabled=FALSE;
}
}
if( obj->e ) {
if( obj->enable && (obj->dyn_e == 0 || obj->dyn_e == 3)) {
ee=obj->e;
e=&ee->e;
obj->v_frame=frame=gtk_frame_new(NULL);
gtk_frame_set_shadow_type(GTK_FRAME(frame),GTK_SHADOW_OUT);
gtk_box_pack_start(GTK_BOX(mh_box),frame,
mixer->p_e,mixer->p_f,0);
iv_box=gtk_vbox_new(FALSE,0);
gtk_container_add(GTK_CONTAINER(frame),iv_box);
obj->chain_en=FALSE;
e->chain=&obj->chain;
e->chain_en=&obj->chain_en;
if( mk_element(e,GTK_BOX(iv_box))<0 ) return NULL;
ih_box=gtk_hbox_new(FALSE,2);
gtk_box_pack_start(GTK_BOX(iv_box),ih_box,FALSE,FALSE,0);
if( e->e.eid.index > 0 ) {
sprintf(gname,"%s%d",e->e.eid.name,e->e.eid.index);
} else {
sprintf(gname,"%s",e->e.eid.name);
}
if( obj->chain_en ) {
obj->cwb=gtk_toggle_button_new();
gtk_box_pack_start(GTK_BOX(ih_box),obj->cwb,FALSE,FALSE,4);
gtk_widget_set_usize(obj->cwb,10,10);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(obj->cwb)
,obj->chain);
gtk_widget_show(obj->cwb);
gtk_signal_connect(GTK_OBJECT(obj->cwb),"toggled",
GTK_SIGNAL_FUNC(chain_callback),
(gpointer)obj);
c_l=gtk_label_new(_("Lock"));
gtk_box_pack_start(GTK_BOX(ih_box),c_l,FALSE,FALSE,0);
gtk_widget_show(c_l);
gtk_widget_show(ih_box);
if( strlen(gname) > 10 ) {
j=0;
while( gname[j]!=' ' && gname[j]!=0 ) j++;
if( gname[j]!=0 ) {
gname[j+3]=0;
}
}
} else {
c_l=gtk_label_new(" ");
gtk_box_pack_start(GTK_BOX(ih_box),c_l,FALSE,FALSE,0);
gtk_widget_show(c_l);
}
gtk_frame_set_label(GTK_FRAME(frame),gname);
gtk_widget_show(ih_box);
gtk_widget_show(iv_box);
gtk_widget_show(frame);
obj->enabled=TRUE;
} else {
obj->enabled=FALSE;
}
}
}
gtk_signal_connect(GTK_OBJECT(mv_box),"destroy",
GTK_SIGNAL_FUNC(close_callback),(gpointer)mixer);
mixer->enabled=TRUE;
return mv_box;
}
#define MIX_3D_VOL(NO,name,min_name,max_name,sname) \
if( e->info.data.teffect1.effect & sname ) { \
ih_box=gtk_hbox_new(FALSE,2); \
gtk_box_pack_start(iv_box,ih_box,FALSE,FALSE,0); \
c_l=gtk_label_new(label_3d[NO]); \
gtk_box_pack_start(GTK_BOX(ih_box),c_l,FALSE,FALSE,0); \
gtk_widget_show(c_l); \
gtk_widget_show(ih_box); \
e->adj[NO]=(GtkAdjustment *)gtk_adjustment_new( \
(gfloat)e->e.data.teffect1.name, \
(gfloat)e->info.data.teffect1.min_name-0.5, \
(gfloat)e->info.data.teffect1.max_name+1.0, \
1.0,1.0,1.0); \
gtk_signal_connect(GTK_OBJECT(e->adj[NO]), \
"value_changed",GTK_SIGNAL_FUNC(vol_3d_callback),(gpointer)e);\
e->w[NO+2]=gtk_hscale_new(GTK_ADJUSTMENT(e->adj[NO])); \
gtk_scale_set_draw_value(GTK_SCALE(e->w[NO+2]),FALSE); \
gtk_box_pack_start(GTK_BOX(iv_box), e->w[NO+2],FALSE,FALSE,4); \
gtk_widget_show(e->w[NO+2]); \
} else { ;\
e->w[NO+2]=NULL; \
e->adj[NO]=NULL; \
}
#define MIX_TONE_VOL(NO,name,min_name,max_name,sname) \
if( e->info.data.tc1.tc & sname ) { \
tv_box = gtk_vbox_new(FALSE,2); \
gtk_box_pack_start(GTK_BOX(ih_box),tv_box,TRUE,TRUE,0); \
c_l=gtk_label_new(label_tone[NO]); \
gtk_box_pack_start(GTK_BOX(tv_box),c_l,FALSE,FALSE,0); \
gtk_widget_show(c_l); \
e->adj[NO]=(GtkAdjustment *)gtk_adjustment_new( \
-(gfloat)e->e.data.tc1.name, \
-(gfloat)e->info.data.tc1.max_name-0.5, \
-(gfloat)e->info.data.tc1.min_name+0.5, \
1.0,4.0,1.0); \
gtk_signal_connect(GTK_OBJECT(e->adj[NO]), \
"value_changed",GTK_SIGNAL_FUNC(vol_tone_callback),(gpointer)e);\
e->w[NO+1]=gtk_vscale_new(GTK_ADJUSTMENT(e->adj[NO])); \
gtk_scale_set_draw_value(GTK_SCALE(e->w[NO+1]),FALSE); \
gtk_box_pack_start(GTK_BOX(tv_box), e->w[NO+1],FALSE,FALSE,4); \
gtk_widget_show(e->w[NO+1]); \
gtk_widget_show(tv_box); \
} else { ;\
e->w[NO+1]=NULL; \
e->adj[NO]=NULL; \
}
gint mk_element(s_element_t *e,GtkBox *iv_box) {
int i,j,k;
GtkWidget *ih_box,*tv_box;
GtkWidget *menu,*c_l,*item;
ih_box=gtk_hbox_new(TRUE,0);
switch( e->e.eid.type) {
case SND_MIXER_ETYPE_VOLUME1:
if( (e->info.data.volume1.prange[0].max-
e->info.data.volume1.prange[0].min) == 1 ) {
gtk_box_pack_start(iv_box,ih_box,FALSE,FALSE,0);
} else
gtk_box_pack_start(iv_box,ih_box,TRUE,TRUE,0);
if( e->e.data.volume1.voices > 1 ) {
*e->chain_en=TRUE;
*e->chain=TRUE;
}
if( e->w == NULL ) {
e->w = (GtkWidget **)g_malloc( e->e.data.volume1.voices *
sizeof(GtkWidget *));
}
if( e->w == NULL ) {
fprintf(stderr,nomem_msg);
return -1;
}
if( e->adj == NULL ) {
e->adj=(GtkAdjustment **)g_malloc(e->e.data.volume1.voices*
sizeof(GtkAdjustment *));
}
if( e->adj==NULL ) {
fprintf(stderr,nomem_msg);
return -1;
}
for( i=0 ; i<e->e.data.volume1.voices ; i++ ) {
if( (e->info.data.volume1.prange[i].max-
e->info.data.volume1.prange[i].min) == 1 ) {
e->adj[i]=NULL;
e->w[i]=gtk_toggle_button_new_with_label("V");
gtk_box_pack_start(GTK_BOX(ih_box),e->w[i],
FALSE,FALSE,0);
gtk_toggle_button_set_state(
GTK_TOGGLE_BUTTON(e->w[i]),
e->e.data.volume1.pvoices[i]);
gtk_signal_connect(GTK_OBJECT(e->w[i]),"toggled",
GTK_SIGNAL_FUNC(volume1_sw_callback),
(gpointer)e);
gtk_widget_show(e->w[i]);
} else {
e->adj[i]=(GtkAdjustment *)gtk_adjustment_new(
-(gfloat)e->e.data.volume1.pvoices[i],
-(gfloat)e->info.data.volume1.prange[i].max-0.5,
-(gfloat)e->info.data.volume1.prange[i].min+0.5,
1.0,4.0,1.0);
gtk_signal_connect(GTK_OBJECT(e->adj[i]),"value_changed",
GTK_SIGNAL_FUNC(volume1_callback),
(gpointer)e);
e->w[i]=gtk_vscale_new(GTK_ADJUSTMENT(e->adj[i]));
gtk_scale_set_draw_value(GTK_SCALE(e->w[i]),FALSE);
gtk_box_pack_start(GTK_BOX(ih_box),e->w[i],FALSE,FALSE,4);
gtk_widget_show(e->w[i]);
}
}
break;
case SND_MIXER_ETYPE_SWITCH1:
gtk_box_pack_start(iv_box,ih_box,FALSE,FALSE,4);
if( e->e.data.switch1.sw > 1 ) {
*e->chain_en=TRUE;
*e->chain=TRUE;
}
if( e->w == NULL ) {
e->w = (GtkWidget **)g_malloc( e->e.data.switch1.sw *
sizeof(GtkWidget *));
}
if( e->w == NULL ) {
fprintf(stderr,nomem_msg);
return -1;
}
for( i=0 ; i<e->e.data.switch1.sw ; i++ ) {
e->w[i]=gtk_toggle_button_new();
gtk_box_pack_start(GTK_BOX(ih_box),e->w[i],FALSE,FALSE,0);
gtk_widget_set_usize(e->w[i],10,10);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(e->w[i]),
snd_mixer_get_bit(e->e.data.switch1.psw,i)
);
gtk_signal_connect(GTK_OBJECT(e->w[i]),"toggled",
GTK_SIGNAL_FUNC(switch1_callback),(gpointer)e);
gtk_widget_show(e->w[i]);
}
break;
case SND_MIXER_ETYPE_SWITCH2:
gtk_box_pack_start(iv_box,ih_box,FALSE,FALSE,4);
if( e->w == NULL ) {
e->w = (GtkWidget **)g_malloc(sizeof(GtkWidget *));
}
if( e->w == NULL ) {
fprintf(stderr,nomem_msg);
return -1;
}
e->w[0]=gtk_toggle_button_new();
gtk_box_pack_start(GTK_BOX(ih_box),e->w[0],FALSE,FALSE,0);
gtk_widget_set_usize(e->w[0],10,10);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(e->w[0]),
e->e.data.switch2.sw);
gtk_signal_connect(GTK_OBJECT(e->w[0]),"toggled",
GTK_SIGNAL_FUNC(switch2_callback),
(gpointer)e);
gtk_widget_show(e->w[0]);
break;
case SND_MIXER_ETYPE_ACCU3:
gtk_box_pack_start(iv_box,ih_box,FALSE,FALSE,0);
if( e->e.data.accu3.voices > 1 ) {
*e->chain_en=TRUE;
*e->chain=TRUE;
}
if( e->w == NULL ) {
e->w = (GtkWidget **)g_malloc(e->e.data.accu3.voices *
sizeof(GtkWidget *));
}
if( e->w == NULL ) {
fprintf(stderr,nomem_msg);
return -1;
}
if( e->adj == NULL ) {
e->adj=(GtkAdjustment **)g_malloc(e->e.data.accu3.voices*
sizeof(GtkAdjustment *));
}
if( e->adj==NULL ) {
printf(nomem_msg);
return -1;
}
for( i=0 ; i<e->e.data.accu3.voices ; i++ ) {
e->adj[i]=(GtkAdjustment *)gtk_adjustment_new(
-(gfloat)e->e.data.accu3.pvoices[i],
-(gfloat)e->info.data.accu3.prange[i].max-0.5,
-(gfloat)e->info.data.accu3.prange[i].min+0.5,
1.0,1.0,1.0);
gtk_signal_connect(GTK_OBJECT(e->adj[i]),"value_changed",
GTK_SIGNAL_FUNC(accu3_callback),(gpointer)e);
e->w[i]=gtk_vscale_new(GTK_ADJUSTMENT(e->adj[i]));
gtk_scale_set_draw_value(GTK_SCALE(e->w[i]),FALSE);
gtk_box_pack_start(GTK_BOX(ih_box),e->w[i],FALSE,FALSE,4);
gtk_widget_show(e->w[i]);
}
break;
case SND_MIXER_ETYPE_MUX1:
if( e->e.data.mux1.output > 1 ) {
*e->chain_en=TRUE;
*e->chain=TRUE;
}
if( e->w == NULL ) {
e->w = (GtkWidget **)g_malloc(e->e.data.mux1.output *
sizeof(GtkWidget *));
}
if( e->w == NULL ) {
fprintf(stderr,nomem_msg);
return -1;
}
for( i=0 ; i<e->e.data.mux1.output ; i++ ) {
e->w[i]=gtk_option_menu_new();
menu=gtk_menu_new();
k=0;
for( j=0 ; j<e->mux_n; j++ ) {
if( strcmp(e->mux[j].name,e->e.data.mux1.poutput[i].name)==0 &&
e->mux[j].index == e->e.data.mux1.poutput[i].index &&
e->mux[j].type == e->e.data.mux1.poutput[i].type ) k=j;
item=gtk_menu_item_new_with_label(e->mux[j].name);
gtk_object_set_data(GTK_OBJECT(item),"ch",(gpointer)i);
gtk_object_set_data(GTK_OBJECT(item),"no",(gpointer)j);
gtk_signal_connect(GTK_OBJECT(item),"activate",
GTK_SIGNAL_FUNC(mux1_callback),(gpointer)e);
gtk_menu_append(GTK_MENU(menu),item);
gtk_widget_show(item);
}
gtk_option_menu_set_menu(GTK_OPTION_MENU(e->w[i]),menu);
gtk_box_pack_start(iv_box,e->w[i],FALSE,FALSE,4);
gtk_widget_show(e->w[i]);
gtk_option_menu_set_history(GTK_OPTION_MENU(e->w[i]),k);
}
break;
case SND_MIXER_ETYPE_MUX2:
if( e->w == NULL ) {
e->w = (GtkWidget **)g_malloc(sizeof(GtkWidget *));
}
if( e->w == NULL ) {
fprintf(stderr,nomem_msg);
return -1;
}
e->w[0]=gtk_option_menu_new();
menu=gtk_menu_new();
k=0;
for( j=0 ; j<e->mux_n; j++ ) {
if( strcmp(e->mux[j].name,e->e.data.mux2.output.name)==0 &&
e->mux[j].index == e->e.data.mux2.output.index &&
e->mux[j].type == e->e.data.mux2.output.type ) k=j;
item=gtk_menu_item_new_with_label(e->mux[j].name);
gtk_object_set_data(GTK_OBJECT(item),"no",(gpointer)j);
gtk_signal_connect(GTK_OBJECT(item),"activate",
GTK_SIGNAL_FUNC(mux2_callback),(gpointer)e);
gtk_menu_append(GTK_MENU(menu),item);
gtk_widget_show(item);
}
gtk_option_menu_set_menu(GTK_OPTION_MENU(e->w[0]),menu);
gtk_box_pack_start(iv_box,e->w[0],FALSE,FALSE,4);
gtk_widget_show(e->w[0]);
gtk_option_menu_set_history(GTK_OPTION_MENU(e->w[0]),k);
break;
case SND_MIXER_ETYPE_3D_EFFECT1:
if( e->w == NULL ) {
e->w = (GtkWidget **)g_malloc(10*sizeof(GtkWidget *));
}
if( e->w == NULL ) {
fprintf(stderr,nomem_msg);
return -1;
}
if( e->adj == NULL ) {
e->adj=(GtkAdjustment **)g_malloc(8*sizeof(GtkAdjustment *));
}
if( e->adj==NULL ) {
printf(nomem_msg);
return -1;
}
if( e->info.data.teffect1.effect & SND_MIXER_EFF1_SW ) {
ih_box=gtk_hbox_new(FALSE,2);
gtk_box_pack_start(iv_box,ih_box,FALSE,FALSE,0);
e->w[0]=gtk_toggle_button_new();
gtk_box_pack_start(GTK_BOX(ih_box),e->w[0],FALSE,FALSE,4);
gtk_widget_set_usize(e->w[0],10,10);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(e->w[0])
,e->e.data.teffect1.sw);
gtk_widget_show(e->w[0]);
gtk_signal_connect(GTK_OBJECT(e->w[0]),"toggled",
GTK_SIGNAL_FUNC(sw_3d_callback),(gpointer)e);
c_l=gtk_label_new(_("Enable"));
gtk_box_pack_start(GTK_BOX(ih_box),c_l,FALSE,FALSE,0);
gtk_widget_show(c_l);
gtk_widget_show(ih_box);
} else {
e->w[0]=NULL;
}
if( e->info.data.teffect1.effect & SND_MIXER_EFF1_MONO_SW ) {
ih_box=gtk_hbox_new(FALSE,2);
gtk_box_pack_start(iv_box,ih_box,FALSE,FALSE,0);
e->w[1]=gtk_toggle_button_new();
gtk_box_pack_start(GTK_BOX(ih_box),e->w[1],FALSE,FALSE,4);
gtk_widget_set_usize(e->w[1],10,10);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(e->w[1])
,e->e.data.teffect1.mono_sw);
gtk_widget_show(e->w[1]);
gtk_signal_connect(GTK_OBJECT(e->w[1]),"toggled",
GTK_SIGNAL_FUNC(sw_3d_callback),(gpointer)e);
c_l=gtk_label_new(_("MONO"));
gtk_box_pack_start(GTK_BOX(ih_box),c_l,FALSE,FALSE,0);
gtk_widget_show(c_l);
gtk_widget_show(ih_box);
} else {
e->w[1]=NULL;
}
MIX_3D_VOL(0,wide,min_wide,max_wide,SND_MIXER_EFF1_WIDE);
MIX_3D_VOL(1,volume,min_volume,max_volume,SND_MIXER_EFF1_VOLUME);
MIX_3D_VOL(2,center,min_center,max_center,SND_MIXER_EFF1_CENTER);
MIX_3D_VOL(3,space,min_space,max_space,SND_MIXER_EFF1_SPACE);
MIX_3D_VOL(4,depth,min_depth,max_depth,SND_MIXER_EFF1_DEPTH);
MIX_3D_VOL(5,delay,min_delay,max_delay,SND_MIXER_EFF1_DELAY);
MIX_3D_VOL(6,feedback,min_feedback,max_feedback,SND_MIXER_EFF1_FEEDBACK);
MIX_3D_VOL(7,depth_rear,min_depth_rear,max_depth_rear,SND_MIXER_EFF1_DEPTH_REAR);
break;
case SND_MIXER_ETYPE_TONE_CONTROL1:
if( e->w == NULL ) {
e->w = (GtkWidget **)g_malloc(3*sizeof(GtkWidget *));
}
if( e->w == NULL ) {
fprintf(stderr,nomem_msg);
return -1;
}
if( e->adj == NULL ) {
e->adj=(GtkAdjustment **)g_malloc(2*sizeof(GtkAdjustment *));
}
if( e->adj==NULL ) {
printf(nomem_msg);
return -1;
}
e->e.data.tc1.tc=e->info.data.tc1.tc;
snd_mixer_element_read(cards[e->card].mixer[e->mdev].handle,&e->e);
if( e->info.data.tc1.tc &
(SND_MIXER_TC1_BASS | SND_MIXER_TC1_TREBLE ) ) {
gtk_box_pack_start(iv_box,ih_box,TRUE,TRUE,0);
MIX_TONE_VOL(0,bass,min_bass,max_bass,SND_MIXER_TC1_BASS);
MIX_TONE_VOL(1,treble,min_treble,max_treble,SND_MIXER_TC1_TREBLE);
}
if( e->info.data.tc1.tc & SND_MIXER_TC1_SW ) {
if( e->info.data.tc1.tc &
(SND_MIXER_TC1_BASS | SND_MIXER_TC1_TREBLE ) )
ih_box=gtk_hbox_new(FALSE,2);
gtk_box_pack_start(iv_box,ih_box,FALSE,FALSE,0);
e->w[0]=gtk_toggle_button_new();
gtk_box_pack_start(GTK_BOX(ih_box),e->w[0],FALSE,FALSE,4);
gtk_widget_set_usize(e->w[0],10,10);
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(e->w[0])
,e->e.data.tc1.sw);
gtk_widget_show(e->w[0]);
gtk_signal_connect(GTK_OBJECT(e->w[0]),"toggled",
GTK_SIGNAL_FUNC(sw_tone_callback),(gpointer)e);
c_l=gtk_label_new(_("Enable"));
gtk_box_pack_start(GTK_BOX(ih_box),c_l,FALSE,FALSE,0);
gtk_widget_show(c_l);
gtk_widget_show(ih_box);
} else {
e->w[0]=NULL;
}
break;
case SND_MIXER_ETYPE_PAN_CONTROL1:
if( e->w == NULL ) {
e->w = (GtkWidget **)g_malloc(e->e.data.pc1.pan*4*
sizeof(GtkWidget *));
}
if( e->w == NULL ) {
fprintf(stderr,nomem_msg);
return -1;
}
if( e->adj == NULL ) {
e->adj=(GtkAdjustment **)g_malloc(e->e.data.pc1.pan*
sizeof(GtkAdjustment *));
}
if( e->adj==NULL ) {
fprintf(stderr,nomem_msg);
return -1;
}
for( i=0 ; i<e->e.data.pc1.pan ; i++ ) {
j=i*4;
e->adj[i]=(GtkAdjustment *)gtk_adjustment_new(
(gfloat)e->e.data.pc1.ppan[i],
(gfloat)e->info.data.pc1.prange[i].min-0.5,
(gfloat)e->info.data.pc1.prange[i].max+1.5,
1.0,4.0,1.0);
gtk_signal_connect(GTK_OBJECT(e->adj[i]),"value_changed",
GTK_SIGNAL_FUNC(pc1_callback),(gpointer)e);
e->w[j]=gtk_hscale_new(GTK_ADJUSTMENT(e->adj[i]));
gtk_scale_set_draw_value(GTK_SCALE(e->w[j]),FALSE);
gtk_box_pack_start(iv_box,e->w[j],FALSE,FALSE,4);
gtk_widget_show(e->w[j]);
gtk_box_pack_start(iv_box,ih_box,FALSE,FALSE,4);
j++;
e->w[j]=gtk_button_new_with_label(pc1_ptc1[e->info.data.pc1.prange[i].pan_type]);
gtk_signal_connect(GTK_OBJECT(e->w[j]),"clicked",
GTK_SIGNAL_FUNC(pc1_ss_callback),(gpointer)e);
gtk_box_pack_start(GTK_BOX(ih_box),e->w[j],FALSE,FALSE,2);
gtk_widget_show(e->w[j++]);
e->w[j]=gtk_button_new_with_label("C");
gtk_signal_connect(GTK_OBJECT(e->w[j]),"clicked",
GTK_SIGNAL_FUNC(pc1_ss_callback),(gpointer)e);
gtk_box_pack_start(GTK_BOX(ih_box),e->w[j],FALSE,FALSE,2);
gtk_widget_show(e->w[j++]);
e->w[j]=gtk_button_new_with_label(pc1_ptc2[e->info.data.pc1.prange[i].pan_type]);
gtk_signal_connect(GTK_OBJECT(e->w[j]),"clicked",
GTK_SIGNAL_FUNC(pc1_ss_callback),(gpointer)e);
gtk_box_pack_start(GTK_BOX(ih_box),e->w[j],FALSE,FALSE,2);
gtk_widget_show(e->w[j]);
}
break;
}
gtk_widget_show(ih_box);
return 0;
}

View file

@ -1,441 +0,0 @@
#include "gamix.h"
int card_num,mdev_num;
s_card_t *cards;
static int search_es(snd_mixer_eid_t *,snd_mixer_elements_t *);
static gint ab_chk( s_mixer_t *,snd_mixer_eid_t * );
/*
static int s_element_build(snd_mixer_t *,s_element_t *,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,m;
snd_ctl_t *p_handle;
snd_mixer_t *m_handle;
snd_mixer_groups_t groups;
snd_mixer_elements_t es;
s_mixer_t *mixer;
s_group_t *group;
s_eelements_t *ee;
s_obj_t *obj;
int *es_nums;
card_num=snd_cards();
cards=(s_card_t *)g_malloc(sizeof(s_card_t)*card_num);
if( cards == NULL ) {
fprintf(stderr,nomem_msg);
return -1;
}
mdev_num=0;
for( i = 0 ; i<card_num ; i++ ) {
if((err=snd_ctl_open(&p_handle,i))<0 ) {
fprintf(stderr,_("open failed: %s\n"),snd_strerror(err));
return -1;
}
err=snd_ctl_hw_info(p_handle, &cards[i].info);
if(err<0) {
fprintf(stderr,_("hw info failed: %s\n"),snd_strerror(err));
snd_ctl_close(p_handle);
return -1;
}
cards[i].mixer=(s_mixer_t *)g_malloc0(sizeof(s_mixer_t)*
cards[i].info.mixerdevs);
if( cards[i].mixer == NULL ) {
fprintf(stderr,nomem_msg);
snd_ctl_close(p_handle);
return -1;
}
mdev_num+=cards[i].info.mixerdevs;
for( j=0 ; j<cards[i].info.mixerdevs ; j++) {
mixer=&cards[i].mixer[j];
//mixer->handle=NULL;
//mixer->obj=NULL;
mixer->c_dev=i;
mixer->m_dev=j;
mixer->o_nums=0;
mixer->enable=TRUE;
mixer->enabled=FALSE;
mixer->p_e=TRUE;
mixer->p_f=TRUE;
if((err=snd_mixer_open(&m_handle,i,j))<0 ) {
fprintf(stderr,_("mixer %d/%d open error: %s\n"),i,j,
snd_strerror(err));
snd_ctl_close(p_handle);
return -1;
}
if((err=snd_ctl_mixer_info(p_handle,j,&mixer->info))<0) {
fprintf(stderr,_("Mixer info failed: %s\n"),snd_strerror(err));
snd_ctl_close(p_handle);
snd_mixer_close(m_handle);
return -1;
}
bzero(&groups,sizeof(snd_mixer_groups_t));
if((err=snd_mixer_groups(m_handle,&groups))<0 ) {
fprintf(stderr,_("Mixer %d/%d groups error: %s\n"),i,i,
snd_strerror(err));
snd_mixer_close(m_handle);
snd_ctl_close(p_handle);
return -1;
}
groups.pgroups = (snd_mixer_gid_t *)g_malloc(groups.groups_over
*sizeof(snd_mixer_eid_t));
if( groups.pgroups == NULL && groups.groups_over) {
fprintf(stderr,nomem_msg);
snd_ctl_close(p_handle);
snd_mixer_close(m_handle);
}
groups.groups_size = groups.groups_over;
groups.groups_over = groups.groups = 0;
if((err=snd_mixer_groups(m_handle,&groups))<0 ) {
fprintf(stderr,_("Mixer %d/%d groups (2) error: %s\n"),
i,j,snd_strerror(err));
snd_ctl_close(p_handle);
snd_mixer_close(m_handle);
return -1;
}
bzero(&es, sizeof(snd_mixer_elements_t));
if( (err=snd_mixer_elements(m_handle,&es))<0 ) {
fprintf(stderr,_("mixer elements read failed: %s"),
snd_strerror(err));
snd_ctl_close(p_handle);
snd_mixer_close(m_handle);
return -1;
}
es.pelements = (snd_mixer_eid_t *)g_malloc(
es.elements_over * sizeof(snd_mixer_eid_t));
if( es.pelements == NULL && es.elements_over) {
fprintf(stderr,nomem_msg);
snd_ctl_close(p_handle);
snd_mixer_close(m_handle);
return -1;
}
es.elements_size = es.elements_over;
es.elements_over = es.elements = 0;
if( (err=snd_mixer_elements(m_handle,&es))<0 ) {
fprintf(stderr,_("mixer elements read failed(2): %s"),
snd_strerror(err));
snd_ctl_close(p_handle);
snd_mixer_close(m_handle);
return -1;
}
es_nums = (int *)g_malloc(es.elements * sizeof(int));
if( es_nums == NULL && es.elements) {
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);
mixer->o_nums=groups.groups;
obj=NULL;
for( k=0 ; k<groups.groups ; k++ ) {
if( obj ) {
obj->next=(s_obj_t *)malloc(sizeof(s_obj_t));
if( obj->next == NULL ) {
fprintf(stderr,nomem_msg);
snd_ctl_close(p_handle);
snd_mixer_close(m_handle);
return -1;
}
obj=obj->next;
} else {
mixer->obj=(s_obj_t *)malloc(sizeof(s_obj_t));
if( mixer->obj == NULL ) {
fprintf(stderr,nomem_msg);
snd_ctl_close(p_handle);
snd_mixer_close(m_handle);
return -1;
}
obj=mixer->obj;
}
bzero(obj,sizeof(s_obj_t));
obj->enable=TRUE;
obj->enabled=FALSE;
obj->g=(s_group_t *)malloc(sizeof(s_group_t));
if( obj->g == NULL ) {
fprintf(stderr,nomem_msg);
snd_ctl_close(p_handle);
snd_mixer_close(m_handle);
return -1;
}
group=obj->g;
bzero(group,sizeof(s_group_t));
group->g.gid=groups.pgroups[k];
if((err=snd_mixer_group_read(m_handle,&group->g)) <0 ) {
fprintf(stderr,_("Mixer %d/%d group error: %s\n"),i,j,
snd_strerror(err));
snd_ctl_close(p_handle);
snd_mixer_close(m_handle);
return -1;
}
group->g.pelements = (snd_mixer_eid_t *)g_malloc(
group->g.elements_over*sizeof(snd_mixer_eid_t));
if( group->g.pelements == NULL && group->g.elements_over) {
snd_ctl_close(p_handle);
fprintf(stderr,nomem_msg);
snd_mixer_close(m_handle);
return -1;
}
group->g.elements_size = group->g.elements_over;
group->g.elements = group->g.elements_over = 0;
if((err=snd_mixer_group_read(m_handle,&group->g)) <0 ) {
fprintf(stderr,_("Mixer %d/%d group error (2): %s\n"),i,j,
snd_strerror(err));
snd_ctl_close(p_handle);
snd_mixer_close(m_handle);
return -1;
}
group->e=(s_element_t *)g_malloc(group->g.elements_size*
sizeof(s_element_t));
if( group->e == NULL && group->g.elements_size) {
fprintf(stderr,nomem_msg);
snd_ctl_close(p_handle);
snd_mixer_close(m_handle);
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 ) {
snd_ctl_close(p_handle);
snd_mixer_close(m_handle);
return -1;
}
}
}
for( k=0 ; k<es.elements ; k++ ) {
if( es_nums[k] > 1 ) {
//for( l=0 ; l<groups.groups ; l++ ) {
l=0;
for( obj=mixer->obj ; obj != NULL && l==0 ;
obj=obj->next ) {
group=obj->g;
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;
if( group->e[m].mux ) free(group->e[m].mux);
l=1;
break;
}
}
}
}
}
/*
delete null object?
*/
l=0;
for( k=0 ; k<es.elements ; k++ ) {
if( es_nums[k] == 0 || es_nums[k]>1 ) {
if( ab_chk(mixer,&es.pelements[k]) ) {
l++;
} else es_nums[k]=1;
}
}
mixer->o_nums+=l;
if( l>0 ) {
obj=mixer->obj;
if( obj ) while( obj->next ) obj=obj->next;
k=0;
while(l>0) {
l--;
while( es_nums[k]==1 ) k++;
if( obj ) {
obj->next=(s_obj_t *)g_malloc0(sizeof(s_obj_t));
if( obj == NULL ) {
fprintf(stderr,nomem_msg);
snd_ctl_close(p_handle);
snd_mixer_close(m_handle);
return -1;
}
obj=obj->next;
} else {
obj=(s_obj_t *)g_malloc0(sizeof(s_obj_t));
if( obj == NULL ) {
fprintf(stderr,nomem_msg);
snd_ctl_close(p_handle);
snd_mixer_close(m_handle);
return -1;
}
mixer->obj=obj;
}
bzero(obj,sizeof(s_obj_t));
obj->e=(s_eelements_t *)malloc(sizeof(s_eelements_t));
if( obj->e == NULL ) {
fprintf(stderr,nomem_msg);
snd_ctl_close(p_handle);
snd_mixer_close(m_handle);
return -1;
}
ee=obj->e;
bzero(ee,sizeof(s_eelements_t));
err=s_element_build(m_handle,&ee->e,&es,es.pelements[k],
i,j);
obj->enable=TRUE;
obj->enabled=FALSE;
k++;
}
}
g_free(groups.pgroups);
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;
}
gboolean is_etype(int etype ) {
switch( etype ) {
case SND_MIXER_ETYPE_SWITCH1:
case SND_MIXER_ETYPE_SWITCH2:
case SND_MIXER_ETYPE_SWITCH3:
case SND_MIXER_ETYPE_MUX1:
case SND_MIXER_ETYPE_MUX2:
case SND_MIXER_ETYPE_ACCU3:
case SND_MIXER_ETYPE_VOLUME1:
case SND_MIXER_ETYPE_VOLUME2:
case SND_MIXER_ETYPE_3D_EFFECT1:
case SND_MIXER_ETYPE_TONE_CONTROL1:
case SND_MIXER_ETYPE_PAN_CONTROL1:
return TRUE;
break;
}
return FALSE;
}
static gint ab_chk( s_mixer_t *mixer,snd_mixer_eid_t *eid ) {
if( !is_etype(eid->type) ) return FALSE;
return TRUE;
}
int s_element_build(snd_mixer_t *handle,s_element_t *e,
snd_mixer_elements_t *es, snd_mixer_eid_t eid,
int c,int m) {
int err;
bzero(&e->info,sizeof(snd_mixer_element_info_t));
bzero(&e->e,sizeof(snd_mixer_element_t));
e->e.eid = eid;
e->info.eid = eid;
if( eid.type != SND_MIXER_ETYPE_SWITCH1 &&
eid.type != SND_MIXER_ETYPE_SWITCH2 &&
eid.type > 0 ) {
err=snd_mixer_element_info_build(handle,&e->info);
if( err<0 ) {
preid(eid);
fprintf(stderr,_("Mixer element info build failed: %s\n"),
snd_strerror(err));
}
}
e->w=NULL;
e->adj=NULL;
e->card=c;
e->mdev=m;
e->mux_n=0;
e->mux=NULL;
if( !is_etype(e->e.eid.type) ) return 0;
err=snd_mixer_element_build(handle,&e->e);
if( err<0 ) {
preid(eid);
fprintf(stderr,_("Mixer element build failed: %s\n"),snd_strerror(err));
}
if( e->info.eid.type == SND_MIXER_ETYPE_MUX1 ||
e->info.eid.type == SND_MIXER_ETYPE_MUX2 ) {
e->mux_n=mk_mux_lst(handle,es,&e->info,&e->mux);
if( e->mux_n < 0 ) {
snd_mixer_close(handle);
return -1;
}
}
return 0;
}
static gint mk_mux_lst(snd_mixer_t *handle,snd_mixer_elements_t *es,
snd_mixer_element_info_t *info,
snd_mixer_eid_t **eids) {
int i,j,err,n=0;
snd_mixer_routes_t rt;
int *ee_lst;
snd_mixer_eid_t *eid_l;
ee_lst=(int *)g_malloc(es->elements*sizeof(int));
if( ee_lst == NULL ) {
fprintf(stderr,nomem_msg);
return -1;
}
for( i=0 ; i<es->elements ; i++ ) {
bzero(&rt,sizeof(rt));
rt.eid=es->pelements[i];
if(( err=snd_mixer_routes(handle,&rt))<0 ) {
fprintf(stderr,_("Mixer route error: %s\n"),snd_strerror(err));
g_free(ee_lst);
return -1;
}
if (!rt.routes_over) continue;
rt.proutes=(snd_mixer_eid_t *)g_malloc(rt.routes_over *
sizeof(snd_mixer_eid_t));
if( rt.proutes == NULL ) {
fprintf(stderr,nomem_msg);
g_free(ee_lst);
return -1;
}
rt.routes_size=rt.routes_over;
rt.routes=rt.routes_over=0;
if( (err=snd_mixer_routes(handle,&rt)) < 0 ) {
fprintf(stderr,_("Mixer route (2) error: %s\n"),snd_strerror(err));
g_free(ee_lst);
return -1;
}
for( j=0 ; j<rt.routes ; j++ ) {
if( strcmp(rt.proutes[j].name,info->eid.name) == 0 &&
rt.proutes[j].index == info->eid.index &&
rt.proutes[j].type == info->eid.type ) {
ee_lst[n++]=i;
break;
}
}
g_free(rt.proutes);
}
if( n == 0 ) {
*eids = NULL;
return 0;
}
eid_l = *eids = (snd_mixer_eid_t *)g_malloc(n*sizeof(snd_mixer_eid_t));
if( *eids == NULL ) {
fprintf(stderr,nomem_msg);
g_free(ee_lst);
return -1;
}
for( i=0 ; i<n ; i++ ) {
eid_l[i]=es->pelements[ee_lst[i]];
}
g_free(ee_lst);
return n;
}

View file

View file

@ -1,282 +0,0 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your freedom to
share and change it. By contrast, the GNU General Public License is
intended to guarantee your freedom to share and change free software--to
make sure the software is free for all its users. This General Public
License applies to most of the Free Software Foundation's software and to
any other program whose authors commit to using it. (Some other
Free Software Foundation software is covered by the GNU Library General
Public License instead.) You can apply it to your programs, too.
When we speak of free software, we are referring to freedom, not price. Our
General Public Licenses are designed to make sure that you have the
freedom to distribute copies of free software (and charge for this service
if you wish), that you receive source code or can get it if you want it,
that you can change the software or use pieces of it in new free programs;
and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid anyone to
deny you these rights or to ask you to surrender the rights. These
restrictions translate to certain responsibilities for you if you distribute
copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether gratis or
for a fee, you must give the recipients all the rights that you have. You
must make sure that they, too, receive or can get the source code. And you
must show them these terms so they know their rights.
We protect your rights with two steps: (1) copyright the software, and (2)
offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain that
everyone understands that there is no warranty for this free software.
If the software is modified by someone else and passed on, we want its
recipients to know that what they have is not the original, so that any
problems introduced by others will not reflect on the original authors'
reputations.
Finally, any free program is threatened constantly by software patents. We
wish to avoid the danger that redistributors of a free program will
individually obtain patent licenses, in effect making the program
proprietary. To prevent this, we have made it clear that any patent must be
licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and modification
follow.
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains a notice
placed by the copyright holder saying it may be distributed under
the terms of this General Public License. The "Program", below, refers to
any such program or work, and a "work based on the Program" means
either the Program or any derivative work under copyright law: that is to
say, a work containing the Program or a portion of it, either verbatim
or with modifications and/or translated into another language. (Hereinafter,
translation is included without limitation in the term
"modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not covered
by this License; they are outside its scope. The act of running the
Program is not restricted, and the output from the Program is covered only
if its contents constitute a work based on the Program (independent
of having been made by running the Program). Whether that is true depends on
what the Program does.
1. You may copy and distribute verbatim copies of the Program's source code
as you receive it, in any medium, provided that you conspicuously
and appropriately publish on each copy an appropriate copyright notice and
disclaimer of warranty; keep intact all the notices that refer to this
License and to the absence of any warranty; and give any other recipients of
the Program a copy of this License along with the Program.
You may charge a fee for the physical act of transferring a copy, and you
may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion of it,
thus forming a work based on the Program, and copy and distribute
such modifications or work under the terms of Section 1 above, provided that
you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices stating
that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in whole
or in part contains or is derived from the Program or any part
thereof, to be licensed as a whole at no charge to all third parties
under the terms of this License.
c) If the modified program normally reads commands interactively when
run, you must cause it, when started running for such interactive
use in the most ordinary way, to print or display an announcement
including an appropriate copyright notice and a notice that there is no
warranty (or else, saying that you provide a warranty) and that users
may redistribute the program under these conditions, and telling the
user how to view a copy of this License. (Exception: if the Program
itself is interactive but does not normally print such an announcement,
your work based on the Program is not required to print an
announcement.)
These requirements apply to the modified work as a whole. If identifiable
sections of that work are not derived from the Program, and can be
reasonably considered independent and separate works in themselves, then
this License, and its terms, do not apply to those sections when you
distribute them as separate works. But when you distribute the same sections
as part of a whole which is a work based on the Program, the
distribution of the whole must be on the terms of this License, whose
permissions for other licensees extend to the entire whole, and thus to each
and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest your
rights to work written entirely by you; rather, the intent is to exercise
the
right to control the distribution of derivative or collective works based on
the Program.
In addition, mere aggregation of another work not based on the Program with
the Program (or with a work based on the Program) on a volume
of a storage or distribution medium does not bring the other work under the
scope of this License.
3. You may copy and distribute the Program (or a work based on it, under
Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable source
code, which must be distributed under the terms of Sections 1
and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three years, to
give any third party, for a charge no more than your cost of physically
performing source distribution, a complete machine-readable copy of the
corresponding source code, to be distributed under the terms of
Sections 1 and 2 above on a medium customarily used for software
interchange; or,
c) Accompany it with the information you received as to the offer to
distribute corresponding source code. (This alternative is allowed only
for noncommercial distribution and only if you received the program in
object code or executable form with such an offer, in accord with
Subsection b above.)
The source code for a work means the preferred form of the work for making
modifications to it. For an executable work, complete source code
means all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation and
installation of the executable. However, as a special exception, the source
code distributed need not include anything that is normally distributed
(in either source or binary form) with the major components (compiler,
kernel, and so on) of the operating system on which the executable runs,
unless that component itself accompanies the executable.
If distribution of executable or object code is made by offering access to
copy from a designated place, then offering equivalent access to copy the
source code from the same place counts as distribution of the source code,
even though third parties are not compelled to copy the source along
with the object code.
4. You may not copy, modify, sublicense, or distribute the Program except as
expressly provided under this License. Any attempt otherwise to
copy, modify, sublicense or distribute the Program is void, and will
automatically terminate your rights under this License. However, parties who
have received copies, or rights, from you under this License will not have
their licenses terminated so long as such parties remain in full
compliance.
5. You are not required to accept this License, since you have not signed
it. However, nothing else grants you permission to modify or distribute
the Program or its derivative works. These actions are prohibited by law if
you do not accept this License. Therefore, by modifying or distributing
the Program (or any work based on the Program), you indicate your acceptance
of this License to do so, and all its terms and conditions for
copying, distributing or modifying the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the original
licensor to copy, distribute or modify the Program subject to these terms
and conditions. You may not impose any further restrictions on the
recipients' exercise of the rights granted herein. You are not responsible
for enforcing compliance by third parties to this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions
are imposed on you (whether by court order, agreement or otherwise) that
contradict the conditions of this License, they do not excuse you from
the conditions of this License. If you cannot distribute so as to satisfy
simultaneously your obligations under this License and any other pertinent
obligations, then as a consequence you may not distribute the Program at
all. For example, if a patent license would not permit royalty-free
redistribution of the Program by all those who receive copies directly or
indirectly through you, then the only way you could satisfy both it and
this License would be to refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any patents
or other property right claims or to contest validity of any such claims;
this section has the sole purpose of protecting the integrity of the free
software distribution system, which is implemented by public license
practices. Many people have made generous contributions to the wide range of
software distributed through that system in reliance on consistent
application of that system; it is up to the author/donor to decide if he or
she is willing to distribute software through any other system and a
licensee cannot impose that choice.
This section is intended to make thoroughly clear what is believed to be a
consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in certain
countries either by patents or by copyrighted interfaces, the original
copyright holder who places the Program under this License may add an
explicit geographical distribution limitation excluding those countries, so
that distribution is permitted only in or among countries not thus excluded.
In such case, this License incorporates the limitation as if written in
the body of this License.
9. The Free Software Foundation may publish revised and/or new versions of
the General Public License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in detail
to address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free
Software Foundation.
10. If you wish to incorporate parts of the Program into other free programs
whose distribution conditions are different, write to the author to
ask for permission. For software which is copyrighted by the Free Software
Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals of
preserving the free status of all derivatives of our free software and of
promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
THE PROGRAM, TO THE
EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING
THE COPYRIGHT HOLDERS
AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR
IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
PROGRAM IS WITH YOU.
SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY
SERVICING, REPAIR OR
CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER,
OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS
PERMITTED ABOVE, BE LIABLE
TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO
LOSS OF DATA OR DATA
BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE PROGRAM
TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS
BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS

View file

View file

@ -1,182 +0,0 @@
Basic Installation
==================
These are generic installation instructions.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, a file
`config.cache' that saves the results of its tests to speed up
reconfiguring, and a file `config.log' containing compiler output
(useful mainly for debugging `configure').
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If at some point `config.cache'
contains results you don't want to keep, you may remove or edit it.
The file `configure.in' is used to create `configure' by a program
called `autoconf'. You only need `configure.in' if you want to change
it or regenerate `configure' using a newer version of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system. If you're
using `csh' on an old version of System V, you might need to type
`sh ./configure' instead to prevent `csh' from trying to execute
`configure' itself.
Running `configure' takes awhile. While running, it prints some
messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
the package.
4. Type `make install' to install the programs and any data files and
documentation.
5. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that
the `configure' script does not know about. You can give `configure'
initial values for variables by setting them in the environment. Using
a Bourne-compatible shell, you can do that on the command line like
this:
CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
Or on systems that have the `env' program, you can do it like this:
env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you must use a version of `make' that
supports the `VPATH' variable, such as GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
If you have to use a `make' that does not supports the `VPATH'
variable, you have to compile the package for one architecture at a time
in the source code directory. After you have installed the package for
one architecture, use `make distclean' before reconfiguring for another
architecture.
Installation Names
==================
By default, `make install' will install the package's files in
`/usr/local/bin', `/usr/local/man', etc. You can specify an
installation prefix other than `/usr/local' by giving `configure' the
option `--prefix=PATH'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
give `configure' the option `--exec-prefix=PATH', the package will use
PATH as the prefix for installing programs and libraries.
Documentation and other data files will still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=PATH' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them.
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Optional Features
=================
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Specifying the System Type
==========================
There may be some features `configure' can not figure out
automatically, but needs to determine by the type of host the package
will run on. Usually `configure' can figure that out, but if it prints
a message saying it can not guess the host type, give it the
`--host=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name with three fields:
CPU-COMPANY-SYSTEM
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the host type.
If you are building compiler tools for cross-compiling, you can also
use the `--target=TYPE' option to select the type of system they will
produce code for and the `--build=TYPE' option to select the type of
system on which you are compiling the package.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share,
you can create a site shell script called `config.site' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Operation Controls
==================
`configure' recognizes the following options to control how it
operates.
`--cache-file=FILE'
Use and save the results of the tests in FILE instead of
`./config.cache'. Set FILE to `/dev/null' to disable caching, for
debugging `configure'.
`--help'
Print a summary of the options to `configure', and exit.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null' (any error
messages will still be shown).
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`--version'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`configure' also accepts some other, not widely useful, options.

View file

@ -1,5 +0,0 @@
bin_PROGRAMS = xamixer2
xamixer2_SOURCES = main.h structs.h xamixer2.c xamixer2.h callbacks.c callbacks.h cinit.c cinit.h display.c display.h util.c util.h config.c config.h switches.c switches.h options.c options.h
xamixer2_LDFLAGS = $(GTK_LIBS)
sysconf_DATA = xamixer.conf
EXTRA_DIST = README COPYING INSTALL AUTHORS NEWS TODO xamixer.home xamixer.conf

View file

View file

View file

View file

@ -1,225 +0,0 @@
/*****************************************************************************
callbacks.c - an Alsa based gtk mixer
Written by Raistlinn (lansdoct@cs.alfred.edu)
Copyright (C) 1998 by Christopher Lansdown
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
******************************************************************************/
/*****************************************************************************/
/* Begin #include's */
#include "main.h"
/* End #include's */
/*****************************************************************************/
/*****************************************************************************/
/* Begin Global Variables */
extern GtkWidget *window;
extern Card *card; /* And array of the cards */
extern int cards; /* The number of cards in the system. */
extern Config config; /* The system config */
/* End Global Variables */
/*****************************************************************************/
void mixer_rebuild_cb(void *data)
{
/* printf("A rebuild event happened.\n"); */
/* fflush(NULL); */
return;
}
void mixer_element_cb(void *data, int cmd, snd_mixer_eid_t *eid)
{
/* printf("An element event happened.\n"); */
/* fflush(NULL); */
return;
}
void mixer_group_cb(void *data, int cmd, snd_mixer_gid_t *gid)
{
/* printf("A group event happened.\n"); */
/* fflush(NULL); */
return;
}
void mixer_change_cb(gpointer data, gint source, GdkInputCondition condition)
{
snd_mixer_callbacks_t callbacks;
/* Set up the callback structure */
callbacks.private_data = data;
callbacks.rebuild = mixer_rebuild_cb;
callbacks.element = mixer_element_cb;
callbacks.group = mixer_group_cb;
bzero(callbacks.reserved, sizeof(void *) * 28);
/* Actually deal with the event. */
snd_mixer_read(MIXER(data)->handle, &callbacks);
return;
}
void adjust_teffect1(GtkWidget *widget, CBData *data)
{
int i, j, err;
Group *group;
i = data->element;
j = data->index;
group = data->group;
switch(j) {
case TYPE_SW:
if(GTK_TOGGLE_BUTTON(widget)->active)
group->element[i].data.teffect1.sw = 1;
else
group->element[i].data.teffect1.sw = 0;
break;
case TYPE_MONO_SW:
if(GTK_TOGGLE_BUTTON(widget)->active)
group->element[i].data.teffect1.mono_sw = 1;
else
group->element[i].data.teffect1.mono_sw = 0;
break;
case TYPE_WIDE:
group->element[i].data.teffect1.wide =
(int)GTK_ADJUSTMENT(widget)->value;
break;
case TYPE_VOLUME:
group->element[i].data.teffect1.volume =
(int)GTK_ADJUSTMENT(widget)->value;
break;
case TYPE_CENTER:
group->element[i].data.teffect1.center =
(int)GTK_ADJUSTMENT(widget)->value;
break;
case TYPE_SPACE:
group->element[i].data.teffect1.space =
(int)GTK_ADJUSTMENT(widget)->value;
break;
case TYPE_DEPTH:
group->element[i].data.teffect1.depth =
(int)GTK_ADJUSTMENT(widget)->value;
break;
case TYPE_DELAY:
group->element[i].data.teffect1.delay =
(int)GTK_ADJUSTMENT(widget)->value;
break;
case TYPE_FEEDBACK:
group->element[i].data.teffect1.feedback =
(int)GTK_ADJUSTMENT(widget)->value;
break;
default:
printf("Hit the default in adjust_teffect1 - this is bad.\n");
break;
}
/* Now let's write the new value to the card */
if ((err = snd_mixer_element_write(data->handle, &group->element[i])) < 0) {
printf("3D Effect Mixer element write error: %s\n", snd_strerror(err));
}
return;
}
void adjust_switch1(GtkWidget *widget, CBData *data)
{
int i, j, err;
i = data->element;
j = data->index;
if(GTK_TOGGLE_BUTTON(widget)->active)
data->group->element[i].data.switch1.psw[j / sizeof(unsigned int)] |=
(1 << (j % sizeof(unsigned int)));
else
data->group->element[i].data.switch1.psw[j / sizeof(unsigned int)] &=
~(1 << (j % sizeof(unsigned int)));
/* Now let's write the new value to the card */
if ((err = snd_mixer_element_write(data->handle, &data->group->element[i])) < 0) {
printf("Mixer element write error: %s\n", snd_strerror(err));
}
return;
}
void adjust_volume1(GtkWidget *widget, CBData *data)
{
register int volume;
int i, j, err;
i = data->element;
j = data->index;
volume = (int)GTK_ADJUSTMENT(data->group->gtk[i].adjust[j])->value;
data->group->element[i].data.volume1.pvoices[j] = volume;
/* Now let's write the new value to the card */
if ((err = snd_mixer_element_write(data->handle, &data->group->element[i])) < 0) {
printf("Mixer element write error: %s\n", snd_strerror(err));
}
return;
}
void adjust_switch2(GtkWidget *widget, CBData *data)
{
int i, j, err;
i = data->element;
j = data->index;
if(GTK_TOGGLE_BUTTON(data->group->gtk[i].interface[j])->active) {
data->group->element[i].data.switch2.sw = 1;
} else {
data->group->element[i].data.switch2.sw = 0;
}
/* Now let's write the new value to the card */
if ((err = snd_mixer_element_write(data->handle, &data->group->element[i])) < 0) {
printf("Mixer element write error: %s\n", snd_strerror(err));
}
return;
}

View file

@ -1,28 +0,0 @@
/*****************************************************************************/
/* Begin #include statements */
/* End #include statements */
/*****************************************************************************/
/*****************************************************************************/
/* Begin function prototypes */
void adjust_volume1(GtkWidget *widget, CBData *data);
void adjust_switch1(GtkWidget *widget, CBData *data);
void adjust_switch2(GtkWidget *widget, CBData *data);
void adjust_teffect1(GtkWidget *widget, CBData *data);
void mixer_change_cb(gpointer data, gint source, GdkInputCondition condition);
/* End function prototypes */
/*****************************************************************************/
/*****************************************************************************/
/* Begin #define statements */
/* End #define statements */
/*****************************************************************************/

View file

@ -1,386 +0,0 @@
/*****************************************************************************
cinit.c - routines to initialize the mixer devices
Written by Raistlinn (lansdoct@cs.alfred.edu)
Copyright (C) 1998 by Christopher Lansdown
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
******************************************************************************/
/*****************************************************************************/
/* Begin #include's */
#include "main.h"
/* End #include's */
/*****************************************************************************/
/*****************************************************************************/
/* Begin Global Variables */
extern Card *card; /* And array of the cards */
extern int cards; /* The number of cards in the system. */
extern Config config; /* The system config */
/* End Global Variables */
/*****************************************************************************/
/*****************************************************************************/
/* Begin function prototypes */
int init_group(void *handle, Group *group);
int init_element_route(void *handle, snd_mixer_routes_t *routes, snd_mixer_eid_t *eid);
int misc_group_hack(Mixer *mixer, int index);
/* End function prototypes */
/*****************************************************************************/
int init_cards()
{
int i,j,k;
int err;
snd_ctl_t *handle;
cards = snd_cards();
card = calloc(cards, sizeof(Card));
for(i = 0; i < cards; i++) {
/* Open the hardware */
if((err = snd_ctl_open(&handle, i)) < 0) {
printf("Unable to open card #%i!\nError: %s\n", i, snd_strerror(err));
card[i].mixer = NULL;
card[i].number = -1;
continue;
} else {
card[i].number = i;
}
/* Get the hardware info - the primary use of this is to find out how many
mixer devices the card has, but it's also useful to find out the human-readable
name of the card. */
if((err = snd_ctl_hw_info(handle, &card[i].hw_info)) < 0) {
printf("Unable to get hardware information about card #%i!\nError: %s\n",
i, snd_strerror(err));
printf("Trying to guess the appropriate values.\n");
card[i].hw_info.mixerdevs = 1;
}
card[i].nmixers = card[i].hw_info.mixerdevs;
/* Allocate out the mixer array */
card[i].mixer = calloc(card[i].hw_info.mixerdevs, sizeof(Mixer));
for(j = 0; j < card[i].hw_info.mixerdevs; j++) {
/* Open the mixer to begin with. Isn't it funny how there's all this
nice generalized code that can handle nearly any situation, and it
will be necessary in only a very small percentage of the situations.
Oh well, I guess that that's what distinguishes us from windows. :-) */
if((err = snd_mixer_open(&card[i].mixer[j].handle, i, j)) < 0) {
printf("Unable to open mixer #%i on card #%i~\nError: %s\n",
j, i, snd_strerror(err));
card[i].mixer[j].number = -1;
} else {
card[i].mixer[j].number = j;
}
/* Get the mixer info */
if((err = snd_mixer_info(card[i].mixer[j].handle, &card[i].mixer[j].info)) < 0) {
printf("Unable to get the info for mixer #%i on card %i! Error: %s\n", j, i, snd_strerror(err));
printf("There's not much more I can do on this mixer.");
printf(" Shutting it down.\n");
if((err = snd_mixer_close(card[i].mixer[j].handle)) < 0) {
printf("Oh well. I couldn't even close the mixer. I suspect that something is seriously wrong here. Good luck.\n");
}
card[i].mixer[j].number = -1;
continue;
}
bzero(&card[i].mixer[j].groups, sizeof(snd_mixer_groups_t));
if ((err = snd_mixer_groups(card[i].mixer[j].handle,
&card[i].mixer[j].groups)) < 0) {
printf("Mixer %i/%i groups error: %s",
i, j, snd_strerror(err));
return -1;
}
/* Allocate the space for the group array */
card[i].mixer[j].groups.pgroups = (snd_mixer_gid_t *)
calloc(card[i].mixer[j].groups.groups_over,
sizeof(snd_mixer_gid_t));
if (!card[i].mixer[j].groups.pgroups) {
printf("No enough memory");
return -1;
}
card[i].mixer[j].groups.groups_size = card[i].mixer[j].info.groups;
card[i].mixer[j].groups.groups_over = card[i].mixer[j].groups.groups = 0;
if ((err = snd_mixer_groups(card[i].mixer[j].handle,
&card[i].mixer[j].groups)) < 0) {
printf("Mixer %i/%i groups (2) error: %s",
i, j, snd_strerror(err));
return -1;
}
/* Allocate the space for the array of the groups - this is more than
just their gid's, it's got group-specific info in it */
card[i].mixer[j].group = calloc(card[i].mixer[j].info.groups + 1,
sizeof(Group));
/* get the group structures filled out */
for(k = 0; k < card[i].mixer[j].info.groups; k++) {
card[i].mixer[j].group[k].group.gid =
card[i].mixer[j].groups.pgroups[k];
init_group(card[i].mixer[j].handle,
&card[i].mixer[j].group[k]);
}
misc_group_hack(&card[i].mixer[j], k);
}
if((err = snd_ctl_close(handle)) < 0) {
printf("strange, there was an error closing card #%i!\nError: %s\n",
i, snd_strerror(err));
printf("Oh well.\n");
}
}
/* return a successful execution. */
return 0;
}
int misc_group_hack(Mixer *mixer, int index)
{
/* This code is largely copied straight from amixer. - God I love the GPL. */
snd_mixer_elements_t elements;
snd_mixer_eid_t *element;
snd_mixer_group_t *group;
int err, idx, gdx, idx2;
int flag;
int count=0; /* The count of elements not in any group */
snd_mixer_eid_t **array;
bzero(&elements, sizeof(elements));
if ((err = snd_mixer_elements(mixer->handle, &elements)) < 0) {
printf("Mixer elements error: %s", snd_strerror(err));
return -1;
}
elements.pelements = (snd_mixer_eid_t *)malloc(elements.elements_over *
sizeof(snd_mixer_eid_t));
if (!elements.pelements) {
printf("Not enough memory");
return -1;
}
elements.elements_size = elements.elements_over;
elements.elements_over = elements.elements = 0;
if ((err = snd_mixer_elements(mixer->handle, &elements)) < 0) {
printf("Mixer elements (2) error: %s", snd_strerror(err));
return -1;
}
/* Allocate the temporary array to hold the mixer ID structs */
array = malloc(elements.elements * sizeof(snd_mixer_eid_t *));
if(!array)
printf("Not enough memory.\n");
for (idx = 0; idx < elements.elements; idx++) {
element = &elements.pelements[idx];
flag = 0; /* The flag will be set if the same element name & type
is encountered */
for(gdx = 0; gdx < mixer->info.groups; gdx++) {
group = &mixer->group[gdx].group;
for(idx2 = 0; idx2 < group->elements; idx2++) {
if(group && element)
if(group->pelements[idx2].type == element->type &&
is_same(group->pelements[idx2].name, element->name))
flag = 1;
}
}
if(!flag) {
/* We found a mixer element that's not in a group */
array[count] = element;
count++;
if(count > elements.elements)
printf("Houston, we have a problem.\n");
}
}
/* Set up the group member */
strncpy(mixer->group[index].group.gid.name, "Miscellaneous\0", 24);
mixer->group[index].group.gid.index = 0;
mixer->group[index].group.elements_size = 0; /* I hope that this doesn't matter */
mixer->group[index].group.elements = count;
mixer->group[index].group.elements_over = 0; /* I hope tha this doesn't matter */
mixer->group[index].group.pelements = (snd_mixer_eid_t *)malloc(count *
sizeof(snd_mixer_eid_t));
mixer->group[index].routes = calloc(mixer->group[index].group.elements,
sizeof(snd_mixer_routes_t));
mixer->group[index].element = calloc(mixer->group[index].group.elements,
sizeof(snd_mixer_element_t));
mixer->group[index].einfo = calloc(mixer->group[index].group.elements,
sizeof(snd_mixer_element_info_t));
mixer->group[index].gtk = calloc(mixer->group[index].group.elements,
sizeof(Gtk_Channel));
/* Copy the snd_mixer_eid_t structures into the new group structure and init the routes */
for(idx = 0; idx < count; idx++) {
mixer->group[index].group.pelements[idx] = *array[idx];
mixer->group[index].einfo[idx].eid = mixer->group[index].group.pelements[idx];
if(snd_mixer_element_has_info(&mixer->group[index].group.pelements[idx]) == 1)
if((err =
snd_mixer_element_info_build(mixer->handle,
&mixer->group[index].einfo[idx])) < 0) {
printf("Unable to get element information for element %s! ",
mixer->group[index].group.pelements[idx].name);
printf("Error: %s.\n", snd_strerror(err));
}
mixer->group[index].element[idx].eid = mixer->group[index].group.pelements[idx];
if(snd_mixer_element_has_control(&mixer->group[index].element[idx].eid))
if((err = snd_mixer_element_build(mixer->handle,
&mixer->group[index].element[idx])) < 0) {
printf("Unable to read element %s! ",
mixer->group[index].group.pelements[idx].name);
printf("Error: %s.\n", snd_strerror(err));
}
init_element_route(mixer->handle,
&mixer->group[index].routes[idx],
&mixer->group[index].group.pelements[idx]);
}
/* Increase the number of groups to include the new group */
mixer->info.groups++;
if(elements.pelements)
free(elements.pelements);
if(array)
free(array);
return 1;
}
int init_group(void *handle, Group *group)
{
/* This is largely a mess copied from amixer that gets the group info in a very strange
way, I wish that I knew how it really worked. Anyhow, once we get the group into
and the info about the elements in the group, we'll set up the element array. */
int idx, err;
if((err = snd_mixer_group_read(handle,
&group->group)) < 0) {
printf("Unable to get info for group %s! ", group->group.gid.name);
printf("Error: %s\n", snd_strerror(err));
printf("elements_size = %i, elements_over=%i, elements=%i\n",
group->group.elements_size,
group->group.elements_over,
group->group.elements);
return 0;
}
group->group.pelements = (snd_mixer_eid_t *)calloc(group->group.elements_over,
sizeof(snd_mixer_eid_t));
if (!group->group.pelements) {
printf("Not enough memory...");
return 0;
}
group->group.elements_size = group->group.elements_over;
group->group.elements = group->group.elements_over = 0;
if ((err = snd_mixer_group_read(handle, &group->group)) < 0) {
printf("Unable to get second group info for group %s. Error: %s\n",
group->group.gid.name, snd_strerror(err));
printf("elements_size = %i, elements_over=%i, elements=%i\n",
group->group.elements_size,
group->group.elements_over,
group->group.elements);
return 0;
}
/* Allocate out the arrays for the elements and element info */
group->element = calloc(group->group.elements, sizeof(snd_mixer_element_t));
group->einfo = calloc(group->group.elements, sizeof(snd_mixer_element_info_t));
group->routes = calloc(group->group.elements, sizeof(snd_mixer_routes_t));
group->gtk = calloc(group->group.elements, sizeof(Gtk_Channel));
/* Now go through and get that info */
for (idx = 0; idx < group->group.elements; idx++) {
group->einfo[idx].eid = group->group.pelements[idx];
if(snd_mixer_element_has_info(&group->group.pelements[idx]) == 1)
if((err = snd_mixer_element_info_build(handle, &group->einfo[idx])) < 0) {
printf("Unable to get element information for element %s! ",
group->group.pelements[idx].name);
printf("Error: %s.\n", snd_strerror(err));
}
group->element[idx].eid = group->group.pelements[idx];
if((err = snd_mixer_element_build(handle, &group->element[idx])) < 0) {
printf("Unable to read element %s! ",
group->group.pelements[idx].name);
printf("Error: %s.\n", snd_strerror(err));
}
init_element_route(handle, &group->routes[idx], &group->group.pelements[idx]);
}
return 1;
}
int init_element_route(void *handle, snd_mixer_routes_t *routes, snd_mixer_eid_t *eid)
{
int err, idx;
/* Most of this code is taken straight from amixer as well. */
/* This just gets the routes for the mixer element and stores them. */
bzero(routes, sizeof(snd_mixer_routes_t));
routes->eid = *eid;
if ((err = snd_mixer_routes(handle, routes)) < 0) {
printf("Element %s route error: %s", eid->name, snd_strerror(err));
return -1;
}
if (!routes->routes_over)
return 0;
routes->proutes = (snd_mixer_eid_t *)malloc(routes->routes_over *
sizeof(snd_mixer_eid_t));
if (!routes->proutes) {
printf("No enough memory...");
return -1;
}
routes->routes_size = routes->routes_over;
routes->routes = routes->routes_over = 0;
if ((err = snd_mixer_routes(handle, routes)) < 0) {
printf("Element (2) %s route error: %s", eid->name, snd_strerror(err));
return -1;
}
return 1;
}

View file

@ -1,25 +0,0 @@
/*****************************************************************************/
/* Begin #include statements */
/* End #include statements */
/*****************************************************************************/
/*****************************************************************************/
/* Begin function prototypes */
int init_cards();
/* End function prototypes */
/*****************************************************************************/
/*****************************************************************************/
/* Begin #define statements */
/* End #define statements */
/*****************************************************************************/

View file

@ -1,483 +0,0 @@
/*****************************************************************************
config.c - parses the config file
Written by Raistlinn (lansdoct@cs.alfred.edu)
Copyright (C) 1998 by Christopher Lansdown
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
******************************************************************************/
/*****************************************************************************/
/* Begin #include's */
#include "main.h"
/* End #include's */
/*****************************************************************************/
/*****************************************************************************/
/* Begin #define's */
#define CHANNEL_SIZE 64
#define LABEL_SIZE 1024
/* End #define's */
/*****************************************************************************/
/*****************************************************************************/
/* Begin Global Variables */
extern Card *card; /* And array of the cards */
extern int cards; /* The number of cards in the system. */
Config config; /* The global config */
/* End Global Variables */
/*****************************************************************************/
int config_init()
{
/* Initialize the values to some reasonable defaults */
config.flags &= 0;
config.labels = NULL;
config.xpm = NULL;
config.icon = NULL;
config.mute = "M";
config.unmute = NULL;
config.simul = "|-|";
config.unsimul = NULL;
config.rec = "Rec";
config.unrec = NULL;
config.scale = 100;
config.x_pos = -1;
config.y_pos = -1;
config.padding = 5;
config.cdisplay = NULL;
return 1;
}
int config_read(const char *file)
{
char *home_dir, *home_env;
FILE *stream;
char line[1025], *chr;
int state = 0; /* 0 = general config; 1 = history */
unsigned int i = 0;
int linelen = 0;
char channel[CHANNEL_SIZE]; /* The name of the channel */
char label[LABEL_SIZE]; /* The label or xpm name */
int linenum = 0;
stream = fopen(file, "r");
/* If there is no initialized value */
if(stream == NULL)
return TRUE;
while(fgets(line, 1024, stream)){
linenum++;
/* Get wrid of comments */
if(is_comment(line))
continue;
strip_comment(line);
/* Convert the line to upper case so that matches aren't case
sensitive (if not in history)*/
linelen = strlen(line);
if(strstr(line, "Position")) {
if(sscanf(line, "Position %i %i", &config.x_pos, &config.y_pos) < 2)
config.x_pos = config.y_pos = -1;
}
else if(strstr(line, "ShowCardName"))
config.flags |= CONFIG_SHOW_CARD_NAME;
else if(strstr(line, "ShowMixerNumber"))
config.flags |= CONFIG_SHOW_MIXER_NUMBER;
else if(strstr(line, "ShowMixerName"))
config.flags |= CONFIG_SHOW_MIXER_NAME;
else if(strstr(line, "IconXpm"))
if(sscanf(line, "IconXpm %s", label) < 1)
printf("Bad IconXpm entry at line %i.\n", linenum);
else {
config.icon = calloc(strlen(label) + 1, sizeof(char));
strcpy(config.icon, label);
config.flags |= CONFIG_ICON_XPM;
}
else if(strstr(line, "IgnoreXpms"))
config.flags &= ~CONFIG_USE_XPMS;
else if(strstr(line, "UseXpms"))
config.flags |= CONFIG_USE_XPMS;
else if(strstr(line, "unMuteXpmLeft"))
if(sscanf(line, "unMuteXpmLeft %s", label) < 1)
printf("Bad unMuteXpmLeft entry at line %i.\n", linenum);
else {
config.unmute_l = calloc(strlen(label) + 1, sizeof(char));
strcpy(config.unmute_l, label);
config.flags |= CONFIG_UNMUTE_XPM_L;
}
else if(strstr(line, "unMuteXpm"))
if(sscanf(line, "unMuteXpm %s", label) < 1)
printf("Bad unMuteXpm entry at line %i.\n", linenum);
else {
config.unmute = calloc(strlen(label) + 1, sizeof(char));
strcpy(config.unmute, label);
config.flags |= CONFIG_UNMUTE_XPM;
}
else if(strstr(line, "unRecXpm"))
if(sscanf(line, "unRecXpm %s", label) < 1)
printf("Bad unRecXpm entry at line %i.\n", linenum);
else {
config.unrec = calloc(strlen(label) + 1, sizeof(char));
strcpy(config.unrec, label);
config.flags |= CONFIG_UNREC_XPM;
}
else if(strstr(line, "unSimulXpm"))
if(sscanf(line, "unSimulXpm %s", label) < 1)
printf("Bad unSimulXpm entry at line %i.\n", linenum);
else {
config.unsimul = calloc(strlen(label) + 1, sizeof(char));
strcpy(config.unsimul, label);
config.flags |= CONFIG_UNSIMUL_XPM;
}
else if(strstr(line, "MuteLabel"))
if(sscanf(line, "MuteLabel %s", label) < 1)
printf("Bad MuteLabel entry at line %i.\n", linenum);
else {
config.mute = calloc(strlen(label) + 1, sizeof(char));
strcpy(config.mute, label);
config.flags &= ~CONFIG_MUTE_XPM;
}
else if(strstr(line, "SimulLabel"))
if(sscanf(line, "SimulLabel %s", label) < 1)
printf("Bad SimulLabel entry at line %i.\n", linenum);
else {
config.simul = calloc(strlen(label) + 1, sizeof(char));
strcpy(config.simul, label);
config.flags &= ~CONFIG_SIMUL_XPM;
}
else if(strstr(line, "RecLabel"))
if(sscanf(line, "RecLabel %s", label) < 1)
printf("Bad RecLabel entry at line %i.\n", linenum);
else {
config.rec = calloc(strlen(label) + 1, sizeof(char));
strcpy(config.rec, label);
config.flags &= ~CONFIG_REC_XPM;
}
else if(strstr(line, "MuteXpmLeft"))
if(sscanf(line, "MuteXpmLeft %s", label) < 1)
printf("Bad MuteXpmLeft entry at line %i.\n", linenum);
else {
config.mute_l = calloc(strlen(label) + 1, sizeof(char));
strcpy(config.mute_l, label);
config.flags |= CONFIG_MUTE_XPM_L;
}
else if(strstr(line, "MuteXpm"))
if(sscanf(line, "MuteXpm %s", label) < 1)
printf("Bad MuteXpm entry at line %i.\n", linenum);
else {
config.mute = calloc(strlen(label) + 1, sizeof(char));
strcpy(config.mute, label);
config.flags |= CONFIG_MUTE_XPM;
}
else if(strstr(line, "RecXpm"))
if(sscanf(line, "RecXpm %s", label) < 1)
printf("Bad RecXpm entry at line %i.\n", linenum);
else {
config.rec = calloc(strlen(label) + 1, sizeof(char));
strcpy(config.rec, label);
config.flags |= CONFIG_REC_XPM;
}
else if(strstr(line, "SimulXpm"))
if(sscanf(line, "SimulXpm %s", label) < 1)
printf("Bad SimulXpm entry at line %i.\n", linenum);
else {
config.simul = calloc(strlen(label) + 1, sizeof(char));
strcpy(config.simul, label);
config.flags |= CONFIG_SIMUL_XPM;
}
else if(strstr(line, "BackgroundXpm"))
if(sscanf(line, "BackgroundXpm %s", label) < 1)
printf("Bad BackgroundXpm entry at line %i.\n", linenum);
else {
config.background = calloc(strlen(label) + 1, sizeof(char));
strcpy(config.background, label);
config.flags |= CONFIG_BACKGROUND_XPM;
}
else if(strstr(line, "Label")){
if(get_label(line, "Label", channel, CHANNEL_SIZE,
label, LABEL_SIZE, '[', ']')){
config.labels = channel_label_append(config.labels, channel, label);
}
else
printf("Bad Label entry found on line %i.\n", linenum);
}
else if(strstr(line, "Xpm")){
if(get_label(line, "Xpm", channel, CHANNEL_SIZE,
label, LABEL_SIZE, '[', ']')){
config.xpm = channel_label_append(config.xpm, channel, label);
}
else
printf("Bad Xpm entry found on line %i.\n", linenum);
}
else if(strstr(line, "ScaleSize"))
if(sscanf(line, "ScaleSize %i", &i) == 1)
config.scale = i;
else
printf("Bad ScaleSize entry at line %i.\n", linenum);
if(strstr(line, "ChannelPadding"))
if(sscanf(line, "ChannelPadding %i", &i) == 1)
config.padding = i;
else
printf("Bad ChannelPadding entry at line %i.\n", linenum);
} /* End of config loop */
/* Close the file */
fclose(stream);
return TRUE;
}
int setup_pixmaps(GtkWidget *xpmparent)
{
GtkStyle *style;
int fd;
if(!(config.flags & CONFIG_USE_XPMS)) {
config.mute = "M";
config.simul = "|-|";
config.rec = "Rec";
return;
}
if(config.flags & CONFIG_ICON_XPM){
fd = open(config.icon, O_RDONLY);
if(fd != -1) {
close(fd);
style = gtk_widget_get_style(xpmparent);
config.icon_xpm =
gdk_pixmap_create_from_xpm(xpmparent->window,
&config.icon_mask,
&style->bg[GTK_STATE_NORMAL],
config.icon);
}
else {
printf("Unable to open pixmap %s.\n", config.icon);
config.flags &= ~CONFIG_ICON_XPM;
config.icon_xpm = NULL;
free(config.icon);
config.icon = NULL;
}
}
if(config.flags & CONFIG_MUTE_XPM_L){
fd=open(config.mute_l, O_RDONLY);
if(fd != -1) {
close(fd);
style = gtk_widget_get_style(xpmparent);
config.mute_xpm_l =
gdk_pixmap_create_from_xpm(xpmparent->window,
&config.mute_mask_l,
&style->bg[GTK_STATE_NORMAL],
config.mute_l);
}
else {
printf("Unable to open pixmap %s.\n", config.mute_l);
config.flags &= ~CONFIG_MUTE_XPM_L;
config.mute_xpm_l = NULL;
free(config.mute_l);
config.mute_l = NULL;
}
}
if(config.flags & CONFIG_MUTE_XPM){
fd=open(config.mute, O_RDONLY);
if(fd != -1) {
close(fd);
style = gtk_widget_get_style(xpmparent);
config.mute_xpm =
gdk_pixmap_create_from_xpm(xpmparent->window,
&config.mute_mask,
&style->bg[GTK_STATE_NORMAL],
config.mute);
if(!(config.flags & CONFIG_MUTE_XPM_L)) {
config.mute_xpm_l = config.mute_xpm;
config.mute_mask_l = config.mute_mask;
config.flags |= CONFIG_MUTE_XPM_L;
}
}
else {
printf("Unable to open pixmap %s.\n", config.mute);
config.flags &= ~CONFIG_MUTE_XPM;
config.mute_xpm = NULL;
free(config.mute);
config.mute = "M";
}
}
if(config.flags & CONFIG_UNMUTE_XPM_L) {
fd=open(config.unmute_l, O_RDONLY);
if(fd != -1) {
close(fd);
style = gtk_widget_get_style(xpmparent);
config.unmute_xpm_l =
gdk_pixmap_create_from_xpm(xpmparent->window,
&config.unmute_mask_l,
&style->bg[GTK_STATE_NORMAL],
config.unmute_l);
}
else {
printf("Unable to open pixmap %s.\n", config.unmute_l);
config.flags &= ~CONFIG_UNMUTE_XPM_L;
free(config.unmute_l);
config.unmute_l=NULL;
}
}
if(config.flags & CONFIG_UNMUTE_XPM) {
fd=open(config.unmute, O_RDONLY);
if(fd != -1) {
close(fd);
style = gtk_widget_get_style(xpmparent);
config.unmute_xpm =
gdk_pixmap_create_from_xpm(xpmparent->window,
&config.unmute_mask,
&style->bg[GTK_STATE_NORMAL],
config.unmute);
if(!(config.flags & CONFIG_UNMUTE_XPM_L)) {
printf("Invoked!\n");
config.unmute_xpm_l = config.unmute_xpm;
config.unmute_mask_l = config.unmute_mask;
config.flags |= CONFIG_UNMUTE_XPM_L;
}
}
else {
printf("Unable to open pixmap %s.\n", config.unmute);
config.flags &= ~CONFIG_UNMUTE_XPM;
free(config.unmute);
config.unmute=NULL;
}
}
if(config.flags & CONFIG_REC_XPM) {
fd=open(config.rec, O_RDONLY);
if(fd != -1) {
close(fd);
style = gtk_widget_get_style(xpmparent);
config.rec_xpm =
gdk_pixmap_create_from_xpm(xpmparent->window,
&config.rec_mask,
&style->bg[GTK_STATE_NORMAL],
config.rec);
}
else {
printf("Unable to open pixmap %s.\n", config.rec);
config.flags &= ~CONFIG_REC_XPM;
free(config.rec);
config.rec = "Rec";
}
}
if(config.flags & CONFIG_UNREC_XPM) {
fd=open(config.unrec, O_RDONLY);
if(fd != -1) {
close(fd);
style = gtk_widget_get_style(xpmparent);
config.unrec_xpm =
gdk_pixmap_create_from_xpm(xpmparent->window,
&config.unrec_mask,
&style->bg[GTK_STATE_NORMAL],
config.unrec);
}
else {
printf("Unable to open pixmap %s.\n", config.unrec);
config.flags &= ~CONFIG_UNREC_XPM;
free(config.unrec);
config.unrec=NULL;
}
}
if(config.flags & CONFIG_SIMUL_XPM) {
fd = open(config.simul, O_RDONLY);
if(fd != -1) {
close(fd);
style = gtk_widget_get_style(xpmparent);
config.simul_xpm =
gdk_pixmap_create_from_xpm(xpmparent->window,
&config.simul_mask,
&style->bg[GTK_STATE_NORMAL],
config.simul);
}
else {
printf("Unable to open pixmap %s.\n", config.simul);
config.flags &= ~CONFIG_SIMUL_XPM;
free(config.simul);
config.simul="|-|";
}
}
if(config.flags & CONFIG_UNSIMUL_XPM) {
fd = open(config.unsimul, O_RDONLY);
if(fd != -1) {
close(fd);
style = gtk_widget_get_style(xpmparent);
config.unsimul_xpm =
gdk_pixmap_create_from_xpm(xpmparent->window,
&config.unsimul_mask,
&style->bg[GTK_STATE_NORMAL],
config.unsimul);
}
else {
printf("Unable to open pixmap %s.\n", config.unsimul);
config.flags &= ~CONFIG_UNSIMUL_XPM;
free(config.unsimul);
config.unsimul=NULL;
}
}
if(config.flags & CONFIG_BACKGROUND_XPM) {
fd = open(config.background, O_RDONLY);
if(fd != -1) {
close(fd);
style = gtk_widget_get_style(xpmparent);
config.background_xpm =
gdk_pixmap_create_from_xpm(xpmparent->window,
&config.background_mask,
&style->bg[GTK_STATE_NORMAL],
config.background);
}
else {
printf("Unable to open pixmap %s.\n", config.background);
config.flags &= ~CONFIG_BACKGROUND_XPM;
free(config.background);
config.background=NULL;
}
}
return TRUE;
}

View file

@ -1,24 +0,0 @@
/*****************************************************************************/
/* Begin #include statements */
/* End #include statements */
/*****************************************************************************/
/*****************************************************************************/
/* Begin function prototypes */
int config_init();
int config_read(const char *file);
int setup_pixmaps(GtkWidget *xpmparent);
/* End function prototypes */
/*****************************************************************************/
/*****************************************************************************/
/* Begin #define statements */
#define HOME_FILE ".xamixer"
/* End #define statements */
/*****************************************************************************/

View file

@ -1,11 +0,0 @@
AC_INIT(xamixer2.c)
AM_INIT_AUTOMAKE(xamixer2,0.1.3)
AC_PROG_CC
AC_PROG_INSTALL
AC_HEADER_STDC
AM_PATH_GTK(1.0.1)
AM_PATH_ALSA(0.1.3)
CFLAGS="$CFLAGS $GTK_CFLAGS $ALSA_FLAGS"
LDFLAGS="$LDFLAGS $GTK_LIBS $ALSA_LIBS"
AC_OUTPUT(Makefile)

View file

@ -1,592 +0,0 @@
/*****************************************************************************
xamixer.c - an Alsa based gtk mixer
Written by Raistlinn (lansdoct@cs.alfred.edu)
Copyright (C) 1998 by Christopher Lansdown
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
******************************************************************************/
/*****************************************************************************/
/* Begin #include's */
#include "main.h"
/* End #include's */
/*****************************************************************************/
/*****************************************************************************/
/* Begin Global Variables */
extern GtkWidget *window;
extern Card *card; /* And array of the cards */
extern int cards; /* The number of cards in the system. */
extern Config config; /* The system config */
/* End Global Variables */
/*****************************************************************************/
/*****************************************************************************/
/* Begin function prototypes */
GtkWidget *group_elements(int card, int mixer, Group *group);
GtkWidget *display_volume1(Group *group, int element, void *handle, char *route);
GtkWidget *display_switch2(Group *group, int element, void *handle, char *route);
GtkWidget *display_switch1(Group *group, int element, void *handle, char *route);
GtkWidget *display_3deffect1(Group *group, int element, void *handle, char *route);
/* End function protoypes */
/*****************************************************************************/
GtkWidget *create_mixer_page(int card_num, int mixer_num)
{
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *frame;
int i=card_num, j=mixer_num, k=0, l, m;
int w=1, col;
/* Compute the number of culumns to use */
// w = (int)sqrt((double)card[i].mixer[j].info.elements);
w = (int)(1.5 *
(float)card[i].mixer[j].info.elements /
(float)card[i].mixer[j].info.groups);
if (w == 0)
col = 0;
else
/* Compute the number of groups in a column */
col = (card[i].mixer[j].info.groups + w - 1)/ w;
/* Create the main bounding box */
hbox = gtk_hbox_new(FALSE, 0);
gtk_widget_show(hbox);
/* Make a vertical box for each column, then put that column's worth
of mixer groups into the column */
for(l = 0; l < w; l++) {
/* Make the vertical box to pack it in */
vbox = gtk_vbox_new(FALSE, 0);
gtk_widget_show(vbox);
gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 0);
for(m = 0; m < col && k < card[i].mixer[j].info.groups; m++) {
/* Make the group frame */
frame = gtk_frame_new(card[i].mixer[j].group[k].group.gid.name);
gtk_widget_show(frame);
gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
gtk_container_add(GTK_CONTAINER(frame),
group_elements(card_num,
mixer_num,
&card[i].mixer[j].group[k]));
/* Now increment the count of which mixer group we're on */
k++;
}
}
return hbox;
}
GtkWidget *group_elements(int card_num, int mixer, Group *group)
{
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *label;
GtkWidget *box;
GtkWidget *widget;
char thor[128];
int i, j;
snd_mixer_element_t test;
vbox = gtk_vbox_new(FALSE, 0);
gtk_widget_show(vbox);
for(i = 0; i < group->group.elements; i++) {
/* Each element gets its own horizontal box */
hbox=gtk_hbox_new(FALSE, 0);
gtk_widget_show(hbox);
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
snprintf(thor, 128, "%s routed to the %s",
group->group.pelements[i].name,
group->routes[i].proutes[0].name);
/* label = gtk_label_new(thor); */
/* gtk_widget_show(label); */
/* gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); */
switch(group->group.pelements[i].type){
case SND_MIXER_ETYPE_VOLUME1:
gtk_box_pack_end(GTK_BOX(hbox),
display_volume1(group, i,
card[card_num].mixer[mixer].handle,
thor),
FALSE, FALSE, 0);
break;
case SND_MIXER_ETYPE_SWITCH1:
gtk_box_pack_end(GTK_BOX(hbox),
display_switch1(group, i,
card[card_num].mixer[mixer].handle,
thor),
FALSE, FALSE, 0);
break;
case SND_MIXER_ETYPE_SWITCH2:
gtk_box_pack_end(GTK_BOX(hbox),
display_switch2(group, i,
card[card_num].mixer[mixer].handle,
thor),
FALSE, FALSE, 0);
break;
case SND_MIXER_ETYPE_3D_EFFECT1:
gtk_box_pack_end(GTK_BOX(hbox),
display_3deffect1(group, i,
card[card_num].mixer[mixer].handle,
thor),
FALSE, FALSE, 0);
break;
}
}
return vbox;
}
GtkWidget *display_3deffect1(Group *group, int element, void *handle, char *route)
{
GtkWidget *vbox;
GtkWidget *box;
GtkTooltips *tooltips;
GtkWidget *widget;
GtkWidget *label;
int i=element;
GtkObject *adj;
vbox = gtk_vbox_new(FALSE, 0);
gtk_widget_show(vbox);
group->gtk[i].interface = calloc(10, sizeof(GtkWidget *));
group->gtk[i].adjust = calloc(10, sizeof(GtkWidget *));
/* The on/off switch */
if(group->einfo[i].data.teffect1.effect & SND_MIXER_EFF1_SW) {
box = gtk_hbox_new(FALSE, 0);
gtk_widget_show(box);
gtk_box_pack_start(GTK_BOX(vbox), box, FALSE, FALSE, 0);
label = gtk_label_new("3D Effect");
gtk_widget_show(label);
gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0);
widget = gtk_check_button_new();
if(group->element[i].data.teffect1.sw)
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(widget), TRUE);
gtk_widget_show(widget);
gtk_box_pack_end(GTK_BOX(box), widget, FALSE, FALSE, 0);
/* Connect it to the callback */
gtk_signal_connect(GTK_OBJECT(widget), "toggled",
GTK_SIGNAL_FUNC(adjust_teffect1),
create_cb_data(group, handle, i, TYPE_SW));
}
/* The mono switch */
if(group->einfo[i].data.teffect1.effect & SND_MIXER_EFF1_MONO_SW) {
box = gtk_hbox_new(FALSE, 0);
gtk_widget_show(box);
gtk_box_pack_start(GTK_BOX(vbox), box, FALSE, FALSE, 0);
label = gtk_label_new("3D Effect Mono");
gtk_widget_show(label);
gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0);
widget = gtk_check_button_new();
if(group->element[i].data.teffect1.sw)
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(widget), TRUE);
gtk_widget_show(widget);
gtk_box_pack_end(GTK_BOX(box), widget, FALSE, FALSE, 0);
/* Connect it to the callback */
gtk_signal_connect(GTK_OBJECT(widget), "toggled",
GTK_SIGNAL_FUNC(adjust_teffect1),
create_cb_data(group, handle, i, TYPE_MONO_SW));
}
/* the wide control */
if(group->einfo[i].data.teffect1.effect & SND_MIXER_EFF1_WIDE) {
box = gtk_hbox_new(FALSE, 0);
gtk_widget_show(box);
gtk_box_pack_start(GTK_BOX(vbox), box, FALSE, FALSE, 0);
label = gtk_label_new("3D Effect Width");
gtk_widget_show(label);
gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0);
adj = gtk_adjustment_new(group->element[i].data.teffect1.wide,
group->einfo[i].data.teffect1.min_wide,
group->einfo[i].data.teffect1.max_wide,
1.0,
3.0,
0.0);
widget = gtk_hscale_new(GTK_ADJUSTMENT(adj));
gtk_scale_set_value_pos(GTK_SCALE(widget),
GTK_POS_RIGHT);
gtk_widget_set_usize(widget, 100, -1);
gtk_widget_show(widget);
gtk_box_pack_end(GTK_BOX(box), widget, FALSE, FALSE, 0);
/* connect the signal */
gtk_signal_connect(GTK_OBJECT(adj),
"value_changed",
GTK_SIGNAL_FUNC (adjust_teffect1),
create_cb_data(group, handle, i, TYPE_WIDE));
}
/* the volume widget */
if(group->einfo[i].data.teffect1.effect & SND_MIXER_EFF1_VOLUME) {
box = gtk_hbox_new(FALSE, 0);
gtk_widget_show(box);
gtk_box_pack_start(GTK_BOX(vbox), box, FALSE, FALSE, 0);
label = gtk_label_new("3D Effect Volume");
gtk_widget_show(label);
gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0);
adj = gtk_adjustment_new(group->element[i].data.teffect1.volume,
group->einfo[i].data.teffect1.min_volume,
group->einfo[i].data.teffect1.max_volume,
1.0,
3.0,
0.0);
widget = gtk_hscale_new(GTK_ADJUSTMENT(adj));
gtk_scale_set_value_pos(GTK_SCALE(widget),
GTK_POS_RIGHT);
gtk_widget_set_usize(widget, 100, -1);
gtk_widget_show(widget);
gtk_box_pack_end(GTK_BOX(box), widget, FALSE, FALSE, 0);
/* connect the signal */
gtk_signal_connect(GTK_OBJECT(adj),
"value_changed",
GTK_SIGNAL_FUNC (adjust_teffect1),
create_cb_data(group, handle, i, TYPE_VOLUME));
}
/* The center widget */
if(group->einfo[i].data.teffect1.effect & SND_MIXER_EFF1_CENTER) {
box = gtk_hbox_new(FALSE, 0);
gtk_widget_show(box);
gtk_box_pack_start(GTK_BOX(vbox), box, FALSE, FALSE, 0);
label = gtk_label_new("3D Effect Center");
gtk_widget_show(label);
gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0);
adj = gtk_adjustment_new(group->element[i].data.teffect1.center,
group->einfo[i].data.teffect1.min_center,
group->einfo[i].data.teffect1.max_center,
1.0,
3.0,
0.0);
widget = gtk_hscale_new(GTK_ADJUSTMENT(adj));
gtk_scale_set_value_pos(GTK_SCALE(widget),
GTK_POS_RIGHT);
gtk_widget_set_usize(widget, 100, -1);
gtk_widget_show(widget);
gtk_box_pack_end(GTK_BOX(box), widget, FALSE, FALSE, 0);
gtk_signal_connect(GTK_OBJECT(adj),
"value_changed",
GTK_SIGNAL_FUNC (adjust_teffect1),
create_cb_data(group, handle, i, TYPE_CENTER));
}
/* The Space widget */
if(group->einfo[i].data.teffect1.effect & SND_MIXER_EFF1_SPACE) {
box = gtk_hbox_new(FALSE, 0);
gtk_widget_show(box);
gtk_box_pack_start(GTK_BOX(vbox), box, FALSE, FALSE, 0);
label = gtk_label_new("3D Effect Space");
gtk_widget_show(label);
gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0);
adj = gtk_adjustment_new(group->element[i].data.teffect1.space,
group->einfo[i].data.teffect1.min_space,
group->einfo[i].data.teffect1.max_space,
1.0,
3.0,
0.0);
widget = gtk_hscale_new(GTK_ADJUSTMENT(adj));
gtk_scale_set_value_pos(GTK_SCALE(widget),
GTK_POS_RIGHT);
gtk_widget_set_usize(widget, 100, -1);
gtk_widget_show(widget);
gtk_box_pack_end(GTK_BOX(box), widget, FALSE, FALSE, 0);
gtk_signal_connect(GTK_OBJECT(adj),
"value_changed",
GTK_SIGNAL_FUNC (adjust_teffect1),
create_cb_data(group, handle, i, TYPE_SPACE));
}
/* The depth widget */
if(group->einfo[i].data.teffect1.effect & SND_MIXER_EFF1_DEPTH) {
box = gtk_hbox_new(FALSE, 0);
gtk_widget_show(box);
gtk_box_pack_start(GTK_BOX(vbox), box, FALSE, FALSE, 0);
label = gtk_label_new("3D Effect Depth");
gtk_widget_show(label);
gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0);
adj = gtk_adjustment_new(group->element[i].data.teffect1.depth,
group->einfo[i].data.teffect1.min_depth,
group->einfo[i].data.teffect1.max_depth,
1.0,
3.0,
0.0);
widget = gtk_hscale_new(GTK_ADJUSTMENT(adj));
gtk_scale_set_value_pos(GTK_SCALE(widget),
GTK_POS_RIGHT);
gtk_widget_set_usize(widget, 100, -1);
gtk_widget_show(widget);
gtk_box_pack_end(GTK_BOX(box), widget, FALSE, FALSE, 0);
gtk_signal_connect(GTK_OBJECT(adj),
"value_changed",
GTK_SIGNAL_FUNC (adjust_teffect1),
create_cb_data(group, handle, i, TYPE_DEPTH));
}
/* The delay widget */
if(group->einfo[i].data.teffect1.effect & SND_MIXER_EFF1_DELAY) {
box = gtk_hbox_new(FALSE, 0);
gtk_widget_show(box);
gtk_box_pack_start(GTK_BOX(vbox), box, FALSE, FALSE, 0);
label = gtk_label_new("3D Effect Delay");
gtk_widget_show(label);
gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0);
adj = gtk_adjustment_new(group->element[i].data.teffect1.delay,
group->einfo[i].data.teffect1.min_delay,
group->einfo[i].data.teffect1.max_delay,
1.0,
3.0,
0.0);
widget = gtk_hscale_new(GTK_ADJUSTMENT(adj));
gtk_scale_set_value_pos(GTK_SCALE(widget),
GTK_POS_RIGHT);
gtk_widget_set_usize(widget, 100, -1);
gtk_widget_show(widget);
gtk_box_pack_end(GTK_BOX(box), widget, FALSE, FALSE, 0);
gtk_signal_connect(GTK_OBJECT(adj),
"value_changed",
GTK_SIGNAL_FUNC (adjust_teffect1),
create_cb_data(group, handle, i, TYPE_DELAY));
}
/* The feedback widget */
if(group->einfo[i].data.teffect1.effect & SND_MIXER_EFF1_FEEDBACK) {
box = gtk_hbox_new(FALSE, 0);
gtk_widget_show(box);
gtk_box_pack_start(GTK_BOX(vbox), box, FALSE, FALSE, 0);
label = gtk_label_new("3D Effect Feedback");
gtk_widget_show(label);
gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0);
adj = gtk_adjustment_new(group->element[i].data.teffect1.feedback,
group->einfo[i].data.teffect1.min_feedback,
group->einfo[i].data.teffect1.max_feedback,
1.0,
3.0,
0.0);
widget = gtk_hscale_new(GTK_ADJUSTMENT(adj));
gtk_scale_set_value_pos(GTK_SCALE(widget),
GTK_POS_RIGHT);
gtk_widget_set_usize(widget, 100, -1);
gtk_widget_show(widget);
gtk_box_pack_end(GTK_BOX(box), widget, FALSE, FALSE, 0);
gtk_signal_connect(GTK_OBJECT(adj),
"value_changed",
GTK_SIGNAL_FUNC (adjust_teffect1),
create_cb_data(group, handle, i, TYPE_FEEDBACK));
}
return vbox;
}
GtkWidget *display_switch1(Group *group, int element, void *handle, char *route)
{
GtkWidget *box;
GtkTooltips *tooltips;
GtkWidget *button;
int i, j;
i = element;
box = gtk_hbox_new(FALSE, 0);
gtk_widget_show(box);
/* Allocate the widget array */
group->gtk[i].interface = calloc(group->element[i].data.switch1.sw, sizeof(GtkWidget *));
for(j = 0; j < group->element[i].data.switch1.sw; j++) {
button = gtk_check_button_new();
/* looks painful, doesn't it? It's checking the state of the appropriate bit */
if(group->element[i].data.switch1.psw[j / sizeof(unsigned int)] &
(1 << (j % sizeof(unsigned int))))
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON (button), TRUE);
gtk_widget_show(button);
/* Set up the tooltips */
tooltips = gtk_tooltips_new();
gtk_tooltips_set_tip (tooltips, button, route, NULL);
gtk_box_pack_start(GTK_BOX (box), button, FALSE, FALSE, 0);
/* Connect it to the callback */
gtk_signal_connect(GTK_OBJECT(button), "toggled",
GTK_SIGNAL_FUNC(adjust_switch1),
create_cb_data(group, handle, i, j));
/* Store the widget */
group->gtk[i].interface[j] = button;
}
return box;
}
GtkWidget *display_switch2(Group *group, int element, void *handle, char *route)
{
GtkWidget *button;
GtkTooltips *tooltips;
int i, j=0;
i = element;
if(!group) {
printf("Group isn't initialized!\n");
return NULL;
}
button = gtk_check_button_new();
if(group->element)
if(group->element[i].data.switch2.sw) {
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), TRUE);
}
gtk_widget_show(button);
/* Set up the tooltip */
tooltips = gtk_tooltips_new();
gtk_tooltips_set_tip (tooltips, button, route, NULL);
if(group->gtk) {
group->gtk[i].interface = calloc(1, sizeof(GtkWidget *));
group->gtk[i].interface[j] = button;
} else {
printf("Something wasn't initialized properly.\n");
}
/* Connect it to the callback */
gtk_signal_connect(GTK_OBJECT(group->gtk[i].interface[j]),
"toggled",
GTK_SIGNAL_FUNC (adjust_switch2),
create_cb_data(group, handle, element, j));
return button;
}
GtkWidget *display_volume1(Group *group, int element, void *handle, char *route)
{
GtkWidget *box;
GtkTooltips *tooltips;
int i,j;
i = element;
box = gtk_vbox_new(FALSE, 0);
gtk_widget_show(box);
group->gtk[i].adjust = calloc(group->element[i].data.volume1.voices,
sizeof(GtkObject *));
group->gtk[i].interface = calloc(group->element[i].data.volume1.voices,
sizeof(GtkWidget *));
for(j=0; j < group->element[i].data.volume1.voices; j++) {
group->gtk[i].adjust[j] =
gtk_adjustment_new(group->element[i].data.volume1.pvoices[j],
group->einfo[i].data.volume1.prange[0].min,
group->einfo[i].data.volume1.prange[0].max,
1.0,
3.0,
0.0);
group->gtk[i].interface[j] =
gtk_hscale_new(GTK_ADJUSTMENT(group->gtk[i].adjust[j]));
gtk_signal_connect(GTK_OBJECT(group->gtk[i].adjust[j]),
"value_changed",
GTK_SIGNAL_FUNC (adjust_volume1),
create_cb_data(group, handle, element, j));
/* gtk_scale_set_draw_value(GTK_SCALE(group->gtk[i].interface[j]), */
/* FALSE); */
gtk_scale_set_value_pos(GTK_SCALE(group->gtk[i].interface[j]),
GTK_POS_RIGHT);
gtk_widget_set_usize(group->gtk[i].interface[j], 100, -1);
gtk_widget_show(group->gtk[i].interface[j]);
gtk_box_pack_start(GTK_BOX(box),
group->gtk[i].interface[j],
FALSE, FALSE, 0);
/* Set up the tooltip */
tooltips = gtk_tooltips_new();
gtk_tooltips_set_tip (tooltips, group->gtk[i].interface[j], route, NULL);
}
return box;
}

View file

@ -1,33 +0,0 @@
/*****************************************************************************/
/* Begin #include statements */
/* End #include statements */
/*****************************************************************************/
/*****************************************************************************/
/* Begin function prototypes */
GtkWidget *create_mixer_page(int card_num, int mixer_num);
/* End function prototypes */
/*****************************************************************************/
/*****************************************************************************/
/* Begin #define statements */
/* These types are for the callback data identification */
#define TYPE_EFFECT 0
#define TYPE_SW 1
#define TYPE_MONO_SW 2
#define TYPE_WIDE 3
#define TYPE_VOLUME 4
#define TYPE_CENTER 5
#define TYPE_SPACE 6
#define TYPE_DEPTH 7
#define TYPE_DELAY 8
#define TYPE_FEEDBACK 9
/* End #define statements */
/*****************************************************************************/

View file

View file

@ -1,95 +0,0 @@
/*****************************************************************************/
/* Begin system #includes */
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <math.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/asoundlib.h>
#include <gtk/gtk.h>
/* End system #includes */
/*****************************************************************************/
/*****************************************************************************/
/* Begin program #includes */
#include "structs.h"
#include "util.h"
#include "xamixer2.h"
#include "cinit.h"
#include "callbacks.h"
#include "display.h"
#include "config.h"
#include "switches.h"
#include "options.h"
/* End program #includes */
/*****************************************************************************/
/*****************************************************************************/
/* Begin #defines */
#define CHANNEL_LEFT (1 << 0)
#define CHANNEL_RIGHT (1 << 1)
#define CHANNEL_MONO (1 << 2)
#define CHANNEL_MUTE_RIGHT (1 << 3)
#define CHANNEL_MUTE_LEFT (1 << 4)
#define CHANNEL_MUTE_MONO (1 << 5)
#define CHANNEL_RECORD (1 << 6)
#define CHANNEL_RECORD_RIGHT (1 << 7)
#define CHANNEL_RECORD_LEFT (1 << 8)
#define CHANNEL_SIMULTANEOUS (1 << 9)
#define CHANNEL_DISPLAYED (1 << 10)
#define CHANNEL_LTOR (1 << 11)
#define CHANNEL_RTOL (1 << 12)
#define CONFIG_USE_XPMS (1 << 0)
#define CONFIG_ICON_XPM (1 << 1)
#define CONFIG_MUTE_XPM (1 << 2)
#define CONFIG_MUTE_XPM_L (1 << 3)
#define CONFIG_UNMUTE_XPM (1 << 4)
#define CONFIG_UNMUTE_XPM_L (1 << 5)
#define CONFIG_REC_XPM (1 << 6)
#define CONFIG_UNREC_XPM (1 << 7)
#define CONFIG_SIMUL_XPM (1 << 8)
#define CONFIG_UNSIMUL_XPM (1 << 9)
#define CONFIG_LTOR_XPM (1 << 10)
#define CONFIG_UNLTOR_XPM (1 << 11)
#define CONFIG_RTOL_XPM (1 << 12)
#define CONFIG_UNRTOL_XPM (1 << 13)
#define CONFIG_BACKGROUND_XPM (1 << 14)
#define CONFIG_SHOW_CARD_NAME (1 << 15)
#define CONFIG_SHOW_MIXER_NUMBER (1 << 16)
#define CONFIG_SHOW_MIXER_NAME (1 << 17)
#define CONFIG_SWITCHES_HIDDEN (1 << 18)
/* End #defines */
/*****************************************************************************/
/*****************************************************************************/
/* Gtk 1.0 compatability */
#ifndef GTK_HAVE_FEATURES_1_1_0
#define gtk_button_set_relief(a,b)
#endif
/* End Gtk 1.0 compatability */
/*****************************************************************************/

View file

View file

View file

@ -1,137 +0,0 @@
/******************************************************************************/
/* Begin Structures */
struct _Gtk_Channel
{
GtkWidget **interface; /* And array of the interfaces (slider, button, etc.) */
GtkObject **adjust; /* An array of the adjustments */
};
typedef struct _Gtk_Channel Gtk_Channel;
struct _Group
{
snd_mixer_group_t group; /* The group structure */
snd_mixer_element_t *element; /* an array of all the elements in the group */
snd_mixer_element_info_t *einfo; /* an array of the info about all of the elements */
snd_mixer_routes_t *routes; /* an array of all the routes for the elements */
Gtk_Channel *gtk; /* The Gtk+ widgets used for each mixer element */
};
typedef struct _Group Group;
struct _Mixer
{
int number; /* The number of the mixer device */
snd_mixer_t *handle;
snd_mixer_info_t info; /* The info for the mixer */
int cnum; /* The number of channels present */
int snum; /* The number of mixer switches present */
snd_mixer_groups_t groups; /* The mixer groups */
Group *group; /* An array of the mixer groups */
char name[80]; /* The name of the mixer */
GtkWidget *switch_table;
};
typedef struct _Mixer Mixer;
struct _Card
{
snd_ctl_hw_info_t hw_info; /* The hardware info about the card. */
int number; /* The card's number */
void *handle; /* The handle for the mixer */
char name[80]; /* The name of the card */
Mixer *mixer; /* A dynamic array of all of the mixers */
int nmixers; /* The number of mixers on the card */
int npcms; /* The number of pcm devices */
};
typedef struct _Card Card;
struct _MixerInfo
{
Mixer *mixer; /* Which card */
int channel; /* Which channel */
unsigned int flags; /* flags */
GtkWidget *other; /* The other range widget */
GtkWidget *mute; /* The mute pixmap */
GtkWidget *unmute; /* The unmute pixmap */
};
typedef struct _MixerInfo MixerInfo;
struct _ChannelLabel
{
struct _ChannelLabel *next; /* pointer to the next node in the list */
char *channel; /* The channel name */
char *label; /* The channel label or pixmap */
};
typedef struct _ChannelLabel ChannelLabel;
struct _CBData
{
Group *group; /* The group */
void *handle; /* The mixer handle */
int element; /* The element number to use as an index */
int index; /* The index such as the voice # or something like that */
};
typedef struct _CBData CBData;
struct _Config
{
unsigned int flags; /* Flags */
ChannelLabel *labels; /* The text labels for channels */
ChannelLabel *xpm; /* The pixmaps (file names) for channels */
char *icon; /* The Icon pixmap to use */
char *mute; /* The mute label or pixmap (indicated in a flag) */
char *mute_l; /* The left mute label or pixmap (indicated in a flag) */
char *unmute; /* The unmute label or pixmap (indicated in a flag) */
char *unmute_l; /* The left unmute label or pixmap (indicated in a flag) */
char *simul; /* The simultaneous label or pixmap (indicated in a flag */
char *unsimul; /* The unsimultaneous label or pixmap (indicated in a flag */
char *rec; /* The record label or pixmap (indicated in a flag) */
char *unrec; /* The unrecord label or pixmap (indicated in a flag) */
char *background; /* The background xpm */
unsigned int scale; /* The size in pixels that the scales should be set to */
unsigned int padding; /* The padding between channels */
int x_pos, y_pos; /* The position to start out at -1 = default */
GtkWidget *cdisplay; /* The channel display window */
GdkPixmap *icon_xpm; /* The icon xpm */
GdkPixmap *mute_xpm; /* The mute pixmap */
GdkPixmap *unmute_xpm; /* The unmute pixmap */
GdkPixmap *mute_xpm_l; /* The left mute pixmap */
GdkPixmap *unmute_xpm_l; /* The left unmute pixmap */
GdkPixmap *rec_xpm; /* The record pixmap */
GdkPixmap *unrec_xpm; /* The record off pixmap */
GdkPixmap *simul_xpm; /* The sumultaneous pixmap */
GdkPixmap *unsimul_xpm; /* The independent pixmap */
GdkPixmap *background_xpm; /* The background pixmap */
GdkBitmap *icon_mask;
GdkBitmap *mute_mask;
GdkBitmap *unmute_mask;
GdkBitmap *mute_mask_l;
GdkBitmap *unmute_mask_l;
GdkBitmap *rec_mask;
GdkBitmap *unrec_mask;
GdkBitmap *simul_mask;
GdkBitmap *unsimul_mask;
GdkBitmap *background_mask;
};
typedef struct _Config Config;
/* End Structures */
/******************************************************************************/
/******************************************************************************/
/* Begin type macros */
#define MIXER(x) ((Mixer *)(x))
#define CARD(x) ((Card *)(x))
/* End type macros */
/******************************************************************************/

View file

View file

View file

@ -1,31 +0,0 @@
#include <gtk/gtk.h>
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char **argv)
{
GtkWidget *window;
GtkWidget *scale;
GtkObject *adj;
gtk_init(&argc, &argv);
window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
adj = gtk_adjustment_new(1.0,
0.0,
110.0,
1.0,
4.0,
0.0);
scale = gtk_hscale_new(GTK_ADJUSTMENT(adj));
gtk_widget_show(scale);
gtk_container_add(GTK_CONTAINER(window), scale);
gtk_widget_show(window);
gtk_main();
return 0;
}

View file

@ -1,11 +0,0 @@
#include <stdio.h>
main()
{
printf("The value is %i\n", ~(1 << 1));
return 0;
}

View file

@ -1,173 +0,0 @@
/*****************************************************************************
xamixer.c - an Alsa based gtk mixer
Written by Raistlinn (lansdoct@cs.alfred.edu)
Copyright (C) 1998 by Christopher Lansdown
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
******************************************************************************/
/*****************************************************************************/
/* Begin #include's */
#include "main.h"
/* End #include's */
/*****************************************************************************/
extern Config config; /* The system config */
int is_same(char *string1, char *string2)
{
int i = 0;
if(strlen(string1) != strlen(string2))
return 0;
while(string1[i] != '\0')
if(string1[i] != string2[i])
return 0;
else
i++;
return 1;
}
void strip_comment(char *string)
{
char *place;
int i = 0, j = 0, size;
size = strlen(string);
/* Get wrid of the comments */
place = string;
while((place = strchr(place, '#'))){
if(string[(place - string) -1] != '\\')
*place = '\0';
place++;
}
/* Replace the escape sequences */
place = calloc(1, strlen(string));
while(string[i] != '\0'){
if(string[i] == '\\')
place[j] = string[++i];
else
place[j] = string[i];
i++;
j++;
}
EAZERO(string, size);
strncpy(string, place, size);
free(place);
return;
}
int is_comment(char *string)
{
int i=0;
while (string[i] != '\0'){
if (string[i] == '#')
return 1;
if (string[i] != ' ' && string[i] != '\t')
return 0;
i++;
}
return 0;
}
ChannelLabel *channel_label_append(ChannelLabel *head, char *channel, char *label)
{
ChannelLabel *tmp;
tmp = calloc(1, sizeof(ChannelLabel));
tmp->next = head;
tmp->channel = calloc(strlen(channel) + 1, sizeof(char));
strcpy(tmp->channel, channel);
tmp->label = calloc(strlen(label) + 1, sizeof(char));
strcpy(tmp->label, label);
return tmp;
}
int get_label(char *line, char *expect, char *value1, size_t value1_len,
char *value2, size_t value2_len, char quote1, char quote2)
{
char *tmp;
int len, i;
len = strlen(line);
if(expect) {
tmp = strstr(line, expect);
if(!tmp)
return FALSE;
tmp = &tmp[strlen(expect)];
}
else
tmp = line;
tmp = strchr(tmp, quote1) + 1;
if(!tmp)
return FALSE;
for(i = 0; i < (value1_len - 1) && tmp[i] != quote2; i++)
value1[i] = tmp[i];
value1[i] = '\0';
tmp = strchr(tmp, quote1) + 1;
if(!tmp)
return FALSE;
for(i = 0; i < (value2_len - 1) && tmp[i] != quote2; i++)
value2[i] = tmp[i];
value2[i] = '\0';
return TRUE;
}
MixerInfo *create_mixer_info(Mixer *mixer, int num, unsigned int flags)
{
MixerInfo *info;
info = calloc(1, sizeof(MixerInfo));
info->mixer = mixer;
info->channel = num;
info->flags = flags;
info->other = NULL;
info->mute = NULL;
info->unmute = NULL;
return info;
}
CBData *create_cb_data(Group *group, void *handle, int element, int index)
{
CBData *data;
data = malloc(sizeof(CBData));
data->group = group;
data->handle = handle;
data->element = element;
data->index = index;
return data;
}

View file

@ -1,37 +0,0 @@
/*****************************************************************************/
/* Begin #include statements */
/* End #include statements */
/*****************************************************************************/
/*****************************************************************************/
/* Begin function prototypes */
int is_same(char *string1, char *string2);
void strip_comment(char *string);
int is_comment(char *string);
ChannelLabel *channel_label_append(ChannelLabel *head, char *channel, char *label);
int get_label(char *line, char *expect, char *value1, size_t value1_len,
char *value2, size_t value2_len, char quote1, char quote2);
MixerInfo *create_mixer_info(Mixer *mixer, int num, unsigned int flags);
CBData *create_cb_data(Group *group, void *handle, int element, int index);
/* End function prototypes */
/*****************************************************************************/
/*****************************************************************************/
/* Begin #define statements */
/* End #define statements */
/*****************************************************************************/
/*****************************************************************************/
/* Begin Macros */
#define EAZERO(S, L) S[L-1] = '\0';
/* End Macros */
/*****************************************************************************/

View file

@ -1,47 +0,0 @@
# XAmixer home file
# Comments are preceded anywhere on the line by a '#'
# All channel arguments (string & pixmap) must be enclosed in [ ] [ ]
UseXpms
#IgnoreXpms
ScaleSize 115
ChannelPadding 5
Position -1 -1 # Both arguments must be set (and >= 0) to get positioning.
ShowCardName
#ShowMixerNumber
#ShowMixerName
#MuteLabel Mute
#RecLabel Record
RecLabel R
#SimulLabel Lock
#BackgroundXpm /usr/local/share/xamixer/pixmaps/test.xpm
#BackgroundXpm /home/raistlin/xamixer/pixmaps/background5.xpm
#BackgroundXpm /home/raistlin/xamixer/pixmaps/background.xpm
#BackgroundXpm /tmp/background.xpm
IconXpm /usr/local/share/xamixer/pixmaps/icon3.xpm
#MuteXpm /usr/local/share/xamixer/pixmaps/mute3.xpm
#unMuteXpm /usr/local/share/xamixer/pixmaps/unmute3.xpm
MuteXpm /usr/local/share/xamixer/pixmaps/mute3.xpm
unMuteXpm /usr/local/share/xamixer/pixmaps/unmute3.xpm
#RecXpm /usr/local/share/xamixer/pixmaps/record.xpm
#unRecXpm /usr/local/share/xamixer/pixmaps/unrecord.xpm
RecXpm /usr/local/share/xamixer/pixmaps/rec.xpm
unRecXpm /usr/local/share/xamixer/pixmaps/unrec.xpm
#RecXpm /home/raistlin/xamixer/pixmaps/record.xpm
#unRecXpm /home/raistlin/xamixer/pixmaps/unrecord.xpm
SimulXpm /usr/local/share/xamixer/pixmaps/simul.xpm
unSimulXpm /usr/local/share/xamixer/pixmaps/unsimul.xpm
Label [Master] [Mstr]
Label [Master M] [MstrM]
Label [Line-In] [LineIn]
Label [Record-Gain] [RGain]
Label [PC Speaker] [Spkr]
Label [Aux A] [AuxA]
Label [In-Gain] [IGain]
Label [Out-Gain] [OGain]
Xpm [Master] [/usr/local/share/xamixer/pixmaps/master.xpm]
Xpm [CD] [/usr/local/share/xamixer/pixmaps/cd.xpm]
Xpm [MIC] [/usr/local/share/xamixer/pixmaps/mic.xpm]
Xpm [PCM] [/usr/local/share/xamixer/pixmaps/pcm.xpm]
Xpm [Synth] [/usr/local/share/xamixer/pixmaps/synth.xpm]
Xpm [Line-In] [/usr/local/share/xamixer/pixmaps/line-in.xpm]
Xpm [PC Speaker] [/usr/local/share/xamixer/pixmaps/speaker.xpm]

View file

@ -1,47 +0,0 @@
# XAmixer home file
# Comments are preceded anywhere on the line by a '#'
# All channel arguments (string & pixmap) must be enclosed in [ ] [ ]
UseXpms
#IgnoreXpms
ScaleSize 115
ChannelPadding 5
Position -1 -1 # Both arguments must be set (and >= 0) to get positioning.
ShowCardName
#ShowMixerNumber
#ShowMixerName
#MuteLabel Mute
#RecLabel Record
RecLabel R
#SimulLabel Lock
#BackgroundXpm /usr/local/share/xamixer/pixmaps/test.xpm
#BackgroundXpm /home/raistlin/xamixer/pixmaps/background5.xpm
#BackgroundXpm /home/raistlin/xamixer/pixmaps/background.xpm
#BackgroundXpm /tmp/background.xpm
IconXpm /usr/local/share/xamixer/pixmaps/icon3.xpm
#MuteXpm /usr/local/share/xamixer/pixmaps/mute3.xpm
#unMuteXpm /usr/local/share/xamixer/pixmaps/unmute3.xpm
MuteXpm /usr/local/share/xamixer/pixmaps/mute3.xpm
unMuteXpm /usr/local/share/xamixer/pixmaps/unmute3.xpm
#RecXpm /usr/local/share/xamixer/pixmaps/record.xpm
#unRecXpm /usr/local/share/xamixer/pixmaps/unrecord.xpm
RecXpm /usr/local/share/xamixer/pixmaps/rec.xpm
unRecXpm /usr/local/share/xamixer/pixmaps/unrec.xpm
#RecXpm /home/raistlin/xamixer/pixmaps/record.xpm
#unRecXpm /home/raistlin/xamixer/pixmaps/unrecord.xpm
SimulXpm /usr/local/share/xamixer/pixmaps/simul.xpm
unSimulXpm /usr/local/share/xamixer/pixmaps/unsimul.xpm
Label [Master] [Mstr]
Label [Master M] [MstrM]
Label [Line-In] [LineIn]
Label [Record-Gain] [RGain]
Label [PC Speaker] [Spkr]
Label [Aux A] [AuxA]
Label [In-Gain] [IGain]
Label [Out-Gain] [OGain]
Xpm [Master] [/usr/local/share/xamixer/pixmaps/master.xpm]
Xpm [CD] [/usr/local/share/xamixer/pixmaps/cd.xpm]
Xpm [MIC] [/usr/local/share/xamixer/pixmaps/mic.xpm]
Xpm [PCM] [/usr/local/share/xamixer/pixmaps/pcm.xpm]
Xpm [Synth] [/usr/local/share/xamixer/pixmaps/synth.xpm]
Xpm [Line-In] [/usr/local/share/xamixer/pixmaps/line-in.xpm]
Xpm [PC Speaker] [/usr/local/share/xamixer/pixmaps/speaker.xpm]

View file

@ -1,198 +0,0 @@
/*****************************************************************************
xamixer.c - an Alsa based gtk mixer
Written by Raistlinn (lansdoct@cs.alfred.edu)
Copyright (C) 1998 by Christopher Lansdown
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
******************************************************************************/
/*****************************************************************************/
/* Begin #include's */
#include "main.h"
/* End #include's */
/*****************************************************************************/
/*****************************************************************************/
/* Begin Global Variables */
GtkWidget *window;
Card *card; /* And array of the cards */
int cards; /* The number of cards in the system. */
extern Config config; /* The system config */
/* End Global Variables */
/*****************************************************************************/
int main(int argc, char **argv)
{
/* Begin Variable Declarations */
GtkWidget *mainbox;
GtkWidget *notebook;
GtkWidget *frame;
GtkWidget *label;
GtkWidget *table;
GtkWidget *switch_button;
GtkWidget *tmpbox;
GtkWidget *tablebox;
GtkWidget *separator;
int i,j,k,xpm,found,fd;
char title[64];
char name[128];
ChannelLabel *tmp;
char labelname[256];
char *home_env, *home_dir;
GtkStyle *style;
GtkWidget *hbox;
snd_mixer_filter_t mixer_filter;
/* End Variable Declarations */
/* Go through gtk initialization */
gtk_init(&argc, &argv);
/* Read the personal config file - these values override the global config */
home_env = getenv("HOME");
home_dir = calloc((strlen(home_env) + 2 + strlen(RCFILE)), 1);
strcpy(home_dir, home_env);
strcat(home_dir, "/");
strcat(home_dir, RCFILE);
gtk_rc_parse(home_dir);
free(home_dir);
/* Read in the soundcard info */
if(init_cards()) {
printf("Error. Unable to initialize sound cards.\n");
return 1;
}
/* Read in normal config info */
config_init();
config_read("/usr/local/etc/xamixer.conf");
home_env = getenv("HOME");
home_dir = calloc((strlen(home_env) + 2 + strlen(HOME_FILE)), 1);
strcpy(home_dir, home_env);
strcat(home_dir, "/");
strcat(home_dir, HOME_FILE);
config_read(home_dir);
free(home_dir);
/* Make the title */
sprintf(title, "XAmixer2 %s", VERSION);
/* Create the main window */
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window), title);
gtk_signal_connect(GTK_OBJECT (window), "delete_event",
(GtkSignalFunc) gtk_main_quit, NULL);
signal(SIGINT, (void *)gtk_main_quit);
/* Set the policy */
gtk_window_set_policy(GTK_WINDOW (window), TRUE, TRUE, TRUE);
/* Set the position, if one has been defined */
gtk_widget_set_uposition(window, config.x_pos, config.y_pos);
/* Realize the window so that we can start drawing pixmaps to it */
gtk_widget_realize(window);
/* Set up the pixmaps */
setup_pixmaps(window);
/* Create the notebook */
notebook = gtk_notebook_new();
gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), GTK_POS_TOP);
gtk_widget_show(notebook);
gtk_container_add(GTK_CONTAINER(window), notebook);
/* Create the notebook pages */
for(i = 0; i < cards; i++) {
for(j = 0; j < card[i].hw_info.mixerdevs; j++) {
frame = create_mixer_page(i, j);
/* Create the label and add the page to the notebook */
bzero(labelname, 256);
if(config.flags & CONFIG_SHOW_CARD_NAME) {
strcpy(labelname, card[i].hw_info.name);
if(config.flags & (CONFIG_SHOW_MIXER_NAME |
CONFIG_SHOW_MIXER_NUMBER))
strcat(labelname, ", ");
}
if(config.flags & CONFIG_SHOW_MIXER_NUMBER) {
/* Do some trickery to get around an additional
variable, plus this may be more efficient,
since strcat() has to figure out where the end
of the line is anyhow, plus the copying. */
sprintf(&labelname[strlen(labelname)], "Mixer %i", j);
if(config.flags & CONFIG_SHOW_MIXER_NAME)
strcat(labelname, ", ");
}
if(config.flags & CONFIG_SHOW_MIXER_NAME)
strcat(labelname, card[i].mixer[j].info.name);
/* Just in case nothing is specified in the config file */
if(!(config.flags & (CONFIG_SHOW_CARD_NAME |
CONFIG_SHOW_MIXER_NAME |
CONFIG_SHOW_MIXER_NUMBER)))
sprintf(labelname, "%i", i + j);
label = gtk_label_new(labelname);
gtk_widget_show(label);
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), frame, label);
}
}
/* Create the options page */
frame = gtk_frame_new("");
gtk_widget_show(frame);
// gtk_container_add(GTK_CONTAINER (frame), create_options_page());
label = gtk_label_new("Options");
gtk_widget_show(label);
gtk_notebook_append_page(GTK_NOTEBOOK (notebook), frame, label);
/* Set up the icon, if one has been defined. */
if(config.flags & CONFIG_ICON_XPM && config.icon_xpm)
gdk_window_set_icon(window->window, NULL,
config.icon_xpm, config.icon_mask);
/* Set up the update callback for every mixer */
for(i = 0; i < cards; i++)
for(j = 0; j < card[i].nmixers; j++)
gdk_input_add(snd_mixer_file_descriptor(card[i].mixer[j].handle),
GDK_INPUT_READ,
mixer_change_cb,
&card[i].mixer[j]);
/* Show the whole kit and kaboodle */
gtk_widget_show(window);
/* And go into the gtk loop - why does this feel like the first
plunge in a roller coaster after the big hill at the beginning? */
gtk_main();
return 0;
}

View file

@ -1,25 +0,0 @@
/*****************************************************************************/
/* Begin #include statements */
/* End #include statements */
/*****************************************************************************/
/*****************************************************************************/
/* Begin function prototypes */
/* End function prototypes */
/*****************************************************************************/
/*****************************************************************************/
/* Begin #define statements */
#define RCFILE ".xamixerrc"
#define VERSION "0.1.3"
/* End #define statements */
/*****************************************************************************/