Remove widgets from struct alsa_elem and add data to callbacks
Rather than having widget/widget2/widget_callback fields in the struct alsa_elem, have a list of callbacks and allow private data to be passed to callbacks.
This commit is contained in:
32
src/alsa.h
32
src/alsa.h
@@ -17,7 +17,7 @@ struct alsa_card;
|
||||
|
||||
// typedef for callbacks to update widgets when the alsa element
|
||||
// notifies of a change
|
||||
typedef void (AlsaElemCallback)(struct alsa_elem *);
|
||||
typedef void (AlsaElemCallback)(struct alsa_elem *, void *);
|
||||
|
||||
// port categories for routing_src and routing_snk entries
|
||||
// must match the level meter ordering from the driver
|
||||
@@ -92,6 +92,12 @@ struct routing_snk {
|
||||
// pointer back to the element this entry is associated with
|
||||
struct alsa_elem *elem;
|
||||
|
||||
// box widget on the routing page
|
||||
GtkWidget *box_widget;
|
||||
|
||||
// socket widget on the routing page
|
||||
GtkWidget *socket_widget;
|
||||
|
||||
// PC_DSP, PC_MIX, PC_PCM, or PC_HW
|
||||
int port_category;
|
||||
|
||||
@@ -103,6 +109,12 @@ struct routing_snk {
|
||||
GtkWidget *mixer_label_bottom;
|
||||
};
|
||||
|
||||
// hold one callback & its data
|
||||
struct alsa_elem_callback {
|
||||
AlsaElemCallback *callback;
|
||||
void *data;
|
||||
};
|
||||
|
||||
// entry in alsa_card elems (ALSA control elements) array
|
||||
struct alsa_elem {
|
||||
|
||||
@@ -125,15 +137,8 @@ struct alsa_elem {
|
||||
// TODO: move this to struct routing_snk?
|
||||
int lr_num;
|
||||
|
||||
// the primary GTK widget and callback function for this ALSA
|
||||
// control element
|
||||
GtkWidget *widget;
|
||||
AlsaElemCallback *widget_callback;
|
||||
|
||||
// text label for volume controls
|
||||
// handle for routing controls
|
||||
// second button for dual controls
|
||||
GtkWidget *widget2;
|
||||
// the callback functions for this ALSA control element
|
||||
GList *callbacks;
|
||||
|
||||
// for boolean buttons, the two possible texts
|
||||
// for dual buttons, the four possible texts
|
||||
@@ -203,6 +208,13 @@ struct alsa_elem *get_elem_by_prefix(GArray *elems, char *prefix);
|
||||
int get_max_elem_by_name(GArray *elems, char *prefix, char *needle);
|
||||
int is_elem_routing_snk(struct alsa_elem *elem);
|
||||
|
||||
// add callback to alsa_elem callback list
|
||||
void alsa_elem_add_callback(
|
||||
struct alsa_elem *elem,
|
||||
AlsaElemCallback *callback,
|
||||
void *data
|
||||
);
|
||||
|
||||
// alsa snd_ctl_elem_*() functions
|
||||
int alsa_get_elem_type(struct alsa_elem *elem);
|
||||
char *alsa_get_elem_name(struct alsa_elem *elem);
|
||||
|
||||
Reference in New Issue
Block a user