This commit is contained in:
genBTC 2025-03-07 11:24:55 +00:00 committed by GitHub
commit 1897d34fa1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 1133 additions and 877 deletions

View file

@ -5,6 +5,6 @@ AC_HEADER_STDC
AM_INIT_AUTOMAKE
AM_MAINTAINER_MODE([enable])
PKG_CHECK_MODULES(ECHOMIXER, gtk+-2.0 alsa >= 1.0.0)
PKG_CHECK_MODULES(ECHOMIXER, gtk+-3.0 alsa >= 1.0.0)
AC_OUTPUT(Makefile desktop/Makefile)

File diff suppressed because it is too large Load diff

View file

@ -47,7 +47,7 @@ void config_close()
void config_set_stereo(GtkWidget *but, gpointer data)
{
gint i=GPOINTER_TO_INT(data);
config_stereo[i]=GTK_TOGGLE_BUTTON(but)->active;
config_stereo[i]=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(but));
}
void config_restore_stereo()

View file

@ -5,6 +5,6 @@ AC_HEADER_STDC
AM_INIT_AUTOMAKE
AM_MAINTAINER_MODE([enable])
PKG_CHECK_MODULES(ENVY24CONTROL, gtk+-2.0 alsa >= 0.9.0)
PKG_CHECK_MODULES(ENVY24CONTROL, gtk+-3.0 alsa >= 0.9.0)
AC_OUTPUT(Makefile desktop/Makefile)

View file

@ -19,7 +19,7 @@
#include "envy24control.h"
void control_input_callback(gpointer data, gint source, GdkInputCondition condition)
gint control_input_callback(GIOChannel *source, GIOCondition condition, gpointer data)
{
snd_ctl_t *ctl = (snd_ctl_t *)data;
snd_ctl_event_t *ev;
@ -29,12 +29,12 @@ void control_input_callback(gpointer data, gint source, GdkInputCondition condit
snd_ctl_event_alloca(&ev);
if (snd_ctl_read(ctl, ev) < 0)
return;
return FALSE;
name = snd_ctl_event_elem_get_name(ev);
index = snd_ctl_event_elem_get_index(ev);
mask = snd_ctl_event_elem_get_mask(ev);
if (! (mask & (SND_CTL_EVENT_MASK_VALUE | SND_CTL_EVENT_MASK_INFO)))
return;
return FALSE;
switch (snd_ctl_event_elem_get_interface(ev)) {
case SND_CTL_ELEM_IFACE_MIXER:
@ -84,5 +84,6 @@ void control_input_callback(gpointer data, gint source, GdkInputCondition condit
default:
break;
}
return TRUE;
}

File diff suppressed because it is too large Load diff

View file

@ -85,7 +85,7 @@ extern ice1712_eeprom_t card_eeprom;
extern GtkWidget *mixer_mix_drawing;
extern GtkWidget *mixer_clear_peaks_button;
extern GtkWidget *mixer_drawing[20];
extern GtkObject *mixer_adj[20][2];
extern GtkAdjustment *mixer_adj[20][2];
extern GtkWidget *mixer_vscale[20][2];
extern GtkWidget *mixer_solo_toggle[20][2];
extern GtkWidget *mixer_mute_toggle[20][2];
@ -108,7 +108,7 @@ extern GtkWidget *hw_master_clock_actual_rate_label;
extern GtkWidget *hw_rate_locking_check;
extern GtkWidget *hw_rate_reset_check;
extern GtkObject *hw_volume_change_adj;
extern GtkAdjustment *hw_volume_change_adj;
extern GtkWidget *hw_volume_change_spin;
extern GtkWidget *hw_spdif_profi_nonaudio_radio;
@ -151,9 +151,9 @@ extern GtkWidget *input_interface_internal;
extern GtkWidget *input_interface_front_input;
extern GtkWidget *input_interface_rear_input;
extern GtkWidget *input_interface_wavetable;
extern GtkObject *av_dac_volume_adj[];
extern GtkObject *av_adc_volume_adj[];
extern GtkObject *av_ipga_volume_adj[];
extern GtkAdjustment *av_dac_volume_adj[];
extern GtkAdjustment *av_adc_volume_adj[];
extern GtkAdjustment *av_ipga_volume_adj[];
extern GtkLabel *av_dac_volume_label[];
extern GtkLabel *av_adc_volume_label[];
extern GtkLabel *av_ipga_volume_label[];
@ -238,6 +238,6 @@ void ipga_volume_adjust(GtkAdjustment *adj, gpointer data);
void dac_sense_toggled(GtkWidget *togglebutton, gpointer data);
void adc_sense_toggled(GtkWidget *togglebutton, gpointer data);
void control_input_callback(gpointer data, gint source, GdkInputCondition condition);
void mixer_input_callback(gpointer data, gint source, GdkInputCondition condition);
gint control_input_callback(GIOChannel *source, GIOCondition condition, gpointer data);
gint mixer_input_callback(GIOChannel *source, GIOCondition condition, gpointer data);

View file

@ -39,13 +39,13 @@ static inline int is_update_needed(void);
static int is_active(GtkWidget *widget)
{
return GTK_TOGGLE_BUTTON(widget)->active ? 1 : 0;
return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
}
void master_clock_update(void)
{
int err, rate, need_default_update;
if ((err = snd_ctl_elem_read(ctl, internal_clock)) < 0)
g_print("Unable to read Internal Clock state: %s\n", snd_strerror(err));
if ((err = snd_ctl_elem_read(ctl, internal_clock_default)) < 0)
@ -343,7 +343,7 @@ void rate_reset_toggled(GtkWidget *togglebutton, gpointer data)
void volume_change_rate_update(void)
{
int err;
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),
@ -353,8 +353,8 @@ void volume_change_rate_update(void)
void volume_change_rate_adj(GtkAdjustment *adj, gpointer data)
{
int err;
snd_ctl_elem_value_set_integer(volume_rate, 0, adj->value);
double adjustment_value = gtk_adjustment_get_value(adj);
snd_ctl_elem_value_set_integer(volume_rate, 0, adjustment_value);
if ((err = snd_ctl_elem_write(ctl, volume_rate)) < 0)
g_print("Unable to write volume change rate: %s\n", snd_strerror(err));
}
@ -363,7 +363,7 @@ void spdif_output_update(void)
{
int err;
snd_aes_iec958_t iec958;
if ((err = snd_ctl_elem_read(ctl, spdif_output)) < 0) {
if (err == -ENOENT)
return;
@ -550,7 +550,7 @@ void consumer_category_toggled(GtkWidget *togglebutton, gpointer data)
char *str = (char *)data;
snd_aes_iec958_t iec958;
snd_ctl_elem_value_get_iec958(spdif_output, &iec958);
snd_ctl_elem_value_get_iec958(spdif_output, &iec958);
if (!is_active(togglebutton))
return;
if (iec958.status[0] & IEC958_AES0_PROFESSIONAL)
@ -598,7 +598,7 @@ void spdif_output_toggled(GtkWidget *togglebutton, gpointer data)
page = 1;
}
spdif_output_write();
gtk_notebook_set_page(GTK_NOTEBOOK(hw_spdif_output_notebook), page);
gtk_notebook_set_current_page(GTK_NOTEBOOK(hw_spdif_output_notebook), page);
spdif_output_update();
}
}
@ -635,7 +635,7 @@ void spdif_input_toggled(GtkWidget *togglebutton, gpointer data)
{
int err;
char *str = (char *)data;
if (!is_active(togglebutton))
return;
if (!strcmp(str, "Off"))

View file

@ -19,13 +19,13 @@
#include "envy24control.h"
static GdkGC *penGreenShadow[21] = { NULL, };
static GdkGC *penGreenLight[21] = { NULL, };
static GdkGC *penOrangeShadow[21] = { NULL, };
static GdkGC *penOrangeLight[21] = { NULL, };
static GdkGC *penRedShadow[21] = { NULL, };
static GdkGC *penRedLight[21] = { NULL, };
static GdkPixmap *pixmap[21] = { NULL, };
static GdkRGBA *penGreenShadow[21] = { NULL, };
static GdkRGBA *penGreenLight[21] = { NULL, };
static GdkRGBA *penOrangeShadow[21] = { NULL, };
static GdkRGBA *penOrangeLight[21] = { NULL, };
static GdkRGBA *penRedShadow[21] = { NULL, };
static GdkRGBA *penRedLight[21] = { NULL, };
static GdkPixbuf *pixmap[21] = { NULL, };
static snd_ctl_elem_value_t *peaks;
extern int input_channels, output_channels, pcm_output_channels, spdif_channels, view_spdif_playback;
@ -41,7 +41,7 @@ static void update_peak_switch(void)
static void get_levels(int idx, int *l1, int *l2)
{
*l1 = *l2 = 0;
if (idx == 0) {
*l1 = snd_ctl_elem_value_get_integer(peaks, 20);
*l2 = snd_ctl_elem_value_get_integer(peaks, 21);
@ -50,19 +50,14 @@ static void get_levels(int idx, int *l1, int *l2)
}
}
static GdkGC *get_pen(int idx, int nRed, int nGreen, int nBlue)
static GdkRGBA *get_pen(int idx, int nRed, int nGreen, int nBlue)
{
GdkColor *c;
GdkGC *gc;
c = (GdkColor *)g_malloc(sizeof(GdkColor));
c->red = nRed;
c->green = nGreen;
c->blue = nBlue;
gdk_color_alloc(gdk_colormap_get_system(), c);
gc = gdk_gc_new(pixmap[idx]);
gdk_gc_set_foreground(gc, c);
return gc;
GdkRGBA *c = g_malloc(sizeof(GdkRGBA));
c->red = nRed / 255.0;
c->green = nGreen / 255.0;
c->blue = nBlue / 255.0;
c->alpha = 1.0; // Fully opaque
return c;
}
static int get_index(const gchar *name)
@ -91,61 +86,129 @@ static void redraw_meters(int idx, int width, int height, int level1, int level2
int segs_on1 = ((segments * level1) + 128) / 255;
int segs_on2 = ((segments * level2) + 128) / 255;
GdkPixbuf *pixbuf = pixmap[idx];
// Create a Cairo surface from the GdkPixbuf
cairo_surface_t *surface = gdk_cairo_surface_create_from_pixbuf(pixbuf, 0, NULL);
// Create a Cairo context from the surface
cairo_t *cr = cairo_create(surface);
// g_print("segs_on1 = %i (%i), segs_on2 = %i (%i)\n", segs_on1, level1, segs_on2, level2);
for (seg = 0; seg < green_segments; seg++) {
gdk_draw_rectangle(pixmap[idx],
segs_on1 > 0 ? penGreenLight[idx] : penGreenShadow[idx],
TRUE,
6, 3 + ((segments - seg - 1) * 4),
segment_width,
3);
// Set the drawing color
if (segs_on1 > 0) {
cairo_set_source_rgb(cr, penGreenLight[idx]->red,
penGreenLight[idx]->green,
penGreenLight[idx]->blue);
} else {
cairo_set_source_rgb(cr, penGreenShadow[idx]->red,
penGreenShadow[idx]->green,
penGreenShadow[idx]->blue);
}
// Set the rectangle and draw
cairo_rectangle(cr, 6, 3 + ((segments - seg - 1) * 4), segment_width, 3);
cairo_fill(cr);
if (stereo)
gdk_draw_rectangle(pixmap[idx],
segs_on2 > 0 ? penGreenLight[idx] : penGreenShadow[idx],
TRUE,
2 + (width / 2),
3 + ((segments - seg - 1) * 4),
segment_width,
3);
{
// Set the drawing color
if (segs_on2 > 0) {
cairo_set_source_rgb(cr, penGreenLight[idx]->red,
penGreenLight[idx]->green,
penGreenLight[idx]->blue);
} else {
cairo_set_source_rgb(cr, penGreenShadow[idx]->red,
penGreenShadow[idx]->green,
penGreenShadow[idx]->blue);
}
// Set the rectangle and draw
cairo_rectangle(cr, 2 + (width / 2), 3 + ((segments - seg - 1) * 4), segment_width, 3);
cairo_fill(cr);
}
segs_on1--;
segs_on2--;
}
for (seg = green_segments; seg < green_segments + orange_segments; seg++) {
gdk_draw_rectangle(pixmap[idx],
segs_on1 > 0 ? penOrangeLight[idx] : penOrangeShadow[idx],
TRUE,
6, 3 + ((segments - seg - 1) * 4),
segment_width,
3);
// Set the drawing color
if (segs_on1 > 0) {
cairo_set_source_rgb(cr, penOrangeLight[idx]->red,
penOrangeLight[idx]->green,
penOrangeLight[idx]->blue);
} else {
cairo_set_source_rgb(cr, penOrangeShadow[idx]->red,
penOrangeShadow[idx]->green,
penOrangeShadow[idx]->blue);
}
// Set the rectangle and draw
cairo_rectangle(cr, 6, 3 + ((segments - seg - 1) * 4), segment_width, 3);
cairo_fill(cr);
if (stereo)
gdk_draw_rectangle(pixmap[idx],
segs_on2 > 0 ? penOrangeLight[idx] : penOrangeShadow[idx],
TRUE,
2 + (width / 2),
3 + ((segments - seg - 1) * 4),
segment_width,
3);
{
// Set the drawing color
if (segs_on2 > 0) {
cairo_set_source_rgb(cr, penOrangeLight[idx]->red,
penOrangeLight[idx]->green,
penOrangeLight[idx]->blue);
} else {
cairo_set_source_rgb(cr, penOrangeShadow[idx]->red,
penOrangeShadow[idx]->green,
penOrangeShadow[idx]->blue);
}
// Set the rectangle and draw
cairo_rectangle(cr, 2 + (width / 2), 3 + ((segments - seg - 1) * 4), segment_width, 3);
cairo_fill(cr);
}
segs_on1--;
segs_on2--;
}
for (seg = green_segments + orange_segments; seg < segments; seg++) {
gdk_draw_rectangle(pixmap[idx],
segs_on1 > 0 ? penRedLight[idx] : penRedShadow[idx],
TRUE,
6, 3 + ((segments - seg - 1) * 4),
segment_width,
3);
// Set the drawing color
if (segs_on1 > 0) {
cairo_set_source_rgb(cr, penRedLight[idx]->red,
penRedLight[idx]->green,
penRedLight[idx]->blue);
} else {
cairo_set_source_rgb(cr, penRedShadow[idx]->red,
penRedShadow[idx]->green,
penRedShadow[idx]->blue);
}
// Set the rectangle and draw
cairo_rectangle(cr, 6, 3 + ((segments - seg - 1) * 4), segment_width, 3);
cairo_fill(cr);
if (stereo)
gdk_draw_rectangle(pixmap[idx],
segs_on2 > 0 ? penRedLight[idx] : penRedShadow[idx],
TRUE,
2 + (width / 2),
3 + ((segments - seg - 1) * 4),
segment_width,
3);
{
// Set the drawing color based on segs_on2
if (segs_on2 > 0) {
cairo_set_source_rgb(cr, penRedLight[idx]->red,
penRedLight[idx]->green,
penRedLight[idx]->blue);
} else {
cairo_set_source_rgb(cr, penRedShadow[idx]->red,
penRedShadow[idx]->green,
penRedShadow[idx]->blue);
}
// Set the rectangle and draw
cairo_rectangle(cr, 2 + (width / 2), 3 + ((segments - seg - 1) * 4), segment_width, 3);
cairo_fill(cr);
}
segs_on1--;
segs_on2--;
}
// Clean up the Cairo context
cairo_destroy(cr);
}
gint level_meters_configure_event(GtkWidget *widget, GdkEventConfigure *event)
@ -153,25 +216,45 @@ gint level_meters_configure_event(GtkWidget *widget, GdkEventConfigure *event)
int idx = get_index(gtk_widget_get_name(widget));
if (pixmap[idx] != NULL)
gdk_pixmap_unref(pixmap[idx]);
pixmap[idx] = gdk_pixmap_new(widget->window,
widget->allocation.width,
widget->allocation.height,
-1);
g_object_unref(pixmap[idx]);
cairo_surface_t *surface = gdk_window_create_similar_surface(gtk_widget_get_window(widget),
CAIRO_FORMAT_ARGB32, gtk_widget_get_allocated_width(widget), gtk_widget_get_allocated_height(widget));
// Create a GdkPixbuf from the cairo surface
pixmap[idx] = gdk_pixbuf_get_from_surface(surface, 0, 0, gtk_widget_get_allocated_width(widget), gtk_widget_get_allocated_height(widget));
penGreenShadow[idx] = get_pen(idx, 0, 0x77ff, 0);
penGreenLight[idx] = get_pen(idx, 0, 0xffff, 0);
penOrangeShadow[idx] = get_pen(idx, 0xddff, 0x55ff, 0);
penOrangeLight[idx] = get_pen(idx, 0xffff, 0x99ff, 0);
penRedShadow[idx] = get_pen(idx, 0xaaff, 0, 0);
penRedLight[idx] = get_pen(idx, 0xffff, 0, 0);
gdk_draw_rectangle(pixmap[idx],
widget->style->black_gc,
TRUE,
0, 0,
widget->allocation.width,
widget->allocation.height);
// g_print("configure: %i:%i\n", widget->allocation.width, widget->allocation.height);
redraw_meters(idx, widget->allocation.width, widget->allocation.height, 0, 0);
// Get the window for the widget
GdkWindow *window = gtk_widget_get_window(widget);
// Begin drawing on the window (this replaces gdk_cairo_create)
GdkDrawingContext *context = gdk_window_begin_draw_frame(window, NULL);
// Get the Cairo context from the drawing context
cairo_t *cr = gdk_drawing_context_get_cairo_context(context);
//cairo_t *cr = gdk_cairo_create(gtk_widget_get_window(widget)); //DEPRECATED
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
// Set the source color (black in this case)
cairo_set_source_rgb(cr, 0.0, 0.0, 0.0); // RGB for black
// Create the rectangle with the specified dimensions
cairo_rectangle(cr, 0, 0, allocation.width, allocation.height);
// Fill the rectangle (similar to the "TRUE" parameter for filled in gdk_draw_rectangle)
cairo_fill(cr);
// g_print("configure: %i:%i\n", allocation.width, allocation.height);
redraw_meters(idx, allocation.width, allocation.height, 0, 0);
gdk_window_end_draw_frame(window, NULL); // End the draw frame
// Don't forget to manage memory and clean up
cairo_surface_destroy(surface);
return TRUE;
}
@ -179,18 +262,34 @@ gint level_meters_expose_event(GtkWidget *widget, GdkEventExpose *event)
{
int idx = get_index(gtk_widget_get_name(widget));
int l1, l2;
get_levels(idx, &l1, &l2);
redraw_meters(idx, widget->allocation.width, widget->allocation.height, l1, l2);
gdk_draw_pixmap(widget->window,
widget->style->black_gc,
pixmap[idx],
event->area.x, event->area.y,
event->area.x, event->area.y,
event->area.width, event->area.height);
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
redraw_meters(idx, allocation.width, allocation.height, l1, l2);
// Get the window for the widget
GdkWindow *window = gtk_widget_get_window(widget);
// Begin drawing on the window (this replaces gdk_cairo_create)
GdkDrawingContext *context = gdk_window_begin_draw_frame(window, NULL);
// Get the Cairo context from the drawing context
cairo_t *cr = gdk_drawing_context_get_cairo_context(context);
// Convert GdkPixbuf to Cairo surface
cairo_surface_t *surface = gdk_cairo_surface_create_from_pixbuf(pixmap[idx], 0, gtk_widget_get_window(widget));
// Set the source surface to the Cairo context
cairo_set_source_surface(cr, surface, event->area.x, event->area.y);
// Define the area to draw and fill it
cairo_rectangle(cr, event->area.x, event->area.y, event->area.width, event->area.height);
cairo_fill(cr);
// Clean up the Cairo surface
cairo_surface_destroy(surface);
// End the drawing frame
gdk_window_end_draw_frame(window, context);
return FALSE;
}
//TODO: Reduce/Remove/Refactor repeated code
gint level_meters_timeout_callback(gpointer data)
{
GtkWidget *widget;
@ -200,56 +299,112 @@ gint level_meters_timeout_callback(gpointer data)
for (idx = 0; idx <= pcm_output_channels; idx++) {
get_levels(idx, &l1, &l2);
widget = idx == 0 ? mixer_mix_drawing : mixer_drawing[idx-1];
if (GTK_WIDGET_VISIBLE(widget) && (pixmap[idx] != NULL)) {
redraw_meters(idx, widget->allocation.width, widget->allocation.height, l1, l2);
gdk_draw_pixmap(widget->window,
widget->style->black_gc,
pixmap[idx],
0, 0,
0, 0,
widget->allocation.width, widget->allocation.height);
if (gtk_widget_get_visible(widget) && (pixmap[idx] != NULL)) {
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
redraw_meters(idx, allocation.width, allocation.height, l1, l2);
// Get the window for the widget
GdkWindow *window = gtk_widget_get_window(widget);
// Begin drawing on the window
GdkDrawingContext *context = gdk_window_begin_draw_frame(window, NULL);
// Get the Cairo context from the drawing context
cairo_t *cr = gdk_drawing_context_get_cairo_context(context);
// Create a Cairo surface from the pixmap
cairo_surface_t *surface = gdk_cairo_surface_create_from_pixbuf(pixmap[idx], 0, window);
// Set the source surface to the pixmap (Cairo surface)
cairo_set_source_surface(cr, surface, 0, 0);
// Define the area to draw (same as the width and height of the widget)
cairo_rectangle(cr, 0, 0, allocation.width, allocation.height);
cairo_fill(cr); // Fill the rectangle with the pixmap
// Clean up the Cairo surface
cairo_surface_destroy(surface);
// End the drawing frame
gdk_window_end_draw_frame(window, context);
}
}
if (view_spdif_playback) {
for (idx = MAX_PCM_OUTPUT_CHANNELS + 1; idx <= MAX_OUTPUT_CHANNELS + spdif_channels; idx++) {
get_levels(idx, &l1, &l2);
widget = idx == 0 ? mixer_mix_drawing : mixer_drawing[idx-1];
if (GTK_WIDGET_VISIBLE(widget) && (pixmap[idx] != NULL)) {
redraw_meters(idx, widget->allocation.width, widget->allocation.height, l1, l2);
gdk_draw_pixmap(widget->window,
widget->style->black_gc,
pixmap[idx],
0, 0,
0, 0,
widget->allocation.width, widget->allocation.height);
if (gtk_widget_get_visible(widget) && (pixmap[idx] != NULL)) {
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
redraw_meters(idx, allocation.width, allocation.height, l1, l2);
// Get the window for the widget
GdkWindow *window = gtk_widget_get_window(widget);
// Begin drawing on the window
GdkDrawingContext *context = gdk_window_begin_draw_frame(window, NULL);
// Get the Cairo context from the drawing context
cairo_t *cr = gdk_drawing_context_get_cairo_context(context);
// Create a Cairo surface from the pixmap
cairo_surface_t *surface = gdk_cairo_surface_create_from_pixbuf(pixmap[idx], 0, window);
// Set the source surface to the pixmap (Cairo surface)
cairo_set_source_surface(cr, surface, 0, 0);
// Define the area to draw (same as the width and height of the widget)
cairo_rectangle(cr, 0, 0, allocation.width, allocation.height);
cairo_fill(cr); // Fill the rectangle with the pixmap
// Clean up the Cairo surface
cairo_surface_destroy(surface);
// End the drawing frame
gdk_window_end_draw_frame(window, context);
}
}
}
for (idx = MAX_PCM_OUTPUT_CHANNELS + MAX_SPDIF_CHANNELS + 1; idx <= input_channels + MAX_PCM_OUTPUT_CHANNELS + MAX_SPDIF_CHANNELS; idx++) {
get_levels(idx, &l1, &l2);
widget = idx == 0 ? mixer_mix_drawing : mixer_drawing[idx-1];
if (GTK_WIDGET_VISIBLE(widget) && (pixmap[idx] != NULL)) {
redraw_meters(idx, widget->allocation.width, widget->allocation.height, l1, l2);
gdk_draw_pixmap(widget->window,
widget->style->black_gc,
pixmap[idx],
0, 0,
0, 0,
widget->allocation.width, widget->allocation.height);
if (gtk_widget_get_visible(widget) && (pixmap[idx] != NULL)) {
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
redraw_meters(idx, allocation.width, allocation.height, l1, l2);
// Get the window for the widget
GdkWindow *window = gtk_widget_get_window(widget);
// Begin drawing on the window
GdkDrawingContext *context = gdk_window_begin_draw_frame(window, NULL);
// Get the Cairo context from the drawing context
cairo_t *cr = gdk_drawing_context_get_cairo_context(context);
// Create a Cairo surface from the pixmap
cairo_surface_t *surface = gdk_cairo_surface_create_from_pixbuf(pixmap[idx], 0, window);
// Set the source surface to the pixmap (Cairo surface)
cairo_set_source_surface(cr, surface, 0, 0);
// Define the area to draw (same as the width and height of the widget)
cairo_rectangle(cr, 0, 0, allocation.width, allocation.height);
cairo_fill(cr); // Fill the rectangle with the pixmap
// Clean up the Cairo surface
cairo_surface_destroy(surface);
// End the drawing frame
gdk_window_end_draw_frame(window, context);
}
}
for (idx = MAX_PCM_OUTPUT_CHANNELS + MAX_SPDIF_CHANNELS + MAX_INPUT_CHANNELS + 1; \
idx <= spdif_channels + MAX_PCM_OUTPUT_CHANNELS + MAX_SPDIF_CHANNELS + MAX_INPUT_CHANNELS; idx++) {
get_levels(idx, &l1, &l2);
widget = idx == 0 ? mixer_mix_drawing : mixer_drawing[idx-1];
if (GTK_WIDGET_VISIBLE(widget) && (pixmap[idx] != NULL)) {
redraw_meters(idx, widget->allocation.width, widget->allocation.height, l1, l2);
gdk_draw_pixmap(widget->window,
widget->style->black_gc,
pixmap[idx],
0, 0,
0, 0,
widget->allocation.width, widget->allocation.height);
if (gtk_widget_get_visible(widget) && (pixmap[idx] != NULL)) {
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
redraw_meters(idx, allocation.width, allocation.height, l1, l2);
// Get the window for the widget
GdkWindow *window = gtk_widget_get_window(widget);
// Begin drawing on the window
GdkDrawingContext *context = gdk_window_begin_draw_frame(window, NULL);
// Get the Cairo context from the drawing context
cairo_t *cr = gdk_drawing_context_get_cairo_context(context);
// Create a Cairo surface from the pixmap
cairo_surface_t *surface = gdk_cairo_surface_create_from_pixbuf(pixmap[idx], 0, window);
// Set the source surface to the pixmap (Cairo surface)
cairo_set_source_surface(cr, surface, 0, 0);
// Define the area to draw (same as the width and height of the widget)
cairo_rectangle(cr, 0, 0, allocation.width, allocation.height);
cairo_fill(cr); // Fill the rectangle with the pixmap
// Clean up the Cairo surface
cairo_surface_destroy(surface);
// End the drawing frame
gdk_window_end_draw_frame(window, context);
}
}
return TRUE;

View file

@ -243,7 +243,7 @@ int midi_init(char *appname, int channel, int midi_enhanced)
void mixer_adjust(GtkAdjustment *adj, gpointer data);
void mixer_set_mute(int stream, int left, int right);
void midi_process(gpointer data, gint source, GdkInputCondition condition)
gint midi_process(GIOChannel *source, GIOCondition condition, gpointer data)
{
snd_seq_event_t *ev;
static GtkAdjustment *adj=0;
@ -306,6 +306,7 @@ void midi_process(gpointer data, gint source, GdkInputCondition condition)
snd_seq_free_event(ev);
}
while (snd_seq_event_input_pending(seq, 0) > 0);
return TRUE;
}
/* ************************************************* */

View file

@ -7,7 +7,7 @@ int midi_init(char *appname, int channel, int midi_enhanced);
int midi_close();
void midi_maxstreams(int);
int midi_controller(int c, int v);
void midi_process(gpointer data, gint source, GdkInputCondition condition);
gint midi_process(GIOChannel *source, GIOCondition condition, gpointer data);
int midi_button(int b, int v);
#endif

View file

@ -39,13 +39,13 @@ extern int input_channels, output_channels, pcm_output_channels, spdif_channels,
static int is_active(GtkWidget *widget)
{
return GTK_TOGGLE_BUTTON(widget)->active ? 1 : 0;
return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
}
void mixer_update_stream(int stream, int vol_flag, int sw_flag)
{
int err;
if (! stream_is_active[stream - 1])
return;
@ -180,12 +180,13 @@ void mixer_adjust(GtkAdjustment *adj, gpointer data)
int button = (long)data & 1;
int stereo = is_active(mixer_stereo_toggle[stream-1]) ? 1 : 0;
int vol[2] = { -1, -1 };
vol[button] = 96 - adj->value;
if (stereo) {
gtk_adjustment_set_value(GTK_ADJUSTMENT(mixer_adj[stream-1][button ^ 1]), adj->value);
vol[button ^ 1] = 96 - adj->value;
}
double adjustment_value = gtk_adjustment_get_value(adj);
vol[button] = 96 - adjustment_value;
if (stereo) {
gtk_adjustment_set_value(GTK_ADJUSTMENT(mixer_adj[stream-1][button ^ 1]), adjustment_value);
vol[button ^ 1] = 96 - adjustment_value;
}
set_volume1(stream, vol[0], vol[1]);
}

View file

@ -30,7 +30,7 @@ extern int output_channels, input_channels, pcm_output_channels, spdif_channels;
static int is_active(GtkWidget *widget)
{
return GTK_TOGGLE_BUTTON(widget)->active ? 1 : 0;
return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
}
static int get_toggle_index(int stream)

View file

@ -105,9 +105,6 @@ int envy_analog_volume_available(void)
}
/*
*/
void dac_volume_update(int idx)
{
snd_ctl_elem_value_t *val;
@ -210,14 +207,12 @@ void adc_sense_update(int idx)
}
/*
*/
void dac_volume_adjust(GtkAdjustment *adj, gpointer data)
{
int idx = (int)(long)data;
snd_ctl_elem_value_t *val;
int err, ival = -(int)adj->value;
double adjustment_value = gtk_adjustment_get_value(adj);
int err, ival = -(int)adjustment_value;
char text[16];
snd_ctl_elem_value_alloca(&val);
@ -235,7 +230,8 @@ void adc_volume_adjust(GtkAdjustment *adj, gpointer data)
{
int idx = (int)(long)data;
snd_ctl_elem_value_t *val;
int err, ival = -(int)adj->value;
double adjustment_value = gtk_adjustment_get_value(adj);
int err, ival = -(int)adjustment_value;
char text[16];
snd_ctl_elem_value_alloca(&val);
@ -253,7 +249,8 @@ void ipga_volume_adjust(GtkAdjustment *adj, gpointer data)
{
int idx = (int)(long)data;
snd_ctl_elem_value_t *val;
int err, ival = -(int)adj->value;
double adjustment_value = gtk_adjustment_get_value(adj);
int err, ival = -(int)adjustment_value;
char text[16];
snd_ctl_elem_value_alloca(&val);
@ -299,9 +296,6 @@ void adc_sense_toggled(GtkWidget *togglebutton, gpointer data)
g_print("Unable to write adc sense: %s\n", snd_strerror(err));
}
/*
*/
void analog_volume_init(void)
{
snd_ctl_elem_info_t *info;

View file

@ -4,6 +4,6 @@ AM_MAINTAINER_MODE([enable])
AC_PROG_CC
AC_PROG_INSTALL
AC_HEADER_STDC
PKG_CHECK_MODULES(RMEDIGICONTROL, gtk+-2.0 alsa >= 1.0.0)
PKG_CHECK_MODULES(RMEDIGICONTROL, gtk+-3.0 alsa >= 1.0.0)
AC_OUTPUT(Makefile)

View file

@ -13,7 +13,7 @@
GNU General Public License for more details.
*****************************************************************************/
#include "rmedigicontrol.h"
#include "rmedigicontrol.h"
static snd_ctl_elem_value_t *val;
static snd_ctl_elem_info_t *info;
@ -24,21 +24,22 @@ static char *val2char(gdouble val)
sprintf(vlab,"%2.0f",100-val);
return(vlab);
}
static void changed(GtkAdjustment *a,gpointer p)
static void changed(GtkAdjustment *a, gpointer p)
{
snd_ctl_elem_value_set_integer(val,0,((100-a->value)*snd_ctl_elem_info_get_max(info))/100);
snd_ctl_elem_value_set_integer(val,1,((100-a->value)*snd_ctl_elem_info_get_max(info))/100);
snd_ctl_elem_write(ctl,val);
gtk_label_set_text(p,val2char(a->value));
double value = gtk_adjustment_get_value(a);
int adjusted_value = ((100 - value) * snd_ctl_elem_info_get_max(info)) / 100;
snd_ctl_elem_value_set_integer(val, 0, adjusted_value);
snd_ctl_elem_value_set_integer(val, 1, adjusted_value);
snd_ctl_elem_write(ctl, val);
gtk_label_set_text(GTK_LABEL(p), val2char(value));
}
GtkWidget *create_level_box()
{
GtkObject *adjust;
GtkAdjustment *adjust;
GtkWidget *box,*slider1,*label1,*vlabel;
char *elem_name="DAC Playback Volume";
box=gtk_vbox_new(FALSE,2);
box=gtk_box_new(GTK_ORIENTATION_VERTICAL, 2);
snd_ctl_elem_info_malloc(&info);
snd_ctl_elem_value_malloc(&val);
@ -47,19 +48,25 @@ GtkWidget *create_level_box()
snd_ctl_elem_info_set_name(info,elem_name);
snd_ctl_elem_info_set_numid(info,0);
snd_ctl_elem_info(ctl,info);
snd_ctl_elem_value_set_interface(val,SND_CTL_ELEM_TYPE_INTEGER);
snd_ctl_elem_value_set_name(val,elem_name);
snd_ctl_elem_read(ctl,val);
adjust=GTK_OBJECT(gtk_adjustment_new(100-(snd_ctl_elem_value_get_integer(val,0)*100)/snd_ctl_elem_info_get_max(info),0,100,1,5,0));
vlabel=gtk_label_new(val2char((GTK_ADJUSTMENT(adjust))->value));
gtk_signal_connect(adjust,"value_changed",GTK_SIGNAL_FUNC(changed),vlabel);
slider1=gtk_vscale_new(GTK_ADJUSTMENT(adjust));
adjust = gtk_adjustment_new(
100 - (snd_ctl_elem_value_get_integer(val, 0) * 100) / snd_ctl_elem_info_get_max(info),
0, // lower
100, // upper
1, // step increment
5, // page increment
0 // page size
);
vlabel = gtk_label_new(val2char(gtk_adjustment_get_value(adjust)));
g_signal_connect(adjust,"value_changed",G_CALLBACK(changed),vlabel);
slider1=gtk_scale_new(GTK_ORIENTATION_VERTICAL, adjust);
gtk_scale_set_draw_value(GTK_SCALE(slider1),FALSE);
gtk_scale_set_digits(GTK_SCALE(slider1),0);
label1=gtk_label_new("Level");
gtk_box_pack_start(GTK_BOX(box),label1,FALSE,TRUE,5);
gtk_box_pack_start(GTK_BOX(box),slider1,TRUE,TRUE,5);

View file

@ -13,7 +13,7 @@
GNU General Public License for more details.
******************************************************************************/
#include "rmedigicontrol.h"
#include "rmedigicontrol.h"
static snd_ctl_elem_value_t *val;
@ -28,18 +28,18 @@ GtkWidget *create_loopback_toggle()
GtkWidget *t;
GtkWidget *box;
char *elem_name="Loopback Input";
box=gtk_hbox_new(FALSE,0);
snd_ctl_elem_value_malloc(&val);
snd_ctl_elem_value_set_interface(val, SND_CTL_ELEM_IFACE_MIXER);
snd_ctl_elem_value_set_name(val,elem_name);
snd_ctl_elem_read(ctl, val);
t=gtk_check_button_new_with_label(elem_name);
gtk_signal_connect(GTK_OBJECT(t),"toggled",GTK_SIGNAL_FUNC(loopback_toggled),NULL);
g_signal_connect(t,"toggled",G_CALLBACK(loopback_toggled),NULL);
if(snd_ctl_elem_value_get_integer(val,0))
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(t),TRUE);

View file

@ -23,7 +23,7 @@ ctl_elem_info_val_t att_iv;
void destroy(GtkWidget *widget,gpointer data)
{
snd_ctl_close(ctl);
snd_ctl_close(ctl);
gtk_main_quit();
}
int main(int argc, char *argv[])
@ -32,7 +32,7 @@ int main(int argc, char *argv[])
char name[16],*err;
snd_ctl_card_info_t *hw_info;
card_type_t type;
GtkWidget *window,*main_box,*input_box,*loopback_box,*clock_box,*monitor_box,*att_box,*level_box;
GtkWidget *col1_box,*col2_box,*err_lbl;
snd_ctl_card_info_alloca(&hw_info);
@ -76,27 +76,27 @@ int main(int argc, char *argv[])
}
if(card<0)
err="No RME Digi Soundcard found...";
gtk_init(&argc, &argv);
gtk_init(&argc, &argv);
window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_signal_connect(GTK_OBJECT(window),"destroy",GTK_SIGNAL_FUNC(destroy),NULL);
g_signal_connect(window,"destroy",G_CALLBACK(destroy),NULL);
if(err)
{
err_lbl=gtk_label_new(err);
gtk_container_add(GTK_CONTAINER(window),err_lbl);
gtk_widget_show_all(window);
gtk_main ();
exit(EXIT_FAILURE);
gtk_main ();
exit(EXIT_FAILURE);
}
gtk_window_set_title(GTK_WINDOW(window),snd_ctl_card_info_get_name(hw_info));
//-Wdeprecated-declarations
main_box=gtk_hbox_new(FALSE,0);
col1_box=gtk_vbox_new(FALSE,0);
col2_box=gtk_vbox_new(FALSE,0);
col1_box=gtk_vbox_new(FALSE,0);
col2_box=gtk_vbox_new(FALSE,0);
input_box=create_enum_elem_radio("Input Connector",&input_iv);
gtk_box_pack_start(GTK_BOX(col1_box),input_box,TRUE,FALSE,0);
loopback_box=create_loopback_toggle();
gtk_box_pack_start(GTK_BOX(col1_box),loopback_box,TRUE,FALSE,0);
@ -109,7 +109,7 @@ int main(int argc, char *argv[])
{
monitor_box=create_enum_elem_radio("Monitor Tracks",&monitor_iv);
gtk_box_pack_start(GTK_BOX(col2_box),monitor_box,TRUE,FALSE,0);
att_box=create_enum_elem_radio("Attenuation",&att_iv);
gtk_box_pack_start(GTK_BOX(col2_box),att_box,TRUE,FALSE,0);
@ -118,7 +118,7 @@ int main(int argc, char *argv[])
level_box=create_level_box();
gtk_box_pack_start(GTK_BOX(main_box),level_box,TRUE,TRUE,8);
}
gtk_container_add(GTK_CONTAINER(window),main_box);
gtk_container_add(GTK_CONTAINER(window),main_box);
gtk_widget_show_all(window);
gtk_main ();
return EXIT_SUCCESS;
@ -128,9 +128,9 @@ void elem_radio_toggled(GtkRadioButton *r,gpointer p)
int i;
GSList *l;
ctl_elem_info_val_t *iv;
iv=(ctl_elem_info_val_t *)p;
l=gtk_radio_button_group(r);
l=gtk_radio_button_get_group(r);
i=snd_ctl_elem_info_get_items(iv->info);
while(l)
{
@ -151,27 +151,27 @@ GtkWidget *create_enum_elem_radio(char *elem_name,ctl_elem_info_val_t *iv)
snd_ctl_elem_info_malloc(&iv->info);
snd_ctl_elem_value_malloc(&iv->val);
group=NULL;
active=NULL;
box=gtk_vbox_new(TRUE,0);
box=gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
snd_ctl_elem_info_set_interface(iv->info, SND_CTL_ELEM_IFACE_MIXER);
snd_ctl_elem_info_set_name(iv->info,elem_name);
snd_ctl_elem_info_set_numid(iv->info,0);
snd_ctl_elem_info(ctl,iv->info);
snd_ctl_elem_value_set_interface(iv->val, SND_CTL_ELEM_IFACE_MIXER);
snd_ctl_elem_value_set_name(iv->val,elem_name);
snd_ctl_elem_read(ctl,iv->val);
for(i=0;i<snd_ctl_elem_info_get_items(iv->info);i++)
{
snd_ctl_elem_info_set_item(iv->info, i);
snd_ctl_elem_info(ctl,iv->info);
r=gtk_radio_button_new_with_label(group,snd_ctl_elem_info_get_item_name(iv->info));
group=gtk_radio_button_group(GTK_RADIO_BUTTON(r));
gtk_signal_connect(GTK_OBJECT(r),"toggled",GTK_SIGNAL_FUNC(elem_radio_toggled),(gpointer)iv);
r=gtk_radio_button_new_with_label_from_widget(GTK_RADIO_BUTTON(r),
snd_ctl_elem_info_get_item_name(iv->info));
g_signal_connect(r,"toggled",G_CALLBACK(elem_radio_toggled),(gpointer)iv);
if(i==snd_ctl_elem_value_get_integer(iv->val,0))
active=r;
gtk_box_pack_start(GTK_BOX(box),r,TRUE,FALSE,0);