mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-23 06:26:23 +00:00
sys/oss/: fixes #159433. Also add missing copyright header to oss_probe.c.
Original commit message from CVS: Reviewed by: Ronald S. Bultje <rbultje@ronald.bitfreak.net> * sys/oss/gstosselement.c: (gst_osselement_probe_caps): * sys/oss/oss_probe.c: (main): Check for mono/stereo support (similar to samplerate probing), fixes #159433. Also add missing copyright header to oss_probe.c.
This commit is contained in:
parent
6e1fa8a5bf
commit
64ed8f9735
3 changed files with 96 additions and 5 deletions
|
@ -1,3 +1,12 @@
|
|||
2004-12-16 Toni Willberg <toniw@iki.fi>
|
||||
|
||||
Reviewed by: Ronald S. Bultje <rbultje@ronald.bitfreak.net>
|
||||
|
||||
* sys/oss/gstosselement.c: (gst_osselement_probe_caps):
|
||||
* sys/oss/oss_probe.c: (main):
|
||||
Check for mono/stereo support (similar to samplerate probing),
|
||||
fixes #159433. Also add missing copyright header to oss_probe.c.
|
||||
|
||||
2004-12-15 David Schleef <ds@schleef.org>
|
||||
|
||||
* configure.ac: add audioresample and cairo plugins. Remove
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
|
||||
* 2000 Wim Taymans <wim.taymans@chello.be>
|
||||
* 2004 Toni Willberg <toniw@iki.fi>
|
||||
*
|
||||
* gstosssink.c:
|
||||
* gstosselement.c:
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
|
@ -1060,15 +1061,31 @@ gst_osselement_probe_caps (GstOssElement * oss)
|
|||
GstStructure *structure;
|
||||
unsigned int format_bit;
|
||||
unsigned int format_mask;
|
||||
|
||||
GstCaps *caps;
|
||||
|
||||
gboolean mono_supported = FALSE;
|
||||
gboolean stereo_supported = FALSE;
|
||||
int n_channels;
|
||||
|
||||
if (oss->probed_caps != NULL)
|
||||
return;
|
||||
if (oss->fd == -1)
|
||||
return;
|
||||
|
||||
|
||||
/* FIXME test make sure we're not currently playing */
|
||||
/* FIXME test both mono and stereo */
|
||||
|
||||
/* check if the device supports mono, stereo or both */
|
||||
n_channels = 1;
|
||||
ret = ioctl (oss->fd, SNDCTL_DSP_CHANNELS, &n_channels);
|
||||
if (n_channels == 1)
|
||||
mono_supported = TRUE;
|
||||
|
||||
n_channels = 2;
|
||||
ret = ioctl (oss->fd, SNDCTL_DSP_CHANNELS, &n_channels);
|
||||
if (n_channels == 2)
|
||||
stereo_supported = TRUE;
|
||||
|
||||
format_mask = AFMT_U8 | AFMT_S16_LE | AFMT_S16_BE | AFMT_S8 |
|
||||
AFMT_U16_LE | AFMT_U16_BE;
|
||||
|
@ -1084,7 +1101,12 @@ gst_osselement_probe_caps (GstOssElement * oss)
|
|||
probe = g_new0 (GstOssProbe, 1);
|
||||
probe->fd = oss->fd;
|
||||
probe->format = format_bit;
|
||||
probe->n_channels = 2;
|
||||
|
||||
if (stereo_supported) {
|
||||
probe->n_channels = 2;
|
||||
} else {
|
||||
probe->n_channels = 1;
|
||||
}
|
||||
|
||||
ret = gst_osselement_rate_probe_check (probe);
|
||||
if (probe->min == -1 || probe->max == -1) {
|
||||
|
@ -1118,7 +1140,21 @@ gst_osselement_probe_caps (GstOssElement * oss)
|
|||
g_free (probe);
|
||||
|
||||
structure = gst_osselement_get_format_structure (format_bit);
|
||||
gst_structure_set (structure, "channels", GST_TYPE_INT_RANGE, 1, 2, NULL);
|
||||
|
||||
if (mono_supported && stereo_supported) {
|
||||
gst_structure_set (structure, "channels", GST_TYPE_INT_RANGE, 1, 2,
|
||||
NULL);
|
||||
} else if (mono_supported) {
|
||||
gst_structure_set (structure, "channels", G_TYPE_INT, 1, NULL);
|
||||
} else if (stereo_supported) {
|
||||
gst_structure_set (structure, "channels", G_TYPE_INT, 2, NULL);
|
||||
} else {
|
||||
/* falling back to [1,2] because we don't know what breaks if we abort here */
|
||||
GST_ERROR (_("Your OSS device doesn't support mono or stereo."));
|
||||
gst_structure_set (structure, "channels", GST_TYPE_INT_RANGE, 1, 2,
|
||||
NULL);
|
||||
}
|
||||
|
||||
gst_structure_set_value (structure, "rate", &rate_value);
|
||||
g_value_unset (&rate_value);
|
||||
|
||||
|
|
|
@ -1,3 +1,24 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2004 David Schleef
|
||||
* 2004 Toni Willberg <toniw@iki.fi>
|
||||
*
|
||||
* oss_probe.c:
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
|
@ -52,9 +73,12 @@ int
|
|||
main (int argc, char *argv[])
|
||||
{
|
||||
int fd;
|
||||
int i;
|
||||
int i, ret;
|
||||
Probe *probe;
|
||||
|
||||
gboolean mono_supported = FALSE;
|
||||
gboolean stereo_supported = FALSE;
|
||||
|
||||
fd = open ("/dev/dsp", O_RDWR);
|
||||
if (fd < 0) {
|
||||
perror ("/dev/dsp");
|
||||
|
@ -64,7 +88,29 @@ main (int argc, char *argv[])
|
|||
probe = g_new0 (Probe, 1);
|
||||
probe->fd = fd;
|
||||
probe->format = AFMT_S16_LE;
|
||||
|
||||
/* check if the device supports mono, stereo or both */
|
||||
probe->n_channels = 1;
|
||||
ret = ioctl (fd, SNDCTL_DSP_CHANNELS, &probe->n_channels);
|
||||
if (probe->n_channels == 1)
|
||||
mono_supported = TRUE;
|
||||
|
||||
probe->n_channels = 2;
|
||||
ret = ioctl (fd, SNDCTL_DSP_CHANNELS, &probe->n_channels);
|
||||
if (probe->n_channels == 2)
|
||||
stereo_supported = TRUE;
|
||||
|
||||
if (mono_supported && stereo_supported) {
|
||||
g_print ("The device supports mono and stereo.\n");
|
||||
} else if (mono_supported) {
|
||||
g_print ("The device supports only mono.\n");
|
||||
} else if (stereo_supported) {
|
||||
g_print ("The device supports only stereo.\n");
|
||||
} else {
|
||||
/* exit with error */
|
||||
g_error
|
||||
("The device doesn't support mono or stereo. This should not happen.\n");
|
||||
}
|
||||
|
||||
probe_check (probe);
|
||||
g_array_sort (probe->rates, int_compare);
|
||||
|
|
Loading…
Reference in a new issue