diff --git a/xamixer2/callbacks.c b/xamixer2/callbacks.c index 55b17e8..917a661 100644 --- a/xamixer2/callbacks.c +++ b/xamixer2/callbacks.c @@ -37,6 +37,50 @@ 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) { diff --git a/xamixer2/callbacks.h b/xamixer2/callbacks.h index e96f73b..1575e80 100644 --- a/xamixer2/callbacks.h +++ b/xamixer2/callbacks.h @@ -14,6 +14,7 @@ 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 */ /*****************************************************************************/ diff --git a/xamixer2/cinit.c b/xamixer2/cinit.c index c26dcfe..d8a1a63 100644 --- a/xamixer2/cinit.c +++ b/xamixer2/cinit.c @@ -77,7 +77,8 @@ int init_cards() 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)); diff --git a/xamixer2/structs.h b/xamixer2/structs.h index 4b019d2..5a0ecf6 100644 --- a/xamixer2/structs.h +++ b/xamixer2/structs.h @@ -125,34 +125,13 @@ typedef struct _Config Config; /******************************************************************************/ -#if 0 -struct _Channel -{ - int num; /* The channel's number */ - snd_mixer_channel_t data; /* the data */ - snd_mixer_channel_info_t info; /* The info */ - unsigned int flags; /* The Channel's flags */ - GtkWidget *lm, *rm, *mm, *rec; /* The associated widgets */ - GtkWidget *lrec, *rrec; /* More associated widgets */ - GtkObject *ladj, *radj, *madj; /* The associated objects */ - GtkTooltips *left_tt, *right_tt, *mono_tt; /* The tooltips */ - GtkWidget *lscal, *rscal, *mscal; /* The scale widgets */ - GtkWidget *label, *lock; - GtkWidget *ltor_in, *rtol_in; - void *mixer; /* A pointer to the mixer */ -}; -typedef struct _Channel Channel; -#endif - - - - - - - - - - - +/******************************************************************************/ +/* Begin type macros */ + +#define MIXER(x) ((Mixer *)(x)) +#define CARD(x) ((Card *)(x)) + +/* End type macros */ +/******************************************************************************/ diff --git a/xamixer2/util.h b/xamixer2/util.h index e97e83a..29790d7 100644 --- a/xamixer2/util.h +++ b/xamixer2/util.h @@ -31,7 +31,6 @@ CBData *create_cb_data(Group *group, void *handle, int element, int index); /* Begin Macros */ #define EAZERO(S, L) S[L-1] = '\0'; -#define MIXER(m) ((Mixer *)m) /* End Macros */ /*****************************************************************************/ diff --git a/xamixer2/xamixer2.c b/xamixer2/xamixer2.c index 75f25d7..606328e 100644 --- a/xamixer2/xamixer2.c +++ b/xamixer2/xamixer2.c @@ -58,6 +58,7 @@ int main(int argc, char **argv) char *home_env, *home_dir; GtkStyle *style; GtkWidget *hbox; + snd_mixer_filter_t mixer_filter; /* End Variable Declarations */ /* Go through gtk initialization */ @@ -177,6 +178,15 @@ int main(int argc, char **argv) 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);