mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-03-30 12:49:40 +00:00
remove weird thing code set caps on src pad as soon as card is opened
Original commit message from CVS: remove weird thing code set caps on src pad as soon as card is opened
This commit is contained in:
parent
7813a24e3f
commit
7858bbc88a
1 changed files with 32 additions and 14 deletions
|
@ -29,8 +29,6 @@
|
||||||
|
|
||||||
#include <gstosssrc.h>
|
#include <gstosssrc.h>
|
||||||
|
|
||||||
//#define WEIRD_THING /* show the weird thing with 44100 KHz rec */
|
|
||||||
|
|
||||||
static GstElementDetails gst_osssrc_details = {
|
static GstElementDetails gst_osssrc_details = {
|
||||||
"Audio Source (OSS)",
|
"Audio Source (OSS)",
|
||||||
"Source/Audio",
|
"Source/Audio",
|
||||||
|
@ -306,6 +304,9 @@ gst_osssrc_get_property (GObject *object, guint prop_id, GValue *value, GParamSp
|
||||||
static GstElementStateReturn
|
static GstElementStateReturn
|
||||||
gst_osssrc_change_state (GstElement *element)
|
gst_osssrc_change_state (GstElement *element)
|
||||||
{
|
{
|
||||||
|
GstPad *pad = NULL;
|
||||||
|
GstOssSrc *src = GST_OSSSRC (element);
|
||||||
|
|
||||||
g_return_val_if_fail (GST_IS_OSSSRC (element), FALSE);
|
g_return_val_if_fail (GST_IS_OSSSRC (element), FALSE);
|
||||||
GST_DEBUG (0, "osssrc: state change\n");
|
GST_DEBUG (0, "osssrc: state change\n");
|
||||||
/* if going down into NULL state, close the file if it's open */
|
/* if going down into NULL state, close the file if it's open */
|
||||||
|
@ -319,6 +320,31 @@ gst_osssrc_change_state (GstElement *element)
|
||||||
if (!GST_FLAG_IS_SET (element, GST_OSSSRC_OPEN)) {
|
if (!GST_FLAG_IS_SET (element, GST_OSSSRC_OPEN)) {
|
||||||
if (!gst_osssrc_open_audio (GST_OSSSRC (element)))
|
if (!gst_osssrc_open_audio (GST_OSSSRC (element)))
|
||||||
return GST_STATE_FAILURE;
|
return GST_STATE_FAILURE;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* set the caps here instead of after first iteration */
|
||||||
|
pad = gst_element_get_pad (element, "src");
|
||||||
|
if (! (GST_PAD_CAPS (pad)))
|
||||||
|
{
|
||||||
|
/* set caps on src pad */
|
||||||
|
if (!gst_pad_try_set_caps (pad,
|
||||||
|
GST_CAPS_NEW (
|
||||||
|
"oss_src",
|
||||||
|
"audio/raw",
|
||||||
|
"format", GST_PROPS_STRING ("int"),
|
||||||
|
"law", GST_PROPS_INT (0), //FIXME
|
||||||
|
"endianness", GST_PROPS_INT (G_BYTE_ORDER), //FIXME
|
||||||
|
"signed", GST_PROPS_BOOLEAN (TRUE), //FIXME
|
||||||
|
"width", GST_PROPS_INT (src->format),
|
||||||
|
"depth", GST_PROPS_INT (src->format),
|
||||||
|
"rate", GST_PROPS_INT (src->frequency),
|
||||||
|
"channels", GST_PROPS_INT (src->channels)
|
||||||
|
)))
|
||||||
|
{
|
||||||
|
gst_element_error (GST_ELEMENT (element), "could not set caps");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -366,9 +392,10 @@ gst_osssrc_sync_parms (GstOssSrc *osssrc)
|
||||||
{
|
{
|
||||||
audio_buf_info ispace;
|
audio_buf_info ispace;
|
||||||
gint frag;
|
gint frag;
|
||||||
/* hack : ioctl on frequency seems to *change* the frequency
|
/* remember : ioctl on samplerate returns the sample rate the card
|
||||||
maybe this is right, but at least for 44100 Khz, it
|
* is actually set to ! Setting it to 44101 KHz could cause it to
|
||||||
gives unexpected results ! */
|
* be set to 44101, for example
|
||||||
|
*/
|
||||||
|
|
||||||
guint frequency;
|
guint frequency;
|
||||||
|
|
||||||
|
@ -385,18 +412,9 @@ gst_osssrc_sync_parms (GstOssSrc *osssrc)
|
||||||
|
|
||||||
ioctl(osssrc->fd, SNDCTL_DSP_SETFMT, &osssrc->format);
|
ioctl(osssrc->fd, SNDCTL_DSP_SETFMT, &osssrc->format);
|
||||||
ioctl(osssrc->fd, SNDCTL_DSP_CHANNELS, &osssrc->channels);
|
ioctl(osssrc->fd, SNDCTL_DSP_CHANNELS, &osssrc->channels);
|
||||||
#ifdef WEIRD_THING
|
|
||||||
g_print ("DEBUG: do you want to see A Weird Thing (TM) ?\n");
|
|
||||||
g_print ("DEBUG: then set osssrc to a 44100 frequency and check these numbers.\n");
|
|
||||||
g_print ("DEBUG: osssrc frequency before ioctl: %d\n", osssrc->frequency);
|
|
||||||
#endif
|
|
||||||
ioctl(osssrc->fd, SNDCTL_DSP_SPEED, &osssrc->frequency);
|
ioctl(osssrc->fd, SNDCTL_DSP_SPEED, &osssrc->frequency);
|
||||||
#ifdef WEIRD_THING
|
|
||||||
g_print ("DEBUG: osssrc frequency after ioctl : %d\n", osssrc->frequency);
|
|
||||||
g_print ("DEBUG: redoing ioctl using a temp variable, and resetting osssrc->frequency\n");
|
|
||||||
osssrc->frequency = frequency;
|
osssrc->frequency = frequency;
|
||||||
ioctl(osssrc->fd, SNDCTL_DSP_SPEED, &frequency);
|
ioctl(osssrc->fd, SNDCTL_DSP_SPEED, &frequency);
|
||||||
#endif
|
|
||||||
ioctl(osssrc->fd, SNDCTL_DSP_GETISPACE, &ispace);
|
ioctl(osssrc->fd, SNDCTL_DSP_GETISPACE, &ispace);
|
||||||
ioctl(osssrc->fd, SNDCTL_DSP_GETBLKSIZE, &frag);
|
ioctl(osssrc->fd, SNDCTL_DSP_GETBLKSIZE, &frag);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue