mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-03 14:08:56 +00:00
sys/oss/gstosselement.*: Reworked enumeration of oss dsps and mixers so that gst-mixer works on my system using alsa ...
Original commit message from CVS: 2004-02-29 Christophe Fergeau <teuf@gnome.org> * sys/oss/gstosselement.c: (gst_osselement_probe), (device_combination_append), (gst_osselement_class_probe_devices): * sys/oss/gstosselement.h: Reworked enumeration of oss dsps and mixers so that gst-mixer works on my system using alsa oss emulation, fixes bug #135597
This commit is contained in:
parent
147a44ce03
commit
ce608897ab
3 changed files with 87 additions and 56 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2004-02-29 Christophe Fergeau <teuf@gnome.org>
|
||||||
|
|
||||||
|
* sys/oss/gstosselement.c: (gst_osselement_probe),
|
||||||
|
(device_combination_append), (gst_osselement_class_probe_devices):
|
||||||
|
* sys/oss/gstosselement.h:
|
||||||
|
Reworked enumeration of oss dsps and mixers so that gst-mixer works
|
||||||
|
on my system using alsa oss emulation, fixes bug #135597
|
||||||
|
|
||||||
2004-02-29 Ronald Bultje <rbultje@ronald.bitfreak.net>
|
2004-02-29 Ronald Bultje <rbultje@ronald.bitfreak.net>
|
||||||
|
|
||||||
* gst/videodrop/gstvideodrop.c: (gst_videodrop_init),
|
* gst/videodrop/gstvideodrop.c: (gst_videodrop_init),
|
||||||
|
|
|
@ -176,33 +176,62 @@ gst_ossprobe_get_properties (GstPropertyProbe *probe)
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* OSS (without devfs) allows at max. 16 devices */
|
||||||
|
#define MAX_OSS_DEVICES 16
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_osselement_probe (gchar *device_base,
|
gst_osselement_probe (gchar *device_base,
|
||||||
gint device_num,
|
gint device_num,
|
||||||
gchar **put)
|
gchar **name,
|
||||||
|
dev_t *devno)
|
||||||
{
|
{
|
||||||
gchar *device;
|
gchar *device = NULL;
|
||||||
struct stat s;
|
struct stat s;
|
||||||
|
|
||||||
/* only if yet unfilled */
|
if ((name == NULL) || (devno == NULL)) {
|
||||||
if (*put != NULL)
|
goto end;
|
||||||
return;
|
}
|
||||||
|
|
||||||
if (device_num == 0)
|
*name = NULL;
|
||||||
|
*devno = 0;
|
||||||
|
|
||||||
|
if (device_num == -1)
|
||||||
device = g_strdup (device_base);
|
device = g_strdup (device_base);
|
||||||
else
|
else if ((device_num >= -1) && (device_num <= MAX_OSS_DEVICES)) {
|
||||||
device = g_strdup_printf ("%s%d", device_base, device_num);
|
device = g_strdup_printf ("%s%d", device_base, device_num);
|
||||||
|
} else {
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
|
|
||||||
if (lstat (device, &s) || !S_ISCHR (s.st_mode))
|
if (lstat (device, &s) || !S_ISCHR (s.st_mode))
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
*put = device;
|
*name = device;
|
||||||
return;
|
*devno = s.st_rdev;
|
||||||
|
return;
|
||||||
|
|
||||||
end:
|
end:
|
||||||
g_free (device);
|
g_free (device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GList*
|
||||||
|
device_combination_append (GList *device_combinations,
|
||||||
|
GstOssDeviceCombination *combi)
|
||||||
|
{
|
||||||
|
GList *it;
|
||||||
|
|
||||||
|
for (it = device_combinations; it != NULL; it = it->next) {
|
||||||
|
GstOssDeviceCombination *cur;
|
||||||
|
|
||||||
|
cur = (GstOssDeviceCombination*)it->data;
|
||||||
|
if (cur->dev == combi->dev) {
|
||||||
|
return device_combinations;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return g_list_append (device_combinations, combi);
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_osselement_class_probe_devices (GstOssElementClass *klass,
|
gst_osselement_class_probe_devices (GstOssElementClass *klass,
|
||||||
gboolean check)
|
gboolean check)
|
||||||
|
@ -227,10 +256,13 @@ gst_osselement_class_probe_devices (GstOssElementClass *klass,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!init && !check) {
|
if (!init && !check) {
|
||||||
gchar *dsp_base[] = { "/dev/dsp", "/dev/sound/dsp", NULL };
|
#define MIXER 0
|
||||||
gchar *mixer_base[] = { "/dev/mixer", "/dev/sound/mixer", NULL };
|
#define DSP 1
|
||||||
GstOssDeviceCombination devices[16];
|
gchar *dev_base[][2] = { {"/dev/mixer", "/dev/dsp"},
|
||||||
|
{"/dev/sound/mixer", "/dev/sound/dsp"},
|
||||||
|
{NULL, NULL}};
|
||||||
gint n;
|
gint n;
|
||||||
|
gint base;
|
||||||
|
|
||||||
while (device_combinations) {
|
while (device_combinations) {
|
||||||
GList *item = device_combinations;
|
GList *item = device_combinations;
|
||||||
|
@ -244,55 +276,45 @@ gst_osselement_class_probe_devices (GstOssElementClass *klass,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* probe for all /dev entries */
|
/* probe for all /dev entries */
|
||||||
memset (devices, 0, sizeof (devices));
|
for (base = 0; dev_base[base][DSP] != NULL; base++) {
|
||||||
|
|
||||||
/* OSS (without devfs) allows at max. 16 devices */
|
|
||||||
for (n = 0; n < 16; n++) {
|
|
||||||
gint base;
|
|
||||||
|
|
||||||
for (base = 0; dsp_base[base] != NULL; base++)
|
|
||||||
gst_osselement_probe (dsp_base[base], n, &devices[n].dsp);
|
|
||||||
|
|
||||||
for (base = 0; mixer_base[base] != NULL; base++)
|
|
||||||
gst_osselement_probe (mixer_base[base], n, &devices[n].mixer);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* does the device exist (can we open them)? */
|
|
||||||
for (n = 0; n < 16; n++) {
|
|
||||||
gint fd;
|
gint fd;
|
||||||
|
|
||||||
if (!devices[n].dsp)
|
for (n = -1; n < MAX_OSS_DEVICES; n++) {
|
||||||
continue;
|
gchar *dsp = NULL;
|
||||||
|
gchar *mixer = NULL;
|
||||||
|
dev_t dsp_dev;
|
||||||
|
dev_t mixer_dev;
|
||||||
|
|
||||||
/* we just check the dsp. we assume the mixer always works.
|
gst_osselement_probe (dev_base[base][DSP], n, &dsp, &dsp_dev);
|
||||||
* we don't need a mixer anyway (says OSS)... If we are a
|
if (dsp == NULL) {
|
||||||
* mixer element, we use the mixer anyway. */
|
continue;
|
||||||
if ((fd = open (mixer ? devices[n].mixer :
|
}
|
||||||
devices[n].dsp, openmode)) > 0 || errno == EBUSY) {
|
gst_osselement_probe (dev_base[base][MIXER], n, &mixer, &mixer_dev);
|
||||||
GstOssDeviceCombination *combi;
|
/* does the device exist (can we open them)? */
|
||||||
|
|
||||||
if (fd > 0)
|
/* we just check the dsp. we assume the mixer always works.
|
||||||
close (fd);
|
* we don't need a mixer anyway (says OSS)... If we are a
|
||||||
|
* mixer element, we use the mixer anyway. */
|
||||||
/* yay! \o/ */
|
if ((fd = open (mixer ? mixer :
|
||||||
combi = g_new0 (GstOssDeviceCombination, 1);
|
dsp, openmode)) > 0 || errno == EBUSY) {
|
||||||
combi->dsp = devices[n].dsp;
|
GstOssDeviceCombination *combi;
|
||||||
combi->mixer = devices[n].mixer;
|
|
||||||
devices[n].dsp = devices[n].mixer = NULL;
|
if (fd > 0)
|
||||||
|
close (fd);
|
||||||
device_combinations = g_list_append (device_combinations, combi);
|
|
||||||
|
/* yay! \o/ */
|
||||||
|
combi = g_new0 (GstOssDeviceCombination, 1);
|
||||||
|
combi->dsp = dsp;
|
||||||
|
combi->mixer = mixer;
|
||||||
|
device_combinations = device_combination_append (device_combinations,
|
||||||
|
combi);
|
||||||
|
} else {
|
||||||
|
g_free (dsp);
|
||||||
|
g_free (mixer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* free */
|
|
||||||
for (n = 0; n < 16; n++) {
|
|
||||||
if (devices[n].dsp)
|
|
||||||
g_free (devices[n].dsp);
|
|
||||||
|
|
||||||
if (devices[n].mixer)
|
|
||||||
g_free (devices[n].mixer);
|
|
||||||
}
|
|
||||||
|
|
||||||
init = TRUE;
|
init = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,7 @@ typedef enum {
|
||||||
|
|
||||||
typedef struct _GstOssDeviceCombination {
|
typedef struct _GstOssDeviceCombination {
|
||||||
gchar *dsp, *mixer;
|
gchar *dsp, *mixer;
|
||||||
|
dev_t dev;
|
||||||
} GstOssDeviceCombination;
|
} GstOssDeviceCombination;
|
||||||
|
|
||||||
struct _GstOssElement
|
struct _GstOssElement
|
||||||
|
|
Loading…
Reference in a new issue