Seems working now..
#include "envy24control.h"
-static void control_value(snd_ctl_t *handle, void *private_data, snd_ctl_elem_id_t *id)
+void control_input_callback(gpointer data, gint source, GdkInputCondition condition)
{
- if (id->iface == SND_CTL_ELEM_IFACE_PCM) {
- if (!strcmp(id->name, "Multi Track Route")) {
+ snd_ctl_t *ctl = (snd_ctl_t *)data;
+ snd_ctl_event_t *ev;
+ const char *name;
+ int index;
+
+ snd_ctl_event_alloca(&ev);
+ if (snd_ctl_read(ctl, ev) < 0)
+ return;
+ name = snd_ctl_event_elem_get_name(ev);
+ index = snd_ctl_event_elem_get_index(ev);
+ switch (snd_ctl_event_elem_get_interface(ev)) {
+ case SND_CTL_ELEM_IFACE_PCM:
+ if (!strcmp(name, "Multi Track Route"))
patchbay_update();
- return;
- }
- if (!strcmp(id->name, "Multi Track S/PDIF Master")) {
+ else if (!strcmp(name, "Multi Track S/PDIF Master"))
master_clock_update();
- return;
- }
- if (!strcmp(id->name, "Word Clock Sync")) {
+ else if (!strcmp(name, "Word Clock Sync"))
master_clock_update();
- return;
- }
- if (!strcmp(id->name, "Multi Track Volume Rate")) {
+ else if (!strcmp(name, "Multi Track Volume Rate"))
volume_change_rate_update();
- return;
- }
- if (!strcmp(id->name, "S/PDIF Input Optical")) {
+ else if (!strcmp(name, "S/PDIF Input Optical"))
spdif_input_update();
- return;
- }
- if (!strcmp(id->name, "Delta S/PDIF Output Defaults")) {
+ else if (!strcmp(name, "Delta S/PDIF Output Defaults"))
spdif_output_update();
- return;
- }
- }
- if (id->iface == SND_CTL_ELEM_IFACE_MIXER) {
- if (!strcmp(id->name, "Multi Playback Volume")) {
- mixer_update_stream(id->index + 1, 1, 0);
- return;
- }
- if (!strcmp(id->name, "Multi Capture Volume")) {
- mixer_update_stream(id->index + 11, 1, 0);
- return;
- }
- if (!strcmp(id->name, "Multi Playback Switch")) {
- mixer_update_stream(id->index + 1, 0, 1);
- return;
- }
- if (!strcmp(id->name, "Multi Capture Switch")) {
- mixer_update_stream(id->index + 11, 0, 1);
- return;
- }
+ break;
+ case SND_CTL_ELEM_IFACE_MIXER:
+ if (!strcmp(name, "Multi Playback Volume"))
+ mixer_update_stream(index + 1, 1, 0);
+ else if (!strcmp(name, "Multi Capture Volume"))
+ mixer_update_stream(index + 11, 1, 0);
+ else if (!strcmp(name, "Multi Playback Switch"))
+ mixer_update_stream(index + 1, 0, 1);
+ else if (!strcmp(name, "Multi Capture Switch"))
+ mixer_update_stream(index + 11, 0, 1);
+ break;
+ default:
+ break;
}
}
-static snd_ctl_callbacks_t control_callbacks = {
- private_data: NULL,
- rebuild: NULL, /* FIXME!! */
- value: control_value,
- change: NULL,
- add: NULL,
- remove: NULL,
- reserved: { NULL, }
-};
-
-void control_input_callback(gpointer data, gint source, GdkInputCondition condition)
-{
- snd_ctl_read(card_ctl, &control_callbacks);
-}
******************************************************************************/
#include "envy24control.h"
+#define _GNU_SOURCE
+#include <getopt.h>
-int card = 0;
-snd_ctl_t *card_ctl = NULL;
-snd_ctl_card_info_t hw_info;
ice1712_eeprom_t card_eeprom;
+snd_ctl_t *ctl;
GtkWidget *window;
gtk_widget_set_usize(label, 736, 16);
}
+static void usage(void)
+{
+ fprintf(stderr, "usage: envy24control [-D control-name]\n");
+}
+
int main(int argc, char **argv)
{
GtkWidget *notebook;
- char name[32], title[128];
- int err;
- unsigned int cards_mask;
- snd_ctl_elem_value_t ctl;
+ char *name, title[128];
+ int i, c, err;
+ //snd_ctl_t *ctl; // global
+ snd_ctl_card_info_t *hw_info;
+ snd_ctl_elem_value_t *val;
+ int npfds;
+ struct pollfd *pfds;
// snd_mixer_filter_t filter;
+ static struct option long_options[] = {
+ {"device", 1, 0, 'D'},
+ };
+
+ snd_ctl_card_info_alloca(&hw_info);
+ snd_ctl_elem_value_alloca(&val);
/* Go through gtk initialization */
gtk_init(&argc, &argv);
- card = snd_defaults_card();
- cards_mask = snd_cards_mask();
-
- while (1) {
- sprintf(name, "envy24control%d", card);
- if ((err = snd_ctl_hw_open(&card_ctl, name, card)) < 0) {
- fprintf(stderr, "snd_ctl_open: %s\n", snd_strerror(err));
- exit(EXIT_FAILURE);
- }
- if ((err = snd_ctl_card_info(card_ctl, &hw_info)) < 0) {
- fprintf(stderr, "snd_ctl_card_info: %s\n", snd_strerror(err));
- exit(EXIT_FAILURE);
- }
- if (hw_info.type == SND_CARD_TYPE_ICE1712)
+ name = "hw:0";
+ while ((c = getopt_long(argc, argv, "D:", long_options, NULL)) != -1) {
+ switch (c) {
+ case 'D':
+ name = optarg;
break;
- snd_ctl_close(card_ctl);
- card_ctl = NULL;
- cards_mask &= ~(1 << card);
- for (card = 0; card < 32; card++)
- if ((1 << card) & cards_mask)
- break;
- if (card >= 32)
+ default:
+ usage();
+ exit(1);
break;
+ }
}
- if (card_ctl == NULL) {
- fprintf(stderr, "Unable to find ICE1712 soundcard...\n");
+
+ if ((err = snd_ctl_open(&ctl, name, 0)) < 0) {
+ fprintf(stderr, "snd_ctl_open: %s\n", snd_strerror(err));
exit(EXIT_FAILURE);
}
-
-#if 0
- memset(&filter, 0, sizeof(filter));
- snd_mixer_set_bit(filter.read_cmds, SND_MIXER_READ_ELEM_VALUE, 1);
- if ((err = snd_mixer_put_filter(card_mixer, &filter)) < 0) {
- fprintf(stderr, "snd_mixer_set_filter: %s\n", snd_strerror(err));
+ if ((err = snd_ctl_card_info(ctl, hw_info)) < 0) {
+ fprintf(stderr, "snd_ctl_card_info: %s\n", snd_strerror(err));
+ exit(EXIT_FAILURE);
+ }
+ if (snd_ctl_card_info_get_type(hw_info) != SND_CARD_TYPE_ICE1712) {
+ fprintf(stderr, "invalid card type %d\n", snd_ctl_card_info_get_type(hw_info));
exit(EXIT_FAILURE);
}
-#endif
- memset(&ctl, 0, sizeof(ctl));
- ctl.id.iface = SND_CTL_ELEM_IFACE_CARD;
- strcpy(ctl.id.name, "ICE1712 EEPROM");
- if ((err = snd_ctl_elem_read(card_ctl, &ctl)) < 0) {
+ snd_ctl_elem_value_set_interface(val, SND_CTL_ELEM_IFACE_CARD);
+ snd_ctl_elem_value_set_name(val, "ICE1712 EEPROM");
+ if ((err = snd_ctl_elem_read(ctl, val)) < 0) {
fprintf(stderr, "Unable to read EEPROM contents: %s\n", snd_strerror(err));
exit(EXIT_FAILURE);
}
- memcpy(&card_eeprom, ctl.value.bytes.data, 32);
+ memcpy(&card_eeprom, snd_ctl_elem_value_get_bytes(val), 32);
/* Initialize code */
level_meters_init();
hardware_init();
/* Make the title */
- sprintf(title, "Envy24 Control Utility %s (%s)", VERSION, hw_info.longname);
+ sprintf(title, "Envy24 Control Utility %s (%s)", VERSION, snd_ctl_card_info_get_longname(hw_info));
/* Create the main window */
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
create_hardware(window, notebook, 2);
create_about(window, notebook, 3);
- gdk_input_add(snd_ctl_poll_descriptor(card_ctl),
- GDK_INPUT_READ,
- control_input_callback,
- NULL);
+ npfds = snd_ctl_poll_descriptors_count(ctl);
+ if (npfds > 0) {
+ pfds = alloca(sizeof(*pfds) * npfds);
+ npfds = snd_ctl_poll_descriptors(ctl, pfds, npfds);
+ for (i = 0; i < npfds; i++)
+ gdk_input_add(pfds[i].fd,
+ GDK_INPUT_READ,
+ control_input_callback,
+ ctl);
+ }
gtk_timeout_add(40, level_meters_timeout_callback, NULL);
gtk_timeout_add(100, master_clock_status_timeout_callback, NULL);
gtk_widget_show(window);
gtk_main();
- snd_ctl_close(card_ctl);
+ snd_ctl_close(ctl);
return EXIT_SUCCESS;
}
unsigned char extra[4];
} ice1712_eeprom_t;
-extern snd_ctl_t *card_ctl;
+extern snd_ctl_t *ctl;
extern ice1712_eeprom_t card_eeprom;
extern GtkWidget *mixer_mix_drawing;
#include "envy24control.h"
-static snd_ctl_elem_value_t spdif_master;
-static snd_ctl_elem_value_t word_clock_sync;
-static snd_ctl_elem_value_t volume_rate;
-static snd_ctl_elem_value_t spdif_input;
-static snd_ctl_elem_value_t spdif_output;
+static snd_ctl_elem_value_t *spdif_master;
+static snd_ctl_elem_value_t *word_clock_sync;
+static snd_ctl_elem_value_t *volume_rate;
+static snd_ctl_elem_value_t *spdif_input;
+static snd_ctl_elem_value_t *spdif_output;
#define toggle_set(widget, state) \
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), state);
{
int err;
- if ((err = snd_ctl_elem_read(card_ctl, &spdif_master)) < 0)
+ if ((err = snd_ctl_elem_read(ctl, spdif_master)) < 0)
g_print("Unable to read S/PDIF master state: %s\n", snd_strerror(err));
if (card_eeprom.subvendor == ICE1712_SUBDEVICE_DELTA1010) {
- if ((err = snd_ctl_elem_read(card_ctl, &word_clock_sync)) < 0)
+ if ((err = snd_ctl_elem_read(ctl, word_clock_sync)) < 0)
g_print("Unable to read word clock sync selection: %s\n", snd_strerror(err));
}
- if (spdif_master.value.integer.value[0]) {
- if (word_clock_sync.value.integer.value[0]) {
+ if (snd_ctl_elem_value_get_boolean(spdif_master, 0)) {
+ if (snd_ctl_elem_value_get_boolean(word_clock_sync, 0)) {
toggle_set(hw_master_clock_word_radio, TRUE);
} else {
toggle_set(hw_master_clock_spdif_radio, TRUE);
{
int err;
- spdif_master.value.integer.value[0] = on ? 1 : 0;
- if ((err = snd_ctl_elem_write(card_ctl, &spdif_master)) < 0)
+ snd_ctl_elem_value_set_boolean(spdif_master, 0, on ? 1 : 0);
+ if ((err = snd_ctl_elem_write(ctl, spdif_master)) < 0)
g_print("Unable to write S/PDIF master state: %s\n", snd_strerror(err));
}
if (card_eeprom.subvendor != ICE1712_SUBDEVICE_DELTA1010)
return;
- word_clock_sync.value.integer.value[0] = on ? 1 : 0;
- if ((err = snd_ctl_elem_write(card_ctl, &word_clock_sync)) < 0)
+ snd_ctl_elem_value_set_boolean(word_clock_sync, 0, on ? 1 : 0);
+ if ((err = snd_ctl_elem_write(ctl, word_clock_sync)) < 0)
g_print("Unable to write word clock sync selection: %s\n", snd_strerror(err));
}
gint master_clock_status_timeout_callback(gpointer data)
{
- snd_ctl_elem_value_t sw;
+ snd_ctl_elem_value_t *sw;
int err;
if (card_eeprom.subvendor != ICE1712_SUBDEVICE_DELTA1010)
return FALSE;
- memset(&sw, 0, sizeof(sw));
- sw.id.iface = SND_CTL_ELEM_IFACE_PCM;
- strcpy(sw.id.name, "Word Clock Status");
- if ((err = snd_ctl_elem_read(card_ctl, &sw)) < 0)
+ snd_ctl_elem_value_alloca(&sw);
+ snd_ctl_elem_value_set_interface(sw, SND_CTL_ELEM_IFACE_PCM);
+ snd_ctl_elem_value_set_name(sw, "Word Clock Status");
+ if ((err = snd_ctl_elem_read(ctl, sw)) < 0)
g_print("Unable to determine word clock status: %s\n", snd_strerror(err));
gtk_label_set_text(GTK_LABEL(hw_master_clock_status_label),
- sw.value.integer.value[0] ? "Locked" : "No signal");
+ snd_ctl_elem_value_get_boolean(sw, 0) ? "Locked" : "No signal");
return TRUE;
}
{
int err;
- if ((err = snd_ctl_elem_read(card_ctl, &volume_rate)) < 0)
+ if ((err = snd_ctl_elem_read(ctl, volume_rate)) < 0)
g_print("Unable to read volume change rate: %s\n", snd_strerror(err));
- gtk_adjustment_set_value(GTK_ADJUSTMENT(hw_volume_change_adj), volume_rate.value.integer.value[0]);
+ gtk_adjustment_set_value(GTK_ADJUSTMENT(hw_volume_change_adj),
+ snd_ctl_elem_value_get_integer(volume_rate, 0));
}
void volume_change_rate_adj(GtkAdjustment *adj, gpointer data)
{
int err;
- volume_rate.value.integer.value[0] = adj->value;
- if ((err = snd_ctl_elem_write(card_ctl, &volume_rate)) < 0)
+ snd_ctl_elem_value_set_integer(volume_rate, 0, adj->value);
+ if ((err = snd_ctl_elem_write(ctl, volume_rate)) < 0)
g_print("Unable to write volume change rate: %s\n", snd_strerror(err));
}
if (card_eeprom.subvendor == ICE1712_SUBDEVICE_DELTA44)
return;
- if ((err = snd_ctl_elem_read(card_ctl, &spdif_output)) < 0)
+ if ((err = snd_ctl_elem_read(ctl, spdif_output)) < 0)
g_print("Unable to read Delta S/PDIF output state: %s\n", snd_strerror(err));
- val = spdif_output.value.integer.value[0];
+ val = snd_ctl_elem_value_get_integer(spdif_output, 0);
if (val & 1) { /* consumer */
toggle_set(hw_spdif_consumer_radio, TRUE);
if (val & 8) {
{
int err;
- if ((err = snd_ctl_elem_write(card_ctl, &spdif_output)) < 0)
+ if ((err = snd_ctl_elem_write(ctl, spdif_output)) < 0)
g_print("Unable to write Delta S/PDIF Output Defaults: %s\n", snd_strerror(err));
}
void profi_data_toggled(GtkWidget *togglebutton, gpointer data)
{
char *str = (char *)data;
- int val = spdif_output.value.integer.value[0];
+ int val = snd_ctl_elem_value_get_integer(spdif_output, 0);
if (!is_active(togglebutton))
return;
} else if (!strcmp(str, "Non-audio")) {
val &= ~0x02;
}
- spdif_output.value.integer.value[0] = val;
+ snd_ctl_elem_value_set_integer(spdif_output, 0, val);
spdif_output_write();
}
void profi_stream_toggled(GtkWidget *togglebutton, gpointer data)
{
char *str = (char *)data;
- int val = spdif_output.value.integer.value[0];
+ int val = snd_ctl_elem_value_get_integer(spdif_output, 0);
if (!is_active(togglebutton))
return;
} else if (!strcmp(str, "Stereo")) {
val &= ~0x80;
}
- spdif_output.value.integer.value[0] = val;
+ snd_ctl_elem_value_set_integer(spdif_output, 0, val);
spdif_output_write();
}
void profi_emphasis_toggled(GtkWidget *togglebutton, gpointer data)
{
char *str = (char *)data;
- int val = spdif_output.value.integer.value[0];
+ int val = snd_ctl_elem_value_get_integer(spdif_output, 0);
if (!is_active(togglebutton))
return;
} else if (!strcmp(str, "NOTID")) {
val |= 0x60;
}
- spdif_output.value.integer.value[0] = val;
+ snd_ctl_elem_value_set_integer(spdif_output, 0, val);
spdif_output_write();
}
void consumer_copyright_toggled(GtkWidget *togglebutton, gpointer data)
{
char *str = (char *)data;
- int val = spdif_output.value.integer.value[0];
+ int val = snd_ctl_elem_value_get_integer(spdif_output, 0);
if (!is_active(togglebutton))
return;
} else if (!strcmp(str, "Permitted")) {
val &= ~0x08;
}
- spdif_output.value.integer.value[0] = val;
+ snd_ctl_elem_value_set_integer(spdif_output, 0, val);
spdif_output_write();
}
void consumer_copy_toggled(GtkWidget *togglebutton, gpointer data)
{
char *str = (char *)data;
- int val = spdif_output.value.integer.value[0];
+ int val = snd_ctl_elem_value_get_integer(spdif_output, 0);
if (!is_active(togglebutton))
return;
} else if (!strcmp(str, "Original")) {
val &= ~0x80;
}
- spdif_output.value.integer.value[0] = val;
+ snd_ctl_elem_value_set_integer(spdif_output, 0, val);
spdif_output_write();
}
void consumer_emphasis_toggled(GtkWidget *togglebutton, gpointer data)
{
char *str = (char *)data;
- int val = spdif_output.value.integer.value[0];
+ int val = snd_ctl_elem_value_get_integer(spdif_output, 0);
if (!is_active(togglebutton))
return;
} else if (!strcmp(str, "5015")) {
val &= ~0x10;
}
- spdif_output.value.integer.value[0] = val;
+ snd_ctl_elem_value_set_integer(spdif_output, 0, val);
spdif_output_write();
}
void consumer_category_toggled(GtkWidget *togglebutton, gpointer data)
{
char *str = (char *)data;
- int val = spdif_output.value.integer.value[0];
+ int val = snd_ctl_elem_value_get_integer(spdif_output, 0);
if (!is_active(togglebutton))
return;
} else if (!strcmp(str, "General")) {
val |= 0x60;
}
- spdif_output.value.integer.value[0] = val;
+ snd_ctl_elem_value_set_integer(spdif_output, 0, val);
spdif_output_write();
}
if (is_active(togglebutton)) {
if (!strcmp(str, "Professional")) {
- if (spdif_output.value.integer.value[0] & 0x01) {
+ if (snd_ctl_elem_value_get_integer(spdif_output, 0) & 0x01) {
/* default setup: audio, no emphasis */
- spdif_output.value.integer.value[0] = 0x22;
+ snd_ctl_elem_value_set_integer(spdif_output, 0, 0x22);
}
page = 0;
} else {
- if (!(spdif_output.value.integer.value[0] & 0x01)) {
+ if (!(snd_ctl_elem_value_get_integer(spdif_output, 0) & 0x01)) {
/* default setup: no emphasis, PCM encoder */
- spdif_output.value.integer.value[0] = 0x31;
+ snd_ctl_elem_value_set_integer(spdif_output, 0, 0x31);
}
page = 1;
}
if (card_eeprom.subvendor != ICE1712_SUBDEVICE_DELTADIO2496)
return;
- if ((err = snd_ctl_elem_read(card_ctl, &spdif_input)) < 0)
+ if ((err = snd_ctl_elem_read(ctl, spdif_input)) < 0)
g_print("Unable to read S/PDIF input switch: %s\n", snd_strerror(err));
- if (spdif_input.value.integer.value[0]) {
+ if (snd_ctl_elem_value_get_boolean(spdif_input, 0)) {
toggle_set(hw_spdif_input_optical_radio, TRUE);
} else {
toggle_set(hw_spdif_input_coaxial_radio, TRUE);
if (!is_active(togglebutton))
return;
if (!strcmp(str, "Optical"))
- spdif_input.value.integer.value[0] = 1;
+ snd_ctl_elem_value_set_boolean(spdif_input, 0, 1);
else
- spdif_input.value.integer.value[0] = 0;
- if ((err = snd_ctl_elem_write(card_ctl, &spdif_input)) < 0)
+ snd_ctl_elem_value_set_boolean(spdif_input, 0, 0);
+ if ((err = snd_ctl_elem_write(ctl, spdif_input)) < 0)
g_print("Unable to write S/PDIF input switch: %s\n", snd_strerror(err));
}
void hardware_init(void)
{
- memset(&spdif_master, 0, sizeof(spdif_master));
- spdif_master.id.iface = SND_CTL_ELEM_IFACE_PCM;
- strcpy(spdif_master.id.name, "Multi Track S/PDIF Master");
+ if (snd_ctl_elem_value_malloc(&spdif_master) < 0 ||
+ snd_ctl_elem_value_malloc(&word_clock_sync) < 0 ||
+ snd_ctl_elem_value_malloc(&volume_rate) < 0 ||
+ snd_ctl_elem_value_malloc(&spdif_input) < 0 ||
+ snd_ctl_elem_value_malloc(&spdif_output) < 0) {
+ g_print("Cannot allocate memory\n");
+ exit(1);
+ }
+
+ snd_ctl_elem_value_set_interface(spdif_master, SND_CTL_ELEM_IFACE_PCM);
+ snd_ctl_elem_value_set_name(spdif_master, "Multi Track IEC958 Master");
- memset(&word_clock_sync, 0, sizeof(spdif_master));
- word_clock_sync.id.iface = SND_CTL_ELEM_IFACE_PCM;
- strcpy(word_clock_sync.id.name, "Word Clock Sync");
+ snd_ctl_elem_value_set_interface(word_clock_sync, SND_CTL_ELEM_IFACE_PCM);
+ snd_ctl_elem_value_set_name(word_clock_sync, "Word Clock Sync");
- memset(&volume_rate, 0, sizeof(volume_rate));
- spdif_master.id.iface = SND_CTL_ELEM_IFACE_PCM;
- strcpy(volume_rate.id.name, "Multi Track Volume Rate");
+ snd_ctl_elem_value_set_interface(volume_rate, SND_CTL_ELEM_IFACE_PCM);
+ snd_ctl_elem_value_set_name(volume_rate, "Multi Track Volume Rate");
- memset(&spdif_input, 0, sizeof(spdif_input));
- spdif_master.id.iface = SND_CTL_ELEM_IFACE_PCM;
- strcpy(spdif_input.id.name, "S/PDIF Input Optical");
+ snd_ctl_elem_value_set_interface(spdif_input, SND_CTL_ELEM_IFACE_PCM);
+ snd_ctl_elem_value_set_name(spdif_input, "IEC958 Input Optical");
- memset(&spdif_output, 0, sizeof(spdif_output));
- spdif_master.id.iface = SND_CTL_ELEM_IFACE_PCM;
- strcpy(spdif_output.id.name, "Delta S/PDIF Output Defaults");
+ snd_ctl_elem_value_set_interface(spdif_output, SND_CTL_ELEM_IFACE_PCM);
+ snd_ctl_elem_value_set_name(spdif_output, "IEC958 Playback Default");
}
void hardware_postinit(void)
static GdkGC *penRedShadow[21] = { NULL, };
static GdkGC *penRedLight[21] = { NULL, };
static GdkPixmap *pixmap[21] = { NULL, };
-static snd_ctl_elem_value_t peaks;
+static snd_ctl_elem_value_t *peaks;
static void update_peak_switch(void)
{
int err;
- memset(&peaks, 0, sizeof(peaks));
- peaks.id.iface = SND_CTL_ELEM_IFACE_MIXER;
- strcpy(peaks.id.name, "Multi Track Peak");
- if ((err = snd_ctl_elem_read(card_ctl, &peaks)) < 0)
+ if ((err = snd_ctl_elem_read(ctl, peaks)) < 0)
g_print("Unable to read peaks: %s\n", snd_strerror(err));
}
*l1 = *l2 = 0;
if (idx == 0) {
- *l1 = peaks.value.integer.value[4 + 20];
- *l2 = peaks.value.integer.value[4 + 21];
+ *l1 = snd_ctl_elem_value_get_integer(peaks, 20);
+ *l2 = snd_ctl_elem_value_get_integer(peaks, 21);
} else {
- *l1 = *l2 = peaks.value.integer.value[4 + idx - 1];
+ *l1 = *l2 = snd_ctl_elem_value_get_integer(peaks, idx - 1);
}
}
void level_meters_init(void)
{
- memset(&peaks, 0, sizeof(peaks));
+ snd_ctl_elem_value_malloc(&peaks);
+ snd_ctl_elem_value_set_interface(peaks, SND_CTL_ELEM_IFACE_MIXER);
+ snd_ctl_elem_value_set_name(peaks, "Multi Track Peak");
}
void level_meters_postinit(void)
void mixer_update_stream(int stream, int vol_flag, int sw_flag)
{
- snd_ctl_elem_value_t vol, sw;
int err;
if (vol_flag) {
- memset(&vol, 0, sizeof(vol));
- vol.id.iface = SND_CTL_ELEM_IFACE_MIXER;
- strcpy(vol.id.name, stream <= 10 ? "Multi Playback Volume" : "Multi Capture Volume");
- vol.id.index = (stream - 1) % 10;
- if ((err = snd_ctl_elem_read(card_ctl, &vol)) < 0)
+ snd_ctl_elem_value_t *vol;
+ int v[2];
+ snd_ctl_elem_value_alloca(&vol);
+ snd_ctl_elem_value_set_interface(vol, SND_CTL_ELEM_IFACE_MIXER);
+ snd_ctl_elem_value_set_name(vol, stream <= 10 ? "Multi Playback Volume" : "Multi Capture Volume");
+ snd_ctl_elem_value_set_index(vol, (stream - 1) % 10);
+ if ((err = snd_ctl_elem_read(ctl, vol)) < 0)
g_print("Unable to read multi playback volume: %s\n", snd_strerror(err));
- gtk_adjustment_set_value(GTK_ADJUSTMENT(mixer_adj[stream-1][0]), 96 - vol.value.integer.value[0]);
- gtk_adjustment_set_value(GTK_ADJUSTMENT(mixer_adj[stream-1][1]), 96 - vol.value.integer.value[1]);
- if (vol.value.integer.value[0] != vol.value.integer.value[1])
+ v[0] = snd_ctl_elem_value_get_integer(vol, 0);
+ v[1] = snd_ctl_elem_value_get_integer(vol, 1);
+ gtk_adjustment_set_value(GTK_ADJUSTMENT(mixer_adj[stream-1][0]), 96 - v[0]);
+ gtk_adjustment_set_value(GTK_ADJUSTMENT(mixer_adj[stream-1][1]), 96 - v[1]);
+ if (v[0] != v[1])
toggle_set(mixer_stereo_toggle[stream-1], FALSE);
}
if (sw_flag) {
- memset(&sw, 0, sizeof(sw));
- sw.id.iface = SND_CTL_ELEM_IFACE_MIXER;
- strcpy(sw.id.name, stream <= 10 ? "Multi Playback Switch" : "Multi Capture Switch");
- sw.id.index = (stream - 1) % 10;
- if ((err = snd_ctl_elem_read(card_ctl, &sw)) < 0)
+ snd_ctl_elem_value_t *sw;
+ int v[2];
+ snd_ctl_elem_value_alloca(&sw);
+ snd_ctl_elem_value_set_interface(sw, SND_CTL_ELEM_IFACE_MIXER);
+ snd_ctl_elem_value_set_name(sw, stream <= 10 ? "Multi Playback Switch" : "Multi Capture Switch");
+ snd_ctl_elem_value_set_index(sw, (stream - 1) % 10);
+ if ((err = snd_ctl_elem_read(ctl, sw)) < 0)
g_print("Unable to read multi playback switch: %s\n", snd_strerror(err));
- toggle_set(mixer_solo_toggle[stream-1][0], sw.value.integer.value[0] ? TRUE : FALSE);
- toggle_set(mixer_solo_toggle[stream-1][1], sw.value.integer.value[1] ? TRUE : FALSE);
- toggle_set(mixer_mute_toggle[stream-1][0], !sw.value.integer.value[0] ? TRUE : FALSE);
- toggle_set(mixer_mute_toggle[stream-1][1], !sw.value.integer.value[1] ? TRUE : FALSE);
- if (sw.value.integer.value[0] != sw.value.integer.value[1])
+ v[0] = snd_ctl_elem_value_get_boolean(sw, 0);
+ v[1] = snd_ctl_elem_value_get_boolean(sw, 1);
+ toggle_set(mixer_solo_toggle[stream-1][0], v[0] ? TRUE : FALSE);
+ toggle_set(mixer_solo_toggle[stream-1][1], v[1] ? TRUE : FALSE);
+ toggle_set(mixer_mute_toggle[stream-1][0], !v[0] ? TRUE : FALSE);
+ toggle_set(mixer_mute_toggle[stream-1][1], !v[1] ? TRUE : FALSE);
+ if (v[0] != v[1])
toggle_set(mixer_stereo_toggle[stream-1], FALSE);
}
}
static void set_switch1(int stream, int left, int right)
{
- snd_ctl_elem_value_t sw;
+ snd_ctl_elem_value_t *sw;
int err;
- memset(&sw, 0, sizeof(sw));
- sw.id.iface = SND_CTL_ELEM_IFACE_MIXER;
- strcpy(sw.id.name, stream <= 10 ? "Multi Playback Switch" : "Multi Capture Switch");
- sw.id.index = (stream - 1) % 10;
- if ((err = snd_ctl_elem_read(card_ctl, &sw)) < 0)
+ snd_ctl_elem_value_alloca(&sw);
+ snd_ctl_elem_value_set_interface(sw, SND_CTL_ELEM_IFACE_MIXER);
+ snd_ctl_elem_value_set_name(sw, stream <= 10 ? "Multi Playback Switch" : "Multi Capture Switch");
+ snd_ctl_elem_value_set_index(sw, (stream - 1) % 10);
+ if ((err = snd_ctl_elem_read(ctl, sw)) < 0)
g_print("Unable to read multi switch: %s\n", snd_strerror(err));
if (left >= 0)
- sw.value.integer.value[0] = left != 0;
+ snd_ctl_elem_value_set_boolean(sw, 0, left != 0);
if (right >= 0)
- sw.value.integer.value[1] = right != 0;
- if ((err = snd_ctl_elem_write(card_ctl, &sw)) < 0 && err != -EBUSY)
+ snd_ctl_elem_value_set_boolean(sw, 1, right != 0);
+ if ((err = snd_ctl_elem_write(ctl, sw)) < 0 && err != -EBUSY)
g_print("Unable to write multi switch: %s\n", snd_strerror(err));
}
static void set_volume1(int stream, int left, int right)
{
- snd_ctl_elem_value_t vol;
+ snd_ctl_elem_value_t *vol;
int err;
- memset(&vol, 0, sizeof(vol));
- vol.id.iface = SND_CTL_ELEM_IFACE_MIXER;
- strcpy(vol.id.name, stream <= 10 ? "Multi Playback Volume" : "Multi Capture Volume");
- vol.id.index = (stream - 1) % 10;
- if ((err = snd_ctl_elem_read(card_ctl, &vol)) < 0)
+ snd_ctl_elem_value_alloca(&vol);
+ snd_ctl_elem_value_set_interface(vol, SND_CTL_ELEM_IFACE_MIXER);
+ snd_ctl_elem_value_set_name(vol, stream <= 10 ? "Multi Playback Volume" : "Multi Capture Volume");
+ snd_ctl_elem_value_set_index(vol, (stream - 1) % 10);
+ if ((err = snd_ctl_elem_read(ctl, vol)) < 0)
g_print("Unable to read multi volume: %s\n", snd_strerror(err));
if (left >= 0)
- vol.value.integer.value[0] = left;
+ snd_ctl_elem_value_set_integer(vol, 0, left);
if (right >= 0)
- vol.value.integer.value[1] = right;
- if ((err = snd_ctl_elem_write(card_ctl, &vol)) < 0 && err != -EBUSY)
+ snd_ctl_elem_value_set_integer(vol, 1, right);
+ if ((err = snd_ctl_elem_write(ctl, vol)) < 0 && err != -EBUSY)
g_print("Unable to write multi volume: %s\n", snd_strerror(err));
}
#include "envy24control.h"
-static snd_ctl_elem_value_t routes;
+static snd_ctl_elem_value_t *routes;
#define toggle_set(widget, state) \
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), state);
static int get_toggle_index(int stream)
{
- unsigned short psdout = routes.value.bytes.data[0] |
- (routes.value.bytes.data[1] << 8);
- unsigned short spdout = routes.value.bytes.data[2] |
- (routes.value.bytes.data[3] << 8);
- unsigned int capture = routes.value.bytes.data[4] |
- (routes.value.bytes.data[5] << 8) |
- (routes.value.bytes.data[6] << 16) |
- (routes.value.bytes.data[7] << 24);
+ unsigned short psdout = snd_ctl_elem_value_get_byte(routes, 0) |
+ (snd_ctl_elem_value_get_byte(routes, 1) << 8);
+ unsigned short spdout = snd_ctl_elem_value_get_byte(routes, 2) |
+ (snd_ctl_elem_value_get_byte(routes, 3) << 8);
+ unsigned int capture = snd_ctl_elem_value_get_byte(routes, 4) |
+ (snd_ctl_elem_value_get_byte(routes, 5) << 8) |
+ (snd_ctl_elem_value_get_byte(routes, 6) << 16) |
+ (snd_ctl_elem_value_get_byte(routes, 7) << 24);
int right = (stream - 1) & 1;
int source = (stream - 1) >> 1;
{
int stream, tidx, err;
- if ((err = snd_ctl_elem_read(card_ctl, &routes)) < 0) {
+ if ((err = snd_ctl_elem_read(ctl, routes)) < 0) {
g_print("Multi track routes read error: %s\n", snd_strerror(err));
return;
}
static void set_routes(int stream, int idx)
{
- unsigned short psdout = routes.value.bytes.data[0] |
- (routes.value.bytes.data[1] << 8);
- unsigned short spdout = routes.value.bytes.data[2] |
- (routes.value.bytes.data[3] << 8);
- unsigned int capture = routes.value.bytes.data[4] |
- (routes.value.bytes.data[5] << 8) |
- (routes.value.bytes.data[6] << 16) |
- (routes.value.bytes.data[7] << 24);
+ unsigned short psdout = snd_ctl_elem_value_get_byte(routes, 0) |
+ (snd_ctl_elem_value_get_byte(routes, 1) << 8);
+ unsigned short spdout = snd_ctl_elem_value_get_byte(routes, 2) |
+ (snd_ctl_elem_value_get_byte(routes, 3) << 8);
+ unsigned int capture = snd_ctl_elem_value_get_byte(routes, 4) |
+ (snd_ctl_elem_value_get_byte(routes, 5) << 8) |
+ (snd_ctl_elem_value_get_byte(routes, 6) << 16) |
+ (snd_ctl_elem_value_get_byte(routes, 7) << 24);
int right = (stream - 1) & 1;
int source = (stream - 1) >> 1;
int err;
spdout |= ((idx - 4) & 7) << spdout_shift1;
}
}
- routes.value.bytes.data[0] = psdout & 0xff;
- routes.value.bytes.data[1] = (psdout >> 8) & 0xff;
- routes.value.bytes.data[2] = spdout & 0xff;
- routes.value.bytes.data[3] = (spdout >> 8) & 0xff;
- routes.value.bytes.data[4] = capture & 0xff;
- routes.value.bytes.data[5] = (capture >> 8) & 0xff;
- routes.value.bytes.data[6] = (capture >> 16) & 0xff;
- routes.value.bytes.data[7] = (capture >> 24) & 0xff;
+ snd_ctl_elem_value_set_byte(routes, 0, psdout & 0xff);
+ snd_ctl_elem_value_set_byte(routes, 1, (psdout >> 8) & 0xff);
+ snd_ctl_elem_value_set_byte(routes, 2, spdout & 0xff);
+ snd_ctl_elem_value_set_byte(routes, 3, (spdout >> 8) & 0xff);
+ snd_ctl_elem_value_set_byte(routes, 4, capture & 0xff);
+ snd_ctl_elem_value_set_byte(routes, 5, (capture >> 8) & 0xff);
+ snd_ctl_elem_value_set_byte(routes, 6, (capture >> 16) & 0xff);
+ snd_ctl_elem_value_set_byte(routes, 7, (capture >> 24) & 0xff);
// g_print("psdout = 0x%x, spdout = 0x%x, capture = 0x%x\n", psdout, spdout, capture);
- if ((err = snd_ctl_elem_write(card_ctl, &routes)) < 0)
+
+ if ((err = snd_ctl_elem_write(ctl, routes)) < 0)
g_print("Multi track route write error: %s\n", snd_strerror(err));
}
void patchbay_init(void)
{
- memset(&routes, 0, sizeof(routes));
- routes.id.iface = SND_CTL_ELEM_IFACE_MIXER;
- strcpy(routes.id.name, "Multi Track Route");
+ snd_ctl_elem_value_malloc(&routes);
+ snd_ctl_elem_value_set_interface(routes, SND_CTL_ELEM_IFACE_MIXER);
+ snd_ctl_elem_value_set_name(routes, "Multi Track Route");
}
void patchbay_postinit(void)