Let it compile with the OSS headers (not implemented though)
This commit is contained in:
parent
dfe53e2052
commit
ab3560521f
64
src/mixer.c
64
src/mixer.c
|
@ -17,8 +17,12 @@ static char _license[] =
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <sys/ioctl.h>
|
#if defined(__NetBSD__) || defined(__sun__)
|
||||||
#include <sys/audioio.h>
|
# include <sys/ioctl.h>
|
||||||
|
# include <sys/audioio.h>
|
||||||
|
#else
|
||||||
|
# include <sys/soundcard.h>
|
||||||
|
#endif
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -39,25 +43,31 @@ static char _license[] =
|
||||||
/* Mixer */
|
/* Mixer */
|
||||||
/* private */
|
/* private */
|
||||||
/* types */
|
/* types */
|
||||||
|
#ifdef AUDIO_MIXER_DEVINFO
|
||||||
typedef struct _MixerClass
|
typedef struct _MixerClass
|
||||||
{
|
{
|
||||||
int mixer_class;
|
int mixer_class;
|
||||||
audio_mixer_name_t label;
|
audio_mixer_name_t label;
|
||||||
GtkWidget * hbox;
|
GtkWidget * hbox;
|
||||||
} MixerClass;
|
} MixerClass;
|
||||||
|
#endif
|
||||||
|
|
||||||
struct _Mixer
|
struct _Mixer
|
||||||
{
|
{
|
||||||
int fd;
|
|
||||||
|
|
||||||
/* widgets */
|
/* widgets */
|
||||||
GtkWidget * window;
|
GtkWidget * window;
|
||||||
GtkWidget * properties;
|
GtkWidget * properties;
|
||||||
GtkWidget * about;
|
GtkWidget * about;
|
||||||
|
|
||||||
/* internals */
|
/* internals */
|
||||||
|
#ifdef AUDIO_MIXER_DEVINFO
|
||||||
|
int fd;
|
||||||
|
|
||||||
MixerClass * mc;
|
MixerClass * mc;
|
||||||
size_t mc_cnt;
|
size_t mc_cnt;
|
||||||
|
#else
|
||||||
|
int fd;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -113,16 +123,20 @@ static DesktopMenubar _mixer_menubar[] =
|
||||||
|
|
||||||
/* prototypes */
|
/* prototypes */
|
||||||
static int _mixer_error(Mixer * mixer, char const * message, int ret);
|
static int _mixer_error(Mixer * mixer, char const * message, int ret);
|
||||||
|
#ifdef AUDIO_MIXER_DEVINFO
|
||||||
static mixer_ctrl_t * _mixer_get(Mixer * mixer, int dev);
|
static mixer_ctrl_t * _mixer_get(Mixer * mixer, int dev);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* public */
|
/* public */
|
||||||
/* mixer_new */
|
/* mixer_new */
|
||||||
|
#ifdef AUDIO_MIXER_DEVINFO
|
||||||
static GtkWidget * _new_enum(Mixer * mixer, int dev,
|
static GtkWidget * _new_enum(Mixer * mixer, int dev,
|
||||||
struct audio_mixer_enum * e);
|
struct audio_mixer_enum * e);
|
||||||
static GtkWidget * _new_set(Mixer * mixer, int dev, struct audio_mixer_set * s);
|
static GtkWidget * _new_set(Mixer * mixer, int dev, struct audio_mixer_set * s);
|
||||||
static GtkWidget * _new_value(Mixer * mixer, int dev,
|
static GtkWidget * _new_value(Mixer * mixer, int dev,
|
||||||
struct audio_mixer_value * v);
|
struct audio_mixer_value * v);
|
||||||
|
#endif
|
||||||
|
|
||||||
Mixer * mixer_new(char const * device, MixerOrientation orientation)
|
Mixer * mixer_new(char const * device, MixerOrientation orientation)
|
||||||
{
|
{
|
||||||
|
@ -135,8 +149,10 @@ Mixer * mixer_new(char const * device, MixerOrientation orientation)
|
||||||
GtkWidget * hbox;
|
GtkWidget * hbox;
|
||||||
GtkWidget * control;
|
GtkWidget * control;
|
||||||
int i;
|
int i;
|
||||||
|
#ifdef AUDIO_MIXER_DEVINFO
|
||||||
mixer_devinfo_t md;
|
mixer_devinfo_t md;
|
||||||
MixerClass * p;
|
MixerClass * p;
|
||||||
|
#endif
|
||||||
size_t u;
|
size_t u;
|
||||||
|
|
||||||
if((mixer = malloc(sizeof(*mixer))) == NULL)
|
if((mixer = malloc(sizeof(*mixer))) == NULL)
|
||||||
|
@ -147,8 +163,10 @@ Mixer * mixer_new(char const * device, MixerOrientation orientation)
|
||||||
mixer->window = NULL;
|
mixer->window = NULL;
|
||||||
mixer->properties = NULL;
|
mixer->properties = NULL;
|
||||||
mixer->about = NULL;
|
mixer->about = NULL;
|
||||||
|
#ifdef AUDIO_MIXER_DEVINFO
|
||||||
mixer->mc = NULL;
|
mixer->mc = NULL;
|
||||||
mixer->mc_cnt = 0;
|
mixer->mc_cnt = 0;
|
||||||
|
#endif
|
||||||
if(mixer->fd < 0)
|
if(mixer->fd < 0)
|
||||||
{
|
{
|
||||||
_mixer_error(NULL, device, 0);
|
_mixer_error(NULL, device, 0);
|
||||||
|
@ -183,6 +201,7 @@ Mixer * mixer_new(char const * device, MixerOrientation orientation)
|
||||||
hvbox = gtk_hbox_new(FALSE, 0);
|
hvbox = gtk_hbox_new(FALSE, 0);
|
||||||
for(i = 0;; i++)
|
for(i = 0;; i++)
|
||||||
{
|
{
|
||||||
|
#ifdef AUDIO_MIXER_DEVINFO
|
||||||
md.index = i;
|
md.index = i;
|
||||||
if(ioctl(mixer->fd, AUDIO_MIXER_DEVINFO, &md) < 0)
|
if(ioctl(mixer->fd, AUDIO_MIXER_DEVINFO, &md) < 0)
|
||||||
break;
|
break;
|
||||||
|
@ -200,12 +219,17 @@ Mixer * mixer_new(char const * device, MixerOrientation orientation)
|
||||||
p->mixer_class = md.mixer_class;
|
p->mixer_class = md.mixer_class;
|
||||||
memcpy(&p->label, &md.label, sizeof(md.label));
|
memcpy(&p->label, &md.label, sizeof(md.label));
|
||||||
p->hbox = NULL;
|
p->hbox = NULL;
|
||||||
|
#else
|
||||||
|
/* FIXME implement */
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled),
|
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled),
|
||||||
hvbox);
|
hvbox);
|
||||||
/* controls */
|
/* controls */
|
||||||
for(i = 0;; i++)
|
for(i = 0;; i++)
|
||||||
{
|
{
|
||||||
|
#ifdef AUDIO_MIXER_DEVINFO
|
||||||
md.index = i;
|
md.index = i;
|
||||||
if(ioctl(mixer->fd, AUDIO_MIXER_DEVINFO, &md) < 0)
|
if(ioctl(mixer->fd, AUDIO_MIXER_DEVINFO, &md) < 0)
|
||||||
break;
|
break;
|
||||||
|
@ -242,11 +266,17 @@ Mixer * mixer_new(char const * device, MixerOrientation orientation)
|
||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, TRUE, 2);
|
gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, TRUE, 2);
|
||||||
|
#else
|
||||||
|
/* FIXME implement */
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
gtk_box_pack_start(GTK_BOX(vbox), scrolled, TRUE, TRUE, 0);
|
gtk_box_pack_start(GTK_BOX(vbox), scrolled, TRUE, TRUE, 0);
|
||||||
gtk_container_add(GTK_CONTAINER(mixer->window), vbox);
|
gtk_container_add(GTK_CONTAINER(mixer->window), vbox);
|
||||||
gtk_widget_show_all(vbox);
|
gtk_widget_show_all(vbox);
|
||||||
|
#ifdef AUDIO_MIXER_DEVINFO
|
||||||
mixer_show_class(mixer, AudioCoutputs);
|
mixer_show_class(mixer, AudioCoutputs);
|
||||||
|
#endif
|
||||||
gtk_widget_show(mixer->window);
|
gtk_widget_show(mixer->window);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "DEBUG: %s() => %p\n", __func__, (void*)mixer);
|
fprintf(stderr, "DEBUG: %s() => %p\n", __func__, (void*)mixer);
|
||||||
|
@ -254,6 +284,7 @@ Mixer * mixer_new(char const * device, MixerOrientation orientation)
|
||||||
return mixer;
|
return mixer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef AUDIO_MIXER_DEVINFO
|
||||||
static GtkWidget * _new_enum(Mixer * mixer, int dev,
|
static GtkWidget * _new_enum(Mixer * mixer, int dev,
|
||||||
struct audio_mixer_enum * e)
|
struct audio_mixer_enum * e)
|
||||||
{
|
{
|
||||||
|
@ -363,6 +394,7 @@ static GtkWidget * _new_value(Mixer * mixer, int dev,
|
||||||
gtk_box_pack_start(GTK_BOX(vbox), bind, FALSE, TRUE, 0);
|
gtk_box_pack_start(GTK_BOX(vbox), bind, FALSE, TRUE, 0);
|
||||||
return vbox;
|
return vbox;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* mixer_delete */
|
/* mixer_delete */
|
||||||
|
@ -380,13 +412,16 @@ void mixer_delete(Mixer * mixer)
|
||||||
/* mixer_set_enum */
|
/* mixer_set_enum */
|
||||||
int mixer_set_enum(Mixer * mixer, GtkWidget * widget)
|
int mixer_set_enum(Mixer * mixer, GtkWidget * widget)
|
||||||
{
|
{
|
||||||
|
#ifdef AUDIO_MIXER_DEVINFO
|
||||||
mixer_ctrl_t * p;
|
mixer_ctrl_t * p;
|
||||||
int * q;
|
int * q;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "DEBUG: %s(%p) fd=%d\n", __func__, (void*)mixer,
|
fprintf(stderr, "DEBUG: %s(%p) fd=%d\n", __func__, (void*)mixer,
|
||||||
mixer->fd);
|
mixer->fd);
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef AUDIO_MIXER_DEVINFO
|
||||||
p = g_object_get_data(G_OBJECT(widget), "ctrl");
|
p = g_object_get_data(G_OBJECT(widget), "ctrl");
|
||||||
q = g_object_get_data(G_OBJECT(widget), "ord");
|
q = g_object_get_data(G_OBJECT(widget), "ord");
|
||||||
if(p == NULL || q == NULL)
|
if(p == NULL || q == NULL)
|
||||||
|
@ -399,22 +434,29 @@ int mixer_set_enum(Mixer * mixer, GtkWidget * widget)
|
||||||
if(ioctl(mixer->fd, AUDIO_MIXER_WRITE, p) == 0)
|
if(ioctl(mixer->fd, AUDIO_MIXER_WRITE, p) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
return _mixer_error(mixer, "AUDIO_MIXER_WRITE", 1);
|
return _mixer_error(mixer, "AUDIO_MIXER_WRITE", 1);
|
||||||
|
#else
|
||||||
|
/* FIXME implement */
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* mixer_set_value */
|
/* mixer_set_value */
|
||||||
int mixer_set_value(Mixer * mixer, GtkWidget * widget, gdouble value)
|
int mixer_set_value(Mixer * mixer, GtkWidget * widget, gdouble value)
|
||||||
{
|
{
|
||||||
|
#ifdef AUDIO_MIXER_DEVINFO
|
||||||
GtkWidget * b;
|
GtkWidget * b;
|
||||||
mixer_ctrl_t * p;
|
mixer_ctrl_t * p;
|
||||||
u_char * level;
|
u_char * level;
|
||||||
int i;
|
int i;
|
||||||
GSList * q;
|
GSList * q;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "DEBUG: %s(%p, %lf) fd=%d\n", __func__, (void*)mixer,
|
fprintf(stderr, "DEBUG: %s(%p, %lf) fd=%d\n", __func__, (void*)mixer,
|
||||||
value, mixer->fd);
|
value, mixer->fd);
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef AUDIO_MIXER_DEVINFO
|
||||||
b = g_object_get_data(G_OBJECT(widget), "bind");
|
b = g_object_get_data(G_OBJECT(widget), "bind");
|
||||||
p = g_object_get_data(G_OBJECT(widget), "ctrl");
|
p = g_object_get_data(G_OBJECT(widget), "ctrl");
|
||||||
level = g_object_get_data(G_OBJECT(widget), "channel");
|
level = g_object_get_data(G_OBJECT(widget), "channel");
|
||||||
|
@ -438,6 +480,10 @@ int mixer_set_value(Mixer * mixer, GtkWidget * widget, gdouble value)
|
||||||
if(ioctl(mixer->fd, AUDIO_MIXER_WRITE, p) == 0)
|
if(ioctl(mixer->fd, AUDIO_MIXER_WRITE, p) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
return _mixer_error(mixer, "AUDIO_MIXER_WRITE", 1);
|
return _mixer_error(mixer, "AUDIO_MIXER_WRITE", 1);
|
||||||
|
#else
|
||||||
|
/* FIXME implement */
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -466,18 +512,21 @@ void mixer_about(Mixer * mixer)
|
||||||
/* mixer_properties */
|
/* mixer_properties */
|
||||||
void mixer_properties(Mixer * mixer)
|
void mixer_properties(Mixer * mixer)
|
||||||
{
|
{
|
||||||
|
#ifdef AUDIO_MIXER_DEVINFO
|
||||||
audio_device_t ad;
|
audio_device_t ad;
|
||||||
GtkSizeGroup * left;
|
GtkSizeGroup * left;
|
||||||
GtkSizeGroup * right;
|
GtkSizeGroup * right;
|
||||||
GtkWidget * vbox;
|
GtkWidget * vbox;
|
||||||
GtkWidget * hbox;
|
GtkWidget * hbox;
|
||||||
GtkWidget * widget;
|
GtkWidget * widget;
|
||||||
|
#endif
|
||||||
|
|
||||||
if(mixer->properties != NULL)
|
if(mixer->properties != NULL)
|
||||||
{
|
{
|
||||||
gtk_widget_show(mixer->properties);
|
gtk_widget_show(mixer->properties);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#ifdef AUDIO_MIXER_DEVINFO
|
||||||
if(ioctl(mixer->fd, AUDIO_GETDEV, &ad) != 0)
|
if(ioctl(mixer->fd, AUDIO_GETDEV, &ad) != 0)
|
||||||
{
|
{
|
||||||
_mixer_error(mixer, "AUDIO_GETDEV", 1);
|
_mixer_error(mixer, "AUDIO_GETDEV", 1);
|
||||||
|
@ -528,12 +577,14 @@ void mixer_properties(Mixer * mixer)
|
||||||
g_signal_connect(mixer->properties, "response", G_CALLBACK(
|
g_signal_connect(mixer->properties, "response", G_CALLBACK(
|
||||||
gtk_widget_hide), NULL);
|
gtk_widget_hide), NULL);
|
||||||
gtk_widget_show(mixer->properties);
|
gtk_widget_show(mixer->properties);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* mixer_show */
|
/* mixer_show */
|
||||||
void mixer_show(Mixer * mixer, int view)
|
void mixer_show(Mixer * mixer, int view)
|
||||||
{
|
{
|
||||||
|
#ifdef AUDIO_MIXER_DEVINFO
|
||||||
size_t u;
|
size_t u;
|
||||||
|
|
||||||
if(view < 0)
|
if(view < 0)
|
||||||
|
@ -553,6 +604,7 @@ void mixer_show(Mixer * mixer, int view)
|
||||||
gtk_widget_show(mixer->mc[u].hbox);
|
gtk_widget_show(mixer->mc[u].hbox);
|
||||||
else
|
else
|
||||||
gtk_widget_hide(mixer->mc[u].hbox);
|
gtk_widget_hide(mixer->mc[u].hbox);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -566,6 +618,7 @@ void mixer_show_all(Mixer * mixer)
|
||||||
/* mixer_show_all */
|
/* mixer_show_all */
|
||||||
void mixer_show_class(Mixer * mixer, char const * name)
|
void mixer_show_class(Mixer * mixer, char const * name)
|
||||||
{
|
{
|
||||||
|
#ifdef AUDIO_MIXER_DEVINFO
|
||||||
size_t u;
|
size_t u;
|
||||||
|
|
||||||
for(u = 0; u < mixer->mc_cnt; u++)
|
for(u = 0; u < mixer->mc_cnt; u++)
|
||||||
|
@ -576,6 +629,7 @@ void mixer_show_class(Mixer * mixer, char const * name)
|
||||||
gtk_widget_show(mixer->mc[u].hbox);
|
gtk_widget_show(mixer->mc[u].hbox);
|
||||||
else
|
else
|
||||||
gtk_widget_hide(mixer->mc[u].hbox);
|
gtk_widget_hide(mixer->mc[u].hbox);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -614,6 +668,7 @@ static int _error_text(char const * message, int ret)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef AUDIO_MIXER_DEVINFO
|
||||||
/* mixer_get */
|
/* mixer_get */
|
||||||
static mixer_ctrl_t * _mixer_get(Mixer * mixer, int dev)
|
static mixer_ctrl_t * _mixer_get(Mixer * mixer, int dev)
|
||||||
{
|
{
|
||||||
|
@ -664,3 +719,4 @@ static mixer_ctrl_t * _mixer_get(Mixer * mixer, int dev)
|
||||||
#endif
|
#endif
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue
Block a user