diff options
author | Thomas Vander Stichele <thomas@apestaart.org> | 2004-03-14 22:34:33 +0000 |
---|---|---|
committer | Thomas Vander Stichele <thomas@apestaart.org> | 2004-03-14 22:34:33 +0000 |
commit | 7a778ee4b7ec09a1f5b2185c9cceee3910dfbdf2 (patch) | |
tree | f863b467dea9559a6ec9c48affbfae11f8104164 /sys/dxr3/dxr3audiosink.c | |
parent | a19db4bbdc4a15ea0d8f4d28e9a1302c9c3d1657 (diff) | |
download | gst-plugins-bad-7a778ee4b7ec09a1f5b2185c9cceee3910dfbdf2.tar.gz gst-plugins-bad-7a778ee4b7ec09a1f5b2185c9cceee3910dfbdf2.tar.bz2 gst-plugins-bad-7a778ee4b7ec09a1f5b2185c9cceee3910dfbdf2.zip |
gst-indent
Original commit message from CVS:
gst-indent
Diffstat (limited to 'sys/dxr3/dxr3audiosink.c')
-rw-r--r-- | sys/dxr3/dxr3audiosink.c | 398 |
1 files changed, 188 insertions, 210 deletions
diff --git a/sys/dxr3/dxr3audiosink.c b/sys/dxr3/dxr3audiosink.c index 0bde9e35..a1a7b8e6 100644 --- a/sys/dxr3/dxr3audiosink.c +++ b/sys/dxr3/dxr3audiosink.c @@ -56,95 +56,84 @@ static GstElementDetails dxr3audiosink_details = { /* Dxr3AudioSink signals and args */ -enum { +enum +{ SIGNAL_FLUSHED, LAST_SIGNAL }; -enum { +enum +{ ARG_0, ARG_DIGITAL_PCM }; static GstStaticPadTemplate dxr3audiosink_pcm_sink_factory = -GST_STATIC_PAD_TEMPLATE ( - "pcm_sink", - GST_PAD_SINK, - GST_PAD_ALWAYS, - GST_STATIC_CAPS ( - "audio/x-raw-int, " - "endianness = (int) BYTE_ORDER, " - "signed = (boolean) TRUE, " - "width = (int) 16, " - "depth = (int) 16, " - "rate = (int) { 32000, 44100, 48000, 66000 }, " - "channels = (int) 2" - ) -); +GST_STATIC_PAD_TEMPLATE ("pcm_sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("audio/x-raw-int, " + "endianness = (int) BYTE_ORDER, " + "signed = (boolean) TRUE, " + "width = (int) 16, " + "depth = (int) 16, " + "rate = (int) { 32000, 44100, 48000, 66000 }, " "channels = (int) 2") + ); static GstStaticPadTemplate dxr3audiosink_ac3_sink_factory = -GST_STATIC_PAD_TEMPLATE ( - "ac3_sink", - GST_PAD_SINK, - GST_PAD_ALWAYS, - GST_STATIC_CAPS ( - "audio/x-ac3" - /* no parameters needed, we don't need a parsed stream */ - ) -); - - -static void dxr3audiosink_class_init (Dxr3AudioSinkClass *klass); -static void dxr3audiosink_base_init (Dxr3AudioSinkClass *klass); -static void dxr3audiosink_init (Dxr3AudioSink *sink); - -static void dxr3audiosink_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static void dxr3audiosink_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); - -static gboolean dxr3audiosink_open (Dxr3AudioSink *sink); -static gboolean dxr3audiosink_set_mode_pcm (Dxr3AudioSink *sink); -static gboolean dxr3audiosink_set_mode_ac3 (Dxr3AudioSink *sink); -static void dxr3audiosink_close (Dxr3AudioSink *sink); -static void dxr3audiosink_set_clock (GstElement *element, - GstClock *clock); - -static GstPadLinkReturn dxr3audiosink_pcm_sinklink (GstPad *pad, - const GstCaps *caps); -static void dxr3audiosink_set_scr (Dxr3AudioSink *sink, - guint32 scr); - -static gboolean dxr3audiosink_handle_event (GstPad *pad, - GstEvent *event); -static void dxr3audiosink_chain_pcm (GstPad *pad,GstData *buf); -static void dxr3audiosink_chain_ac3 (GstPad *pad, GstData *buf); +GST_STATIC_PAD_TEMPLATE ("ac3_sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("audio/x-ac3" + /* no parameters needed, we don't need a parsed stream */ + ) + ); + + +static void dxr3audiosink_class_init (Dxr3AudioSinkClass * klass); +static void dxr3audiosink_base_init (Dxr3AudioSinkClass * klass); +static void dxr3audiosink_init (Dxr3AudioSink * sink); + +static void dxr3audiosink_set_property (GObject * object, + guint prop_id, const GValue * value, GParamSpec * pspec); +static void dxr3audiosink_get_property (GObject * object, + guint prop_id, GValue * value, GParamSpec * pspec); + +static gboolean dxr3audiosink_open (Dxr3AudioSink * sink); +static gboolean dxr3audiosink_set_mode_pcm (Dxr3AudioSink * sink); +static gboolean dxr3audiosink_set_mode_ac3 (Dxr3AudioSink * sink); +static void dxr3audiosink_close (Dxr3AudioSink * sink); +static void dxr3audiosink_set_clock (GstElement * element, GstClock * clock); + +static GstPadLinkReturn dxr3audiosink_pcm_sinklink (GstPad * pad, + const GstCaps * caps); +static void dxr3audiosink_set_scr (Dxr3AudioSink * sink, guint32 scr); + +static gboolean dxr3audiosink_handle_event (GstPad * pad, GstEvent * event); +static void dxr3audiosink_chain_pcm (GstPad * pad, GstData * buf); +static void dxr3audiosink_chain_ac3 (GstPad * pad, GstData * buf); /* static void dxr3audiosink_wait (Dxr3AudioSink *sink, */ /* GstClockTime time); */ /* static int dxr3audiosink_mvcommand (Dxr3AudioSink *sink, */ /* int command); */ -static GstElementStateReturn dxr3audiosink_change_state (GstElement *element); +static GstElementStateReturn dxr3audiosink_change_state (GstElement * element); -static void dxr3audiosink_flushed (Dxr3AudioSink *sink); +static void dxr3audiosink_flushed (Dxr3AudioSink * sink); static GstElementClass *parent_class = NULL; static guint dxr3audiosink_signals[LAST_SIGNAL] = { 0 }; extern GType -dxr3audiosink_get_type (void) +dxr3audiosink_get_type (void) { static GType dxr3audiosink_type = 0; if (!dxr3audiosink_type) { static const GTypeInfo dxr3audiosink_info = { - sizeof(Dxr3AudioSinkClass), + sizeof (Dxr3AudioSinkClass), (GBaseInitFunc) dxr3audiosink_base_init, NULL, (GClassInitFunc) dxr3audiosink_class_init, @@ -155,8 +144,7 @@ dxr3audiosink_get_type (void) (GInstanceInitFunc) dxr3audiosink_init, }; dxr3audiosink_type = g_type_register_static (GST_TYPE_ELEMENT, - "Dxr3AudioSink", - &dxr3audiosink_info, 0); + "Dxr3AudioSink", &dxr3audiosink_info, 0); } return dxr3audiosink_type; @@ -164,43 +152,39 @@ dxr3audiosink_get_type (void) static void -dxr3audiosink_base_init (Dxr3AudioSinkClass *klass) +dxr3audiosink_base_init (Dxr3AudioSinkClass * klass) { GstElementClass *element_class = GST_ELEMENT_CLASS (klass); gst_element_class_add_pad_template (element_class, - gst_static_pad_template_get (&dxr3audiosink_pcm_sink_factory)); + gst_static_pad_template_get (&dxr3audiosink_pcm_sink_factory)); gst_element_class_add_pad_template (element_class, - gst_static_pad_template_get (&dxr3audiosink_ac3_sink_factory)); - gst_element_class_set_details (element_class, - &dxr3audiosink_details); + gst_static_pad_template_get (&dxr3audiosink_ac3_sink_factory)); + gst_element_class_set_details (element_class, &dxr3audiosink_details); } static void -dxr3audiosink_class_init (Dxr3AudioSinkClass *klass) +dxr3audiosink_class_init (Dxr3AudioSinkClass * klass) { GObjectClass *gobject_class; GstElementClass *gstelement_class; - gobject_class = (GObjectClass*)klass; - gstelement_class = (GstElementClass*)klass; + gobject_class = (GObjectClass *) klass; + gstelement_class = (GstElementClass *) klass; parent_class = g_type_class_ref (GST_TYPE_ELEMENT); dxr3audiosink_signals[SIGNAL_FLUSHED] = - g_signal_new ("flushed", G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (Dxr3AudioSinkClass, flushed), - NULL, NULL, - dxr3_marshal_VOID__VOID, - G_TYPE_NONE, 0); + g_signal_new ("flushed", G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (Dxr3AudioSinkClass, flushed), + NULL, NULL, dxr3_marshal_VOID__VOID, G_TYPE_NONE, 0); klass->flushed = dxr3audiosink_flushed; g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DIGITAL_PCM, - g_param_spec_boolean ("digital-pcm", "Digital PCM", - "Use the digital output for PCM sound", - FALSE, G_PARAM_READWRITE)); + g_param_spec_boolean ("digital-pcm", "Digital PCM", + "Use the digital output for PCM sound", FALSE, G_PARAM_READWRITE)); gobject_class->set_property = dxr3audiosink_set_property; gobject_class->get_property = dxr3audiosink_get_property; @@ -210,8 +194,8 @@ dxr3audiosink_class_init (Dxr3AudioSinkClass *klass) } -static void -dxr3audiosink_init (Dxr3AudioSink *sink) +static void +dxr3audiosink_init (Dxr3AudioSink * sink) { GstPadTemplate *temp; @@ -228,7 +212,7 @@ dxr3audiosink_init (Dxr3AudioSink *sink) gst_pad_set_chain_function (sink->ac3_sinkpad, dxr3audiosink_chain_ac3); gst_element_add_pad (GST_ELEMENT (sink), sink->ac3_sinkpad); - GST_FLAG_SET (GST_ELEMENT(sink), GST_ELEMENT_EVENT_AWARE); + GST_FLAG_SET (GST_ELEMENT (sink), GST_ELEMENT_EVENT_AWARE); sink->card_number = 0; @@ -244,7 +228,7 @@ dxr3audiosink_init (Dxr3AudioSink *sink) /* Initially don't use digital output. */ sink->digital_pcm = FALSE; - /* Initially there's no padder.*/ + /* Initially there's no padder. */ sink->padder = NULL; sink->mode = DXR3AUDIOSINK_MODE_NONE; @@ -252,8 +236,8 @@ dxr3audiosink_init (Dxr3AudioSink *sink) static void -dxr3audiosink_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) +dxr3audiosink_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec) { Dxr3AudioSink *sink; @@ -261,70 +245,69 @@ dxr3audiosink_set_property (GObject *object, guint prop_id, sink = DXR3AUDIOSINK (object); switch (prop_id) { - case ARG_DIGITAL_PCM: - sink->digital_pcm = g_value_get_boolean (value); - /* Refresh the setup of the device. */ - if (sink->mode == DXR3AUDIOSINK_MODE_PCM) { - dxr3audiosink_set_mode_pcm (sink); - } - g_object_notify (G_OBJECT (sink), "digital-pcm"); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; + case ARG_DIGITAL_PCM: + sink->digital_pcm = g_value_get_boolean (value); + /* Refresh the setup of the device. */ + if (sink->mode == DXR3AUDIOSINK_MODE_PCM) { + dxr3audiosink_set_mode_pcm (sink); + } + g_object_notify (G_OBJECT (sink), "digital-pcm"); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; } } -static void -dxr3audiosink_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) +static void +dxr3audiosink_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec) { Dxr3AudioSink *sink; - + /* it's not null if we got it, but it might not be ours */ g_return_if_fail (GST_IS_DXR3AUDIOSINK (object)); - + sink = DXR3AUDIOSINK (object); - + switch (prop_id) { - case ARG_DIGITAL_PCM: - g_value_set_boolean (value, sink->digital_pcm); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; + case ARG_DIGITAL_PCM: + g_value_set_boolean (value, sink->digital_pcm); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; } } static gboolean -dxr3audiosink_open (Dxr3AudioSink *sink) +dxr3audiosink_open (Dxr3AudioSink * sink) { - g_return_val_if_fail (!GST_FLAG_IS_SET (sink, - DXR3AUDIOSINK_OPEN), FALSE); + g_return_val_if_fail (!GST_FLAG_IS_SET (sink, DXR3AUDIOSINK_OPEN), FALSE); /* Compute the name of the audio device file. */ sink->audio_filename = g_strdup_printf ("/dev/em8300_ma-%d", - sink->card_number ); + sink->card_number); sink->audio_fd = open (sink->audio_filename, O_WRONLY); if (sink->audio_fd < 0) { GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE, - (_("Could not open audio device \"%s\" for writing."), sink->audio_filename), - GST_ERROR_SYSTEM); + (_("Could not open audio device \"%s\" for writing."), + sink->audio_filename), GST_ERROR_SYSTEM); return FALSE; } /* Open the control device. */ sink->control_filename = g_strdup_printf ("/dev/em8300-%d", - sink->card_number ); + sink->card_number); sink->control_fd = open (sink->control_filename, O_WRONLY); if (sink->control_fd < 0) { GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE, - (_("Could not open control device \"%s\" for writing."), sink->control_filename), - GST_ERROR_SYSTEM); + (_("Could not open control device \"%s\" for writing."), + sink->control_filename), GST_ERROR_SYSTEM); return FALSE; } @@ -343,7 +326,7 @@ dxr3audiosink_open (Dxr3AudioSink *sink) * Set the operation mode of the element to PCM. */ static gboolean -dxr3audiosink_set_mode_pcm (Dxr3AudioSink *sink) +dxr3audiosink_set_mode_pcm (Dxr3AudioSink * sink) { int tmp, oss_mode, audiomode; @@ -354,31 +337,30 @@ dxr3audiosink_set_mode_pcm (Dxr3AudioSink *sink) /* Set the audio device mode. */ oss_mode = (G_BYTE_ORDER == G_BIG_ENDIAN ? AFMT_S16_BE : AFMT_S16_LE); tmp = oss_mode; - if (ioctl (sink->audio_fd, SNDCTL_DSP_SETFMT, &tmp) < 0 || - tmp != oss_mode) { + if (ioctl (sink->audio_fd, SNDCTL_DSP_SETFMT, &tmp) < 0 || tmp != oss_mode) { GST_ELEMENT_ERROR (sink, RESOURCE, SETTINGS, - (_("Could not configure audio device \"%s\"."), sink->audio_filename), - GST_ERROR_SYSTEM); + (_("Could not configure audio device \"%s\"."), sink->audio_filename), + GST_ERROR_SYSTEM); return FALSE; } /* Set the card's general audio output mode. */ audiomode = sink->digital_pcm ? - EM8300_AUDIOMODE_DIGITALPCM : EM8300_AUDIOMODE_ANALOG; + EM8300_AUDIOMODE_DIGITALPCM : EM8300_AUDIOMODE_ANALOG; ioctl (sink->control_fd, EM8300_IOCTL_SET_AUDIOMODE, &audiomode); /* Set the sampling rate. */ tmp = sink->rate; if (ioctl (sink->audio_fd, SNDCTL_DSP_SPEED, &tmp) < 0) { GST_ELEMENT_ERROR (sink, RESOURCE, SETTINGS, - (_("Could not set audio device \"%s\" to %d Hz."), sink->audio_filename, sink->rate), - GST_ERROR_SYSTEM); + (_("Could not set audio device \"%s\" to %d Hz."), sink->audio_filename, + sink->rate), GST_ERROR_SYSTEM); return FALSE; } /* Get rid of the padder, if any. */ if (sink->padder != NULL) { - g_free(sink->padder); + g_free (sink->padder); sink->padder = NULL; } @@ -395,9 +377,9 @@ dxr3audiosink_set_mode_pcm (Dxr3AudioSink *sink) * Set the operation mode of the element to AC3. */ static gboolean -dxr3audiosink_set_mode_ac3 (Dxr3AudioSink *sink) +dxr3audiosink_set_mode_ac3 (Dxr3AudioSink * sink) { - int tmp, audiomode; + int tmp, audiomode; if (sink->audio_fd == -1 || sink->control_fd == -1) { return FALSE; @@ -408,8 +390,8 @@ dxr3audiosink_set_mode_ac3 (Dxr3AudioSink *sink) if (ioctl (sink->audio_fd, SNDCTL_DSP_SPEED, &tmp) < 0 || tmp != AC3_BYTE_RATE) { GST_ELEMENT_ERROR (sink, RESOURCE, SETTINGS, - (_("Could not set audio device \"%s\" to %d Hz."), sink->audio_filename, AC3_BYTE_RATE), - GST_ERROR_SYSTEM); + (_("Could not set audio device \"%s\" to %d Hz."), sink->audio_filename, + AC3_BYTE_RATE), GST_ERROR_SYSTEM); return FALSE; } @@ -419,8 +401,8 @@ dxr3audiosink_set_mode_ac3 (Dxr3AudioSink *sink) /* Create a padder if necessary, */ if (sink->padder == NULL) { - sink->padder = g_malloc (sizeof(ac3_padder)); - ac3p_init(sink->padder); + sink->padder = g_malloc (sizeof (ac3_padder)); + ac3p_init (sink->padder); } sink->mode = DXR3AUDIOSINK_MODE_AC3; @@ -430,21 +412,21 @@ dxr3audiosink_set_mode_ac3 (Dxr3AudioSink *sink) static void -dxr3audiosink_close (Dxr3AudioSink *sink) +dxr3audiosink_close (Dxr3AudioSink * sink) { g_return_if_fail (GST_FLAG_IS_SET (sink, DXR3AUDIOSINK_OPEN)); if (close (sink->audio_fd) != 0) { GST_ELEMENT_ERROR (sink, RESOURCE, CLOSE, - (_("Could not close audio device \"%s\"."), sink->audio_filename), - GST_ERROR_SYSTEM); + (_("Could not close audio device \"%s\"."), sink->audio_filename), + GST_ERROR_SYSTEM); return; } if (close (sink->control_fd) != 0) { GST_ELEMENT_ERROR (sink, RESOURCE, CLOSE, - (_("Could not close control device \"%s\"."), sink->audio_filename), - GST_ERROR_SYSTEM); + (_("Could not close control device \"%s\"."), sink->audio_filename), + GST_ERROR_SYSTEM); return; } @@ -458,14 +440,14 @@ dxr3audiosink_close (Dxr3AudioSink *sink) /* Get rid of the padder, if any. */ if (sink->padder != NULL) { - g_free(sink->padder); + g_free (sink->padder); sink->padder = NULL; } } static void -dxr3audiosink_set_clock (GstElement *element, GstClock *clock) +dxr3audiosink_set_clock (GstElement * element, GstClock * clock) { Dxr3AudioSink *src = DXR3AUDIOSINK (element); @@ -474,7 +456,7 @@ dxr3audiosink_set_clock (GstElement *element, GstClock *clock) static GstPadLinkReturn -dxr3audiosink_pcm_sinklink (GstPad *pad, const GstCaps *caps) +dxr3audiosink_pcm_sinklink (GstPad * pad, const GstCaps * caps) { Dxr3AudioSink *sink = DXR3AUDIOSINK (gst_pad_get_parent (pad)); GstStructure *structure = gst_caps_get_structure (caps, 0); @@ -492,7 +474,7 @@ dxr3audiosink_pcm_sinklink (GstPad *pad, const GstCaps *caps) static void -dxr3audiosink_set_scr (Dxr3AudioSink *sink, guint32 scr) +dxr3audiosink_set_scr (Dxr3AudioSink * sink, guint32 scr) { guint32 zero = 0; @@ -503,7 +485,7 @@ dxr3audiosink_set_scr (Dxr3AudioSink *sink, guint32 scr) static gboolean -dxr3audiosink_handle_event (GstPad *pad, GstEvent *event) +dxr3audiosink_handle_event (GstPad * pad, GstEvent * event) { GstEventType type; Dxr3AudioSink *sink = DXR3AUDIOSINK (gst_pad_get_parent (pad)); @@ -511,33 +493,33 @@ dxr3audiosink_handle_event (GstPad *pad, GstEvent *event) type = event ? GST_EVENT_TYPE (event) : GST_EVENT_UNKNOWN; switch (type) { - case GST_EVENT_FLUSH: - if (sink->control_fd >= 0) { - unsigned audiomode; - - if (sink->mode == DXR3AUDIOSINK_MODE_AC3) { - audiomode = EM8300_AUDIOMODE_DIGITALPCM; - ioctl (sink->control_fd, EM8300_IOCTL_SET_AUDIOMODE, &audiomode); - audiomode = EM8300_AUDIOMODE_DIGITALAC3; - ioctl (sink->control_fd, EM8300_IOCTL_SET_AUDIOMODE, &audiomode); + case GST_EVENT_FLUSH: + if (sink->control_fd >= 0) { + unsigned audiomode; + + if (sink->mode == DXR3AUDIOSINK_MODE_AC3) { + audiomode = EM8300_AUDIOMODE_DIGITALPCM; + ioctl (sink->control_fd, EM8300_IOCTL_SET_AUDIOMODE, &audiomode); + audiomode = EM8300_AUDIOMODE_DIGITALAC3; + ioctl (sink->control_fd, EM8300_IOCTL_SET_AUDIOMODE, &audiomode); + } + + /* Report the flush operation. */ + g_signal_emit (G_OBJECT (sink), + dxr3audiosink_signals[SIGNAL_FLUSHED], 0); } - - /* Report the flush operation. */ - g_signal_emit (G_OBJECT (sink), - dxr3audiosink_signals[SIGNAL_FLUSHED], 0); - } - break; - default: - gst_pad_event_default (pad, event); - break; + break; + default: + gst_pad_event_default (pad, event); + break; } return TRUE; } -static void -dxr3audiosink_chain_pcm (GstPad *pad, GstData *_data) +static void +dxr3audiosink_chain_pcm (GstPad * pad, GstData * _data) { Dxr3AudioSink *sink; gint bytes_written = 0; @@ -579,21 +561,21 @@ dxr3audiosink_chain_pcm (GstPad *pad, GstData *_data) in = MPEGTIME_TO_DXRTIME (sink->scr - (odelay * 90) / 192); diff = in > out ? in - out : out - in; if (diff > 1800) { - dxr3audiosink_set_scr (sink, in); + dxr3audiosink_set_scr (sink, in); } } /* Update our SCR value. */ sink->scr += (unsigned) (GST_BUFFER_SIZE (buf) * - (90000.0 / ((float)sink->rate * 4))); + (90000.0 / ((float) sink->rate * 4))); /* Write the buffer to the sound device. */ bytes_written = write (sink->audio_fd, GST_BUFFER_DATA (buf), - GST_BUFFER_SIZE (buf)); + GST_BUFFER_SIZE (buf)); if (bytes_written < GST_BUFFER_SIZE (buf)) { fprintf (stderr, "dxr3audiosink: Warning: %d bytes should be " - "written, only %d bytes written\n", - GST_BUFFER_SIZE (buf), bytes_written); + "written, only %d bytes written\n", + GST_BUFFER_SIZE (buf), bytes_written); } } @@ -601,8 +583,8 @@ dxr3audiosink_chain_pcm (GstPad *pad, GstData *_data) } -static void -dxr3audiosink_chain_ac3 (GstPad *pad, GstData *_data) +static void +dxr3audiosink_chain_ac3 (GstPad * pad, GstData * _data) { Dxr3AudioSink *sink; gint bytes_written = 0; @@ -626,8 +608,7 @@ dxr3audiosink_chain_ac3 (GstPad *pad, GstData *_data) dxr3audiosink_set_mode_ac3 (sink); } - if (GST_FLAG_IS_SET (sink, DXR3AUDIOSINK_OPEN)) - { + if (GST_FLAG_IS_SET (sink, DXR3AUDIOSINK_OPEN)) { int event; if (GST_BUFFER_TIMESTAMP (buf) != GST_CLOCK_TIME_NONE) { @@ -640,55 +621,53 @@ dxr3audiosink_chain_ac3 (GstPad *pad, GstData *_data) } /* Push the new data into the padder. */ - ac3p_push_data(sink->padder, GST_BUFFER_DATA (buf), - GST_BUFFER_SIZE (buf)); + ac3p_push_data (sink->padder, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf)); /* Parse the data. */ event = ac3p_parse (sink->padder); while (event != AC3P_EVENT_PUSH) { switch (event) { - case AC3P_EVENT_FRAME: - /* We have a new frame: */ + case AC3P_EVENT_FRAME: + /* We have a new frame: */ - /* Update the system reference clock (SCR) in the card. */ - { - unsigned in, out, odelay; - unsigned diff; + /* Update the system reference clock (SCR) in the card. */ + { + unsigned in, out, odelay; + unsigned diff; - ioctl (sink->control_fd, EM8300_IOCTL_SCR_GET, &out); + ioctl (sink->control_fd, EM8300_IOCTL_SCR_GET, &out); - ioctl (sink->audio_fd, SNDCTL_DSP_GETODELAY, &odelay); - /* 192000 bytes/sec */ + ioctl (sink->audio_fd, SNDCTL_DSP_GETODELAY, &odelay); + /* 192000 bytes/sec */ - in = MPEGTIME_TO_DXRTIME (sink->scr - (odelay * 90) / 192); - diff = in > out ? in - out : out - in; - if (diff > 1800) { - dxr3audiosink_set_scr (sink, in); - } - } + in = MPEGTIME_TO_DXRTIME (sink->scr - (odelay * 90) / 192); + diff = in > out ? in - out : out - in; + if (diff > 1800) { + dxr3audiosink_set_scr (sink, in); + } + } - /* Update our SCR value. */ - sink->scr += TIME_FOR_BYTES (ac3p_frame_size (sink->padder)); + /* Update our SCR value. */ + sink->scr += TIME_FOR_BYTES (ac3p_frame_size (sink->padder)); - /* Write the frame to the sound device. */ - bytes_written = write (sink->audio_fd, ac3p_frame (sink->padder), - AC3P_IEC_FRAME_SIZE); + /* Write the frame to the sound device. */ + bytes_written = write (sink->audio_fd, ac3p_frame (sink->padder), + AC3P_IEC_FRAME_SIZE); - if (bytes_written < AC3P_IEC_FRAME_SIZE) - { - fprintf (stderr, "dxr3audiosink: Warning: %d bytes should be " - "written, only %d bytes written\n", - AC3P_IEC_FRAME_SIZE, bytes_written); - } + if (bytes_written < AC3P_IEC_FRAME_SIZE) { + fprintf (stderr, "dxr3audiosink: Warning: %d bytes should be " + "written, only %d bytes written\n", + AC3P_IEC_FRAME_SIZE, bytes_written); + } - break; + break; } event = ac3p_parse (sink->padder); } } - gst_buffer_unref(buf); + gst_buffer_unref (buf); } #if 0 @@ -697,7 +676,7 @@ dxr3audiosink_chain_ac3 (GstPad *pad, GstData *_data) * Make the sink wait the specified amount of time. */ static void -dxr3audiosink_wait (Dxr3AudioSink *sink, GstClockTime time) +dxr3audiosink_wait (Dxr3AudioSink * sink, GstClockTime time) { GstClockID id; GstClockTimeDiff jitter; @@ -711,20 +690,20 @@ dxr3audiosink_wait (Dxr3AudioSink *sink, GstClockTime time) static int -dxr3audiosink_mvcommand (Dxr3AudioSink *sink, int command) +dxr3audiosink_mvcommand (Dxr3AudioSink * sink, int command) { em8300_register_t regs; - + regs.microcode_register = 1; regs.reg = 0; regs.val = command; - + return ioctl (sink->control_fd, EM8300_IOCTL_WRITEREG, ®s); } #endif static GstElementStateReturn -dxr3audiosink_change_state (GstElement *element) +dxr3audiosink_change_state (GstElement * element) { g_return_val_if_fail (GST_IS_DXR3AUDIOSINK (element), GST_STATE_FAILURE); @@ -732,11 +711,10 @@ dxr3audiosink_change_state (GstElement *element) if (GST_FLAG_IS_SET (element, DXR3AUDIOSINK_OPEN)) { dxr3audiosink_close (DXR3AUDIOSINK (element)); } - } - else { + } else { if (!GST_FLAG_IS_SET (element, DXR3AUDIOSINK_OPEN)) { if (!dxr3audiosink_open (DXR3AUDIOSINK (element))) { - return GST_STATE_FAILURE; + return GST_STATE_FAILURE; } } } @@ -757,7 +735,7 @@ dxr3audiosink_change_state (GstElement *element) * queues due to a received flush event */ static void -dxr3audiosink_flushed (Dxr3AudioSink *sink) +dxr3audiosink_flushed (Dxr3AudioSink * sink) { /* Do nothing. */ } |