diff options
Diffstat (limited to 'sys/dxr3')
-rw-r--r-- | sys/dxr3/ac3_padder.c | 289 | ||||
-rw-r--r-- | sys/dxr3/ac3_padder.h | 47 | ||||
-rw-r--r-- | sys/dxr3/dxr3audiosink.c | 398 | ||||
-rw-r--r-- | sys/dxr3/dxr3audiosink.h | 66 | ||||
-rw-r--r-- | sys/dxr3/dxr3init.c | 24 | ||||
-rw-r--r-- | sys/dxr3/dxr3spusink.c | 282 | ||||
-rw-r--r-- | sys/dxr3/dxr3spusink.h | 40 | ||||
-rw-r--r-- | sys/dxr3/dxr3videosink.c | 431 | ||||
-rw-r--r-- | sys/dxr3/dxr3videosink.h | 38 |
9 files changed, 768 insertions, 847 deletions
diff --git a/sys/dxr3/ac3_padder.c b/sys/dxr3/ac3_padder.c index bee59895..606923a7 100644 --- a/sys/dxr3/ac3_padder.c +++ b/sys/dxr3/ac3_padder.c @@ -35,49 +35,48 @@ struct frmsize_s unsigned short bit_rate; unsigned short frm_size[3]; }; - - -static const struct frmsize_s frmsizecod_tbl[64] = - { - { 32 ,{64 ,69 ,96 } }, - { 32 ,{64 ,70 ,96 } }, - { 40 ,{80 ,87 ,120 } }, - { 40 ,{80 ,88 ,120 } }, - { 48 ,{96 ,104 ,144 } }, - { 48 ,{96 ,105 ,144 } }, - { 56 ,{112 ,121 ,168 } }, - { 56 ,{112 ,122 ,168 } }, - { 64 ,{128 ,139 ,192 } }, - { 64 ,{128 ,140 ,192 } }, - { 80 ,{160 ,174 ,240 } }, - { 80 ,{160 ,175 ,240 } }, - { 96 ,{192 ,208 ,288 } }, - { 96 ,{192 ,209 ,288 } }, - { 112 ,{224 ,243 ,336 } }, - { 112 ,{224 ,244 ,336 } }, - { 128 ,{256 ,278 ,384 } }, - { 128 ,{256 ,279 ,384 } }, - { 160 ,{320 ,348 ,480 } }, - { 160 ,{320 ,349 ,480 } }, - { 192 ,{384 ,417 ,576 } }, - { 192 ,{384 ,418 ,576 } }, - { 224 ,{448 ,487 ,672 } }, - { 224 ,{448 ,488 ,672 } }, - { 256 ,{512 ,557 ,768 } }, - { 256 ,{512 ,558 ,768 } }, - { 320 ,{640 ,696 ,960 } }, - { 320 ,{640 ,697 ,960 } }, - { 384 ,{768 ,835 ,1152 } }, - { 384 ,{768 ,836 ,1152 } }, - { 448 ,{896 ,975 ,1344 } }, - { 448 ,{896 ,976 ,1344 } }, - { 512 ,{1024 ,1114 ,1536 } }, - { 512 ,{1024 ,1115 ,1536 } }, - { 576 ,{1152 ,1253 ,1728 } }, - { 576 ,{1152 ,1254 ,1728 } }, - { 640 ,{1280 ,1393 ,1920 } }, - { 640 ,{1280 ,1394 ,1920 } } - }; + + +static const struct frmsize_s frmsizecod_tbl[64] = { + {32, {64, 69, 96}}, + {32, {64, 70, 96}}, + {40, {80, 87, 120}}, + {40, {80, 88, 120}}, + {48, {96, 104, 144}}, + {48, {96, 105, 144}}, + {56, {112, 121, 168}}, + {56, {112, 122, 168}}, + {64, {128, 139, 192}}, + {64, {128, 140, 192}}, + {80, {160, 174, 240}}, + {80, {160, 175, 240}}, + {96, {192, 208, 288}}, + {96, {192, 209, 288}}, + {112, {224, 243, 336}}, + {112, {224, 244, 336}}, + {128, {256, 278, 384}}, + {128, {256, 279, 384}}, + {160, {320, 348, 480}}, + {160, {320, 349, 480}}, + {192, {384, 417, 576}}, + {192, {384, 418, 576}}, + {224, {448, 487, 672}}, + {224, {448, 488, 672}}, + {256, {512, 557, 768}}, + {256, {512, 558, 768}}, + {320, {640, 696, 960}}, + {320, {640, 697, 960}}, + {384, {768, 835, 1152}}, + {384, {768, 836, 1152}}, + {448, {896, 975, 1344}}, + {448, {896, 976, 1344}}, + {512, {1024, 1114, 1536}}, + {512, {1024, 1115, 1536}}, + {576, {1152, 1253, 1728}}, + {576, {1152, 1254, 1728}}, + {640, {1280, 1393, 1920}}, + {640, {1280, 1394, 1920}} +}; @@ -97,7 +96,7 @@ static const struct frmsize_s frmsizecod_tbl[64] = * (S/PDIF) padded packets. */ extern void -ac3p_init(ac3_padder *padder) +ac3p_init (ac3_padder * padder) { const char sync[4] = { 0x72, 0xF8, 0x1F, 0x4E }; @@ -107,7 +106,7 @@ ac3p_init(ac3_padder *padder) padder->remaining = 0; /* Initialize the sync bytes in the frame. */ - memcpy(padder->frame.header, sync, 4); + memcpy (padder->frame.header, sync, 4); } @@ -125,7 +124,7 @@ ac3p_init(ac3_padder *padder) * function returns the %AC3P_EVENT_PUSH event. */ extern void -ac3p_push_data(ac3_padder *padder, guchar *data, guint size) +ac3p_push_data (ac3_padder * padder, guchar * data, guint size) { padder->in_ptr = data; padder->remaining = size; @@ -148,112 +147,108 @@ ac3p_push_data(ac3_padder *padder, guchar *data, guint size) * pushing the data. */ extern int -ac3p_parse(ac3_padder *padder) +ac3p_parse (ac3_padder * padder) { while (padder->remaining > 0) { switch (padder->state) { - case AC3P_STATE_SYNC1: - if (*(padder->in_ptr) == 0x0b) { - /* The first sync byte was found. Go to the next state. */ - padder->frame.sync_byte1 = 0x0b; - padder->state = AC3P_STATE_SYNC2; - } - ac3p_in_fw(padder); - break; - - case AC3P_STATE_SYNC2: - if (*(padder->in_ptr) == 0x77) { - /* The second sync byte was seen right after the first. Go to - the next state. */ - padder->frame.sync_byte2 = 0x77; - padder->state = AC3P_STATE_HEADER; - - /* Skip one byte. */ - ac3p_in_fw(padder); - - /* Prepare for reading the header. */ - padder->out_ptr = (guchar *) &(padder->frame.crc1); - /* Discount the 2 sync bytes from the header size. */ - padder->bytes_to_copy = AC3P_AC3_HEADER_SIZE - 2; - } - else { - /* The second sync byte was not seen. Go back to the - first state. */ - padder->state = AC3P_STATE_SYNC1; - } - break; - - case AC3P_STATE_HEADER: - if (padder->bytes_to_copy > 0) { - /* Copy one byte. */ - *(padder->out_ptr) = *(padder->in_ptr); - ac3p_in_fw(padder); - ac3p_out_fw(padder); - } - else { - int fscod; - - /* The header is ready: */ - - fscod = (padder->frame.code >> 6) & 0x03; - - /* Calculate the frame size. */ - padder->ac3_frame_size = - 2 * frmsizecod_tbl[padder->frame.code & 0x3f].frm_size[fscod]; - - /* Set up the IEC header. */ - if (padder->ac3_frame_size > 0) { - padder->frame.header[4] = IEC61937_DATA_TYPE_AC3; - } - else { - /* Don't know what it is, better be careful. */ - padder->state = AC3P_STATE_SYNC1; - break; - } - padder->frame.header[5] = 0x00; - padder->frame.header[6] = (padder->ac3_frame_size*8) & 0xFF; - padder->frame.header[7] = ((padder->ac3_frame_size*8) >> 8) & 0xFF; - - /* Prepare for reading the body. */ - padder->bytes_to_copy = padder->ac3_frame_size - AC3P_AC3_HEADER_SIZE; - padder->state = AC3P_STATE_CONTENT; - } - break; - - case AC3P_STATE_CONTENT: - if (padder->bytes_to_copy > 0) { - /* Copy one byte. */ - *(padder->out_ptr) = *(padder->in_ptr); - ac3p_in_fw(padder); - ac3p_out_fw(padder); - } - else { - guint16 *ptr, i; - - /* Frame ready. Prepare for output: */ - - /* Zero the non AC3 portion of the padded frame. */ - memset(&(padder->frame.sync_byte1) + padder->ac3_frame_size, 0, - AC3P_IEC_FRAME_SIZE - AC3P_IEC_HEADER_SIZE - padder->ac3_frame_size); - - /* Fix the byte order in the AC3 portion: */ - ptr = (guint16 *) &(padder->frame.sync_byte1); - i = padder->ac3_frame_size / 2; - while (i > 0) { - *ptr = GUINT16_TO_BE(*ptr); - ptr++; - i--; - } - - /* Start over again. */ - padder->state = AC3P_STATE_SYNC1; - - return AC3P_EVENT_FRAME; - } - break; + case AC3P_STATE_SYNC1: + if (*(padder->in_ptr) == 0x0b) { + /* The first sync byte was found. Go to the next state. */ + padder->frame.sync_byte1 = 0x0b; + padder->state = AC3P_STATE_SYNC2; + } + ac3p_in_fw (padder); + break; + + case AC3P_STATE_SYNC2: + if (*(padder->in_ptr) == 0x77) { + /* The second sync byte was seen right after the first. Go to + the next state. */ + padder->frame.sync_byte2 = 0x77; + padder->state = AC3P_STATE_HEADER; + + /* Skip one byte. */ + ac3p_in_fw (padder); + + /* Prepare for reading the header. */ + padder->out_ptr = (guchar *) & (padder->frame.crc1); + /* Discount the 2 sync bytes from the header size. */ + padder->bytes_to_copy = AC3P_AC3_HEADER_SIZE - 2; + } else { + /* The second sync byte was not seen. Go back to the + first state. */ + padder->state = AC3P_STATE_SYNC1; + } + break; + + case AC3P_STATE_HEADER: + if (padder->bytes_to_copy > 0) { + /* Copy one byte. */ + *(padder->out_ptr) = *(padder->in_ptr); + ac3p_in_fw (padder); + ac3p_out_fw (padder); + } else { + int fscod; + + /* The header is ready: */ + + fscod = (padder->frame.code >> 6) & 0x03; + + /* Calculate the frame size. */ + padder->ac3_frame_size = + 2 * frmsizecod_tbl[padder->frame.code & 0x3f].frm_size[fscod]; + + /* Set up the IEC header. */ + if (padder->ac3_frame_size > 0) { + padder->frame.header[4] = IEC61937_DATA_TYPE_AC3; + } else { + /* Don't know what it is, better be careful. */ + padder->state = AC3P_STATE_SYNC1; + break; + } + padder->frame.header[5] = 0x00; + padder->frame.header[6] = (padder->ac3_frame_size * 8) & 0xFF; + padder->frame.header[7] = ((padder->ac3_frame_size * 8) >> 8) & 0xFF; + + /* Prepare for reading the body. */ + padder->bytes_to_copy = padder->ac3_frame_size - AC3P_AC3_HEADER_SIZE; + padder->state = AC3P_STATE_CONTENT; + } + break; + + case AC3P_STATE_CONTENT: + if (padder->bytes_to_copy > 0) { + /* Copy one byte. */ + *(padder->out_ptr) = *(padder->in_ptr); + ac3p_in_fw (padder); + ac3p_out_fw (padder); + } else { + guint16 *ptr, i; + + /* Frame ready. Prepare for output: */ + + /* Zero the non AC3 portion of the padded frame. */ + memset (&(padder->frame.sync_byte1) + padder->ac3_frame_size, 0, + AC3P_IEC_FRAME_SIZE - AC3P_IEC_HEADER_SIZE - + padder->ac3_frame_size); + + /* Fix the byte order in the AC3 portion: */ + ptr = (guint16 *) & (padder->frame.sync_byte1); + i = padder->ac3_frame_size / 2; + while (i > 0) { + *ptr = GUINT16_TO_BE (*ptr); + ptr++; + i--; + } + + /* Start over again. */ + padder->state = AC3P_STATE_SYNC1; + + return AC3P_EVENT_FRAME; + } + break; } } return AC3P_EVENT_PUSH; } - diff --git a/sys/dxr3/ac3_padder.h b/sys/dxr3/ac3_padder.h index c9a7447e..f2ca2faa 100644 --- a/sys/dxr3/ac3_padder.h +++ b/sys/dxr3/ac3_padder.h @@ -34,7 +34,8 @@ /* An IEC958 padded AC3 frame. */ -typedef struct { +typedef struct +{ /* IEC header. */ guchar header[AC3P_IEC_HEADER_SIZE]; @@ -47,9 +48,9 @@ typedef struct { guchar bsidmod; guchar acmod; /* End of AC3 header. */ - - unsigned char data[AC3P_IEC_FRAME_SIZE - AC3P_IEC_HEADER_SIZE - - AC3P_AC3_HEADER_SIZE]; + + unsigned char data[AC3P_IEC_FRAME_SIZE - AC3P_IEC_HEADER_SIZE + - AC3P_AC3_HEADER_SIZE]; } ac3p_iec958_burst_frame; @@ -74,39 +75,37 @@ typedef struct { /* The internal state for the padder. */ -typedef struct { - guint state; /* State of the reading automaton. */ +typedef struct +{ + guint state; /* State of the reading automaton. */ - guchar *in_ptr; /* Input pointer, marking the current - postion in the input buffer. */ - guint remaining; /* The number of bytes remaining in the current - reading buffer. */ + guchar *in_ptr; /* Input pointer, marking the current + postion in the input buffer. */ + guint remaining; /* The number of bytes remaining in the current + reading buffer. */ - guchar *out_ptr; /* Output pointer, marking the current - position in the output frame. */ + guchar *out_ptr; /* Output pointer, marking the current + position in the output frame. */ guint bytes_to_copy; - /* Number of bytes that still must be copied - to the output frame *during this reading - stage*. */ + /* Number of bytes that still must be copied + to the output frame *during this reading + stage*. */ guint ac3_frame_size; - /* The size in bytes of the pure AC3 portion - of the current frame. */ + /* The size in bytes of the pure AC3 portion + of the current frame. */ ac3p_iec958_burst_frame frame; - /* The current output frame. */ + /* The current output frame. */ } ac3_padder; -extern void -ac3p_init(ac3_padder *padder); +extern void ac3p_init (ac3_padder * padder); -extern void -ac3p_push_data(ac3_padder *padder, guchar *data, guint size); +extern void ac3p_push_data (ac3_padder * padder, guchar * data, guint size); -extern int -ac3p_parse(ac3_padder *padder); +extern int ac3p_parse (ac3_padder * padder); /** 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. */ } diff --git a/sys/dxr3/dxr3audiosink.h b/sys/dxr3/dxr3audiosink.h index 28bb34ec..07527d9f 100644 --- a/sys/dxr3/dxr3audiosink.h +++ b/sys/dxr3/dxr3audiosink.h @@ -27,8 +27,6 @@ #include "ac3_padder.h" G_BEGIN_DECLS - - #define GST_TYPE_DXR3AUDIOSINK \ (dxr3audiosink_get_type()) #define DXR3AUDIOSINK(obj) \ @@ -39,75 +37,77 @@ G_BEGIN_DECLS (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DXR3AUDIOSINK)) #define GST_IS_DXR3AUDIOSINK_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DXR3AUDIOSINK)) - - typedef struct _Dxr3AudioSink Dxr3AudioSink; typedef struct _Dxr3AudioSinkClass Dxr3AudioSinkClass; -typedef enum { +typedef enum +{ DXR3AUDIOSINK_OPEN = GST_ELEMENT_FLAG_LAST, - DXR3AUDIOSINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2, + DXR3AUDIOSINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2, } Dxr3AudioSinkFlags; /* PCM or AC3? */ -typedef enum { - DXR3AUDIOSINK_MODE_NONE, /* No mode set. */ - DXR3AUDIOSINK_MODE_AC3, /* AC3 out. */ - DXR3AUDIOSINK_MODE_PCM, /* PCM out. */ +typedef enum +{ + DXR3AUDIOSINK_MODE_NONE, /* No mode set. */ + DXR3AUDIOSINK_MODE_AC3, /* AC3 out. */ + DXR3AUDIOSINK_MODE_PCM, /* PCM out. */ } Dxr3AudioSinkMode; /* Information for a delayed SCR set operation. */ -typedef struct { +typedef struct +{ struct _Dxr3AudioSink *sink; guint32 scr; } Dxr3AudioSinkDelayedSCR; -struct _Dxr3AudioSink { +struct _Dxr3AudioSink +{ GstElement element; - GstPad *pcm_sinkpad; /* The AC3 audio sink pad. */ - GstPad *ac3_sinkpad; /* The PCM audio sink pad. */ + GstPad *pcm_sinkpad; /* The AC3 audio sink pad. */ + GstPad *ac3_sinkpad; /* The PCM audio sink pad. */ - int card_number; /* The number of the card to open. */ + int card_number; /* The number of the card to open. */ - gchar *audio_filename; /* File name for the audio device. */ - int audio_fd; /* File descriptor for the audio device. */ + gchar *audio_filename; /* File name for the audio device. */ + int audio_fd; /* File descriptor for the audio device. */ - gchar *control_filename; /* File name for the control device. */ - int control_fd; /* File descriptor for the control - device. */ + gchar *control_filename; /* File name for the control device. */ + int control_fd; /* File descriptor for the control + device. */ - guint64 scr; /* The current System Reference Clock value - for the audio stream. */ + guint64 scr; /* The current System Reference Clock value + for the audio stream. */ - gboolean digital_pcm; /* Should PCM use the digital or the - analog output? */ + gboolean digital_pcm; /* Should PCM use the digital or the + analog output? */ - Dxr3AudioSinkMode mode; /* The current sound output mode. */ + Dxr3AudioSinkMode mode; /* The current sound output mode. */ - gint rate; /* The sampling rate for PCM sound. */ + gint rate; /* The sampling rate for PCM sound. */ - ac3_padder *padder; /* AC3 to SPDIF padder object. */ + ac3_padder *padder; /* AC3 to SPDIF padder object. */ - GstClock *clock; /* The clock for this element. */ + GstClock *clock; /* The clock for this element. */ }; -struct _Dxr3AudioSinkClass { +struct _Dxr3AudioSinkClass +{ GstElementClass parent_class; /* signals */ - void (*flushed) (Dxr3AudioSink *sink); + void (*flushed) (Dxr3AudioSink * sink); }; -extern GType dxr3audiosink_get_type (void); -extern gboolean dxr3audiosink_factory_init (GstPlugin *plugin); +extern GType dxr3audiosink_get_type (void); +extern gboolean dxr3audiosink_factory_init (GstPlugin * plugin); G_END_DECLS - #endif /* __DXR3AUDIOINK_H__ */ diff --git a/sys/dxr3/dxr3init.c b/sys/dxr3/dxr3init.c index 9a08936c..d5bbd0f2 100644 --- a/sys/dxr3/dxr3init.c +++ b/sys/dxr3/dxr3init.c @@ -31,14 +31,14 @@ static gboolean -plugin_init (GstPlugin *plugin) +plugin_init (GstPlugin * plugin) { if (!gst_element_register (plugin, "dxr3videosink", - GST_RANK_NONE, GST_TYPE_DXR3VIDEOSINK) || + GST_RANK_NONE, GST_TYPE_DXR3VIDEOSINK) || !gst_element_register (plugin, "dxr3audiosink", - GST_RANK_NONE, GST_TYPE_DXR3AUDIOSINK) || + GST_RANK_NONE, GST_TYPE_DXR3AUDIOSINK) || !gst_element_register (plugin, "dxr3spusink", - GST_RANK_NONE, GST_TYPE_DXR3SPUSINK)) + GST_RANK_NONE, GST_TYPE_DXR3SPUSINK)) return FALSE; #ifdef ENABLE_NLS @@ -49,14 +49,8 @@ plugin_init (GstPlugin *plugin) return TRUE; } -GST_PLUGIN_DEFINE ( - GST_VERSION_MAJOR, - GST_VERSION_MINOR, - "dxr3", - "dxr3 mpeg video board elements", - plugin_init, - VERSION, - "GPL", - GST_PACKAGE, - GST_ORIGIN -) +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + "dxr3", + "dxr3 mpeg video board elements", + plugin_init, VERSION, "GPL", GST_PACKAGE, GST_ORIGIN) diff --git a/sys/dxr3/dxr3spusink.c b/sys/dxr3/dxr3spusink.c index fe1f4155..1652cdc6 100644 --- a/sys/dxr3/dxr3spusink.c +++ b/sys/dxr3/dxr3spusink.c @@ -49,7 +49,8 @@ static GstElementDetails dxr3spusink_details = { /* Dxr3SpuSink signals and args */ -enum { +enum +{ SET_CLUT_SIGNAL, HIGHLIGHT_ON_SIGNAL, HIGHLIGHT_OFF_SIGNAL, @@ -57,56 +58,47 @@ enum { LAST_SIGNAL }; -enum { +enum +{ ARG_0, }; static GstStaticPadTemplate dxr3spusink_sink_factory = -GST_STATIC_PAD_TEMPLATE ( - "sink", - GST_PAD_SINK, - GST_PAD_ALWAYS, - GST_STATIC_CAPS_ANY -); +GST_STATIC_PAD_TEMPLATE ("sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS_ANY); -static void dxr3spusink_class_init (Dxr3SpuSinkClass *klass); -static void dxr3spusink_base_init (Dxr3SpuSinkClass *klass); -static void dxr3spusink_init (Dxr3SpuSink *dxr3spusink); +static void dxr3spusink_class_init (Dxr3SpuSinkClass * klass); +static void dxr3spusink_base_init (Dxr3SpuSinkClass * klass); +static void dxr3spusink_init (Dxr3SpuSink * dxr3spusink); -static void dxr3spusink_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static void dxr3spusink_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); +static void dxr3spusink_set_property (GObject * object, + guint prop_id, const GValue * value, GParamSpec * pspec); +static void dxr3spusink_get_property (GObject * object, + guint prop_id, GValue * value, GParamSpec * pspec); -static gboolean dxr3spusink_open (Dxr3SpuSink *sink); -static void dxr3spusink_close (Dxr3SpuSink *sink); -static void dxr3spusink_set_clock (GstElement *element, - GstClock *clock); +static gboolean dxr3spusink_open (Dxr3SpuSink * sink); +static void dxr3spusink_close (Dxr3SpuSink * sink); +static void dxr3spusink_set_clock (GstElement * element, GstClock * clock); -static gboolean dxr3spusink_handle_event (GstPad *pad, GstEvent *event); -static void dxr3spusink_chain (GstPad *pad,GstData *_data); +static gboolean dxr3spusink_handle_event (GstPad * pad, GstEvent * event); +static void dxr3spusink_chain (GstPad * pad, GstData * _data); -static GstElementStateReturn dxr3spusink_change_state (GstElement *element); +static GstElementStateReturn dxr3spusink_change_state (GstElement * element); /* static void dxr3spusink_wait (Dxr3SpuSink *sink, */ /* GstClockTime time); */ -static void dxr3spusink_set_clut (Dxr3SpuSink *sink, - const guint32 *clut); -static void dxr3spusink_highlight_on (Dxr3SpuSink *sink, - unsigned palette, - unsigned sx, unsigned sy, - unsigned ex, unsigned ey, - unsigned pts); -static void dxr3spusink_highlight_off (Dxr3SpuSink *sink); +static void dxr3spusink_set_clut (Dxr3SpuSink * sink, const guint32 * clut); +static void dxr3spusink_highlight_on (Dxr3SpuSink * sink, + unsigned palette, + unsigned sx, unsigned sy, unsigned ex, unsigned ey, unsigned pts); +static void dxr3spusink_highlight_off (Dxr3SpuSink * sink); -static void dxr3spusink_flushed (Dxr3SpuSink *sink); +static void dxr3spusink_flushed (Dxr3SpuSink * sink); static GstElementClass *parent_class = NULL; @@ -114,89 +106,80 @@ static guint dxr3spusink_signals[LAST_SIGNAL] = { 0 }; GType -dxr3spusink_get_type (void) +dxr3spusink_get_type (void) { static GType dxr3spusink_type = 0; if (!dxr3spusink_type) { static const GTypeInfo dxr3spusink_info = { sizeof (Dxr3SpuSinkClass), - (GBaseInitFunc)dxr3spusink_base_init, + (GBaseInitFunc) dxr3spusink_base_init, NULL, - (GClassInitFunc)dxr3spusink_class_init, + (GClassInitFunc) dxr3spusink_class_init, NULL, NULL, sizeof (Dxr3SpuSink), 0, - (GInstanceInitFunc)dxr3spusink_init, + (GInstanceInitFunc) dxr3spusink_init, }; dxr3spusink_type = g_type_register_static (GST_TYPE_ELEMENT, - "Dxr3SpuSink", - &dxr3spusink_info, 0); + "Dxr3SpuSink", &dxr3spusink_info, 0); } return dxr3spusink_type; } static void -dxr3spusink_base_init (Dxr3SpuSinkClass *klass) +dxr3spusink_base_init (Dxr3SpuSinkClass * klass) { GstElementClass *element_class = GST_ELEMENT_CLASS (klass); gst_element_class_add_pad_template (element_class, - gst_static_pad_template_get (&dxr3spusink_sink_factory)); - gst_element_class_set_details (element_class, - &dxr3spusink_details); + gst_static_pad_template_get (&dxr3spusink_sink_factory)); + gst_element_class_set_details (element_class, &dxr3spusink_details); } static void -dxr3spusink_class_init (Dxr3SpuSinkClass *klass) +dxr3spusink_class_init (Dxr3SpuSinkClass * 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); dxr3spusink_signals[SET_CLUT_SIGNAL] = - g_signal_new ("set-clut", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (Dxr3SpuSinkClass, set_clut), - NULL, NULL, - dxr3_marshal_VOID__POINTER, - G_TYPE_NONE, 1, - G_TYPE_POINTER); + g_signal_new ("set-clut", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, + G_STRUCT_OFFSET (Dxr3SpuSinkClass, set_clut), + NULL, NULL, dxr3_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER); dxr3spusink_signals[HIGHLIGHT_ON_SIGNAL] = - g_signal_new ("highlight-on", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (Dxr3SpuSinkClass, highlight_on), - NULL, NULL, - dxr3_marshal_VOID__UINT_UINT_UINT_UINT_UINT_UINT, - G_TYPE_NONE, 6, - G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, - G_TYPE_UINT, G_TYPE_UINT); + g_signal_new ("highlight-on", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, + G_STRUCT_OFFSET (Dxr3SpuSinkClass, highlight_on), + NULL, NULL, + dxr3_marshal_VOID__UINT_UINT_UINT_UINT_UINT_UINT, + G_TYPE_NONE, 6, + G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_UINT, + G_TYPE_UINT, G_TYPE_UINT); dxr3spusink_signals[HIGHLIGHT_OFF_SIGNAL] = - g_signal_new ("highlight-off", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (Dxr3SpuSinkClass, highlight_off), - NULL, NULL, - dxr3_marshal_VOID__VOID, - G_TYPE_NONE, 0); + g_signal_new ("highlight-off", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, + G_STRUCT_OFFSET (Dxr3SpuSinkClass, highlight_off), + NULL, NULL, dxr3_marshal_VOID__VOID, G_TYPE_NONE, 0); dxr3spusink_signals[SIGNAL_FLUSHED] = - g_signal_new ("flushed", G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (Dxr3SpuSinkClass, 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 (Dxr3SpuSinkClass, flushed), + NULL, NULL, dxr3_marshal_VOID__VOID, G_TYPE_NONE, 0); klass->set_clut = dxr3spusink_set_clut; klass->highlight_on = dxr3spusink_highlight_on; @@ -211,13 +194,14 @@ dxr3spusink_class_init (Dxr3SpuSinkClass *klass) } -static void -dxr3spusink_init (Dxr3SpuSink *sink) +static void +dxr3spusink_init (Dxr3SpuSink * sink) { GstPad *pad; - pad = gst_pad_new_from_template ( - gst_static_pad_template_get (&dxr3spusink_sink_factory), "sink"); + pad = + gst_pad_new_from_template (gst_static_pad_template_get + (&dxr3spusink_sink_factory), "sink"); gst_element_add_pad (GST_ELEMENT (sink), pad); gst_pad_set_chain_function (pad, dxr3spusink_chain); @@ -235,8 +219,8 @@ dxr3spusink_init (Dxr3SpuSink *sink) static void -dxr3spusink_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) +dxr3spusink_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec) { Dxr3SpuSink *sink; @@ -250,51 +234,50 @@ dxr3spusink_set_property (GObject *object, guint prop_id, } -static void -dxr3spusink_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) +static void +dxr3spusink_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec) { Dxr3SpuSink *sink; - + /* it's not null if we got it, but it might not be ours */ g_return_if_fail (GST_IS_DXR3SPUSINK (object)); - + sink = DXR3SPUSINK (object); - + switch (prop_id) { - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; } } static gboolean -dxr3spusink_open (Dxr3SpuSink *sink) +dxr3spusink_open (Dxr3SpuSink * sink) { - g_return_val_if_fail (!GST_FLAG_IS_SET (sink, - DXR3SPUSINK_OPEN), FALSE); + g_return_val_if_fail (!GST_FLAG_IS_SET (sink, DXR3SPUSINK_OPEN), FALSE); /* Compute the name of the spu device file. */ - sink->spu_filename = g_strdup_printf ("/dev/em8300_sp-%d", - sink->card_number ); + sink->spu_filename = g_strdup_printf ("/dev/em8300_sp-%d", sink->card_number); sink->spu_fd = open (sink->spu_filename, O_WRONLY); if (sink->spu_fd < 0) { GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE, - (_("Could not open spu device \"%s\" for writing."), sink->spu_filename), GST_ERROR_SYSTEM); + (_("Could not open spu device \"%s\" for writing."), + sink->spu_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; } @@ -305,22 +288,21 @@ dxr3spusink_open (Dxr3SpuSink *sink) static void -dxr3spusink_close (Dxr3SpuSink *sink) +dxr3spusink_close (Dxr3SpuSink * sink) { g_return_if_fail (GST_FLAG_IS_SET (sink, DXR3SPUSINK_OPEN)); if (close (sink->spu_fd) != 0) { GST_ELEMENT_ERROR (sink, RESOURCE, CLOSE, - (_("Could not close spu device \"%s\"."), sink->spu_filename), - GST_ERROR_SYSTEM); + (_("Could not close spu device \"%s\"."), sink->spu_filename), + GST_ERROR_SYSTEM); return; } - if (close (sink->control_fd) != 0) - { + if (close (sink->control_fd) != 0) { GST_ELEMENT_ERROR (sink, RESOURCE, CLOSE, - (_("Could not close control device \"%s\"."), sink->control_filename), - GST_ERROR_SYSTEM); + (_("Could not close control device \"%s\"."), sink->control_filename), + GST_ERROR_SYSTEM); return; } @@ -332,16 +314,16 @@ dxr3spusink_close (Dxr3SpuSink *sink) static void -dxr3spusink_set_clock (GstElement *element, GstClock *clock) +dxr3spusink_set_clock (GstElement * element, GstClock * clock) { Dxr3SpuSink *src = DXR3SPUSINK (element); - + src->clock = clock; } static gboolean -dxr3spusink_handle_event (GstPad *pad, GstEvent *event) +dxr3spusink_handle_event (GstPad * pad, GstEvent * event) { GstEventType type; Dxr3SpuSink *sink; @@ -351,34 +333,34 @@ dxr3spusink_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) { - int subdevice; - subdevice = EM8300_SUBDEVICE_SUBPICTURE; - ioctl (sink->control_fd, EM8300_IOCTL_FLUSH, &subdevice); - - /* FIXME: There should be a nicer way to do this, but I tried - everything and nothing else seems to really reset the video - fifo. */ + case GST_EVENT_FLUSH: + if (sink->control_fd >= 0) { + int subdevice; + + subdevice = EM8300_SUBDEVICE_SUBPICTURE; + ioctl (sink->control_fd, EM8300_IOCTL_FLUSH, &subdevice); + + /* FIXME: There should be a nicer way to do this, but I tried + everything and nothing else seems to really reset the video + fifo. */ /* dxr3spusink_close (sink); */ /* dxr3spusink_open (sink); */ - /* Report the flush operation. */ - g_signal_emit (G_OBJECT (sink), - dxr3spusink_signals[SIGNAL_FLUSHED], 0); - } - break; - default: - gst_pad_event_default (pad, event); - break; + /* Report the flush operation. */ + g_signal_emit (G_OBJECT (sink), dxr3spusink_signals[SIGNAL_FLUSHED], 0); + } + break; + default: + gst_pad_event_default (pad, event); + break; } return TRUE; } -static void -dxr3spusink_chain (GstPad *pad, GstData *_data) +static void +dxr3spusink_chain (GstPad * pad, GstData * _data) { GstBuffer *buf = GST_BUFFER (_data); Dxr3SpuSink *sink; @@ -400,15 +382,15 @@ dxr3spusink_chain (GstPad *pad, GstData *_data) The card needs the PTS to be written *before* the actual data. */ if (GST_BUFFER_TIMESTAMP (buf) != GST_CLOCK_TIME_NONE) { guint pts = (guint) GSTTIME_TO_MPEGTIME (GST_BUFFER_TIMESTAMP (buf)); + ioctl (sink->spu_fd, EM8300_IOCTL_SPU_SETPTS, &pts); } bytes_written = write (sink->spu_fd, GST_BUFFER_DATA (buf), - GST_BUFFER_SIZE (buf)); + GST_BUFFER_SIZE (buf)); if (bytes_written < GST_BUFFER_SIZE (buf)) { fprintf (stderr, "dxr3spusink: Warning: %d bytes should be written," - " only %d bytes written\n", - GST_BUFFER_SIZE (buf), bytes_written); + " only %d bytes written\n", GST_BUFFER_SIZE (buf), bytes_written); } } @@ -417,16 +399,16 @@ dxr3spusink_chain (GstPad *pad, GstData *_data) static GstElementStateReturn -dxr3spusink_change_state (GstElement *element) +dxr3spusink_change_state (GstElement * element) { g_return_val_if_fail (GST_IS_DXR3SPUSINK (element), GST_STATE_FAILURE); switch (GST_STATE_TRANSITION (element)) { case GST_STATE_NULL_TO_READY: if (!GST_FLAG_IS_SET (element, DXR3SPUSINK_OPEN)) { - if (!dxr3spusink_open (DXR3SPUSINK (element))) { - return GST_STATE_FAILURE; - } + if (!dxr3spusink_open (DXR3SPUSINK (element))) { + return GST_STATE_FAILURE; + } } break; case GST_STATE_READY_TO_PAUSED: @@ -439,7 +421,7 @@ dxr3spusink_change_state (GstElement *element) break; case GST_STATE_READY_TO_NULL: if (GST_FLAG_IS_SET (element, DXR3SPUSINK_OPEN)) { - dxr3spusink_close (DXR3SPUSINK (element)); + dxr3spusink_close (DXR3SPUSINK (element)); } break; } @@ -457,7 +439,7 @@ dxr3spusink_change_state (GstElement *element) * Make the sink wait the specified amount of time. */ static void -dxr3spusink_wait (Dxr3SpuSink *sink, GstClockTime time) +dxr3spusink_wait (Dxr3SpuSink * sink, GstClockTime time) { GstClockID id; GstClockTimeDiff jitter; @@ -476,27 +458,25 @@ dxr3spusink_wait (Dxr3SpuSink *sink, GstClockTime time) * Set a new SPU color lookup table (clut) in the dxr3 card. */ static void -dxr3spusink_set_clut (Dxr3SpuSink *sink, const guint32 *clut) +dxr3spusink_set_clut (Dxr3SpuSink * sink, const guint32 * clut) { guint32 clut_fixed[16]; int i; /* Fix the byte order of the table. */ - for (i=0; i<16; i++) { + for (i = 0; i < 16; i++) { clut_fixed[i] = GUINT32_TO_LE (clut[i]); } if (ioctl (sink->spu_fd, EM8300_IOCTL_SPU_SETPALETTE, clut_fixed)) fprintf (stderr, "dxr3spusink: failed to set CLUT (%s)\n", - strerror (errno)); + strerror (errno)); } static void -dxr3spusink_highlight_on (Dxr3SpuSink *sink, unsigned palette, - unsigned sx, unsigned sy, - unsigned ex, unsigned ey, - unsigned pts) +dxr3spusink_highlight_on (Dxr3SpuSink * sink, unsigned palette, + unsigned sx, unsigned sy, unsigned ex, unsigned ey, unsigned pts) { em8300_button_t btn; @@ -509,17 +489,17 @@ dxr3spusink_highlight_on (Dxr3SpuSink *sink, unsigned palette, if (ioctl (sink->spu_fd, EM8300_IOCTL_SPU_BUTTON, &btn)) { fprintf (stderr, "dxr3spusink: failed to set spu button (%s)\n", - strerror (errno)); + strerror (errno)); } } static void -dxr3spusink_highlight_off (Dxr3SpuSink *sink) +dxr3spusink_highlight_off (Dxr3SpuSink * sink) { if (ioctl (sink->spu_fd, EM8300_IOCTL_SPU_BUTTON, NULL)) { fprintf (stderr, "dxr3spusink: failed to set spu button (%s)\n", - strerror (errno)); + strerror (errno)); } } @@ -532,7 +512,7 @@ dxr3spusink_highlight_off (Dxr3SpuSink *sink) * queues due to a received flush event */ static void -dxr3spusink_flushed (Dxr3SpuSink *sink) +dxr3spusink_flushed (Dxr3SpuSink * sink) { /* Do nothing. */ } diff --git a/sys/dxr3/dxr3spusink.h b/sys/dxr3/dxr3spusink.h index e2551714..51bfa39e 100644 --- a/sys/dxr3/dxr3spusink.h +++ b/sys/dxr3/dxr3spusink.h @@ -25,8 +25,6 @@ #include <gst/gst.h> G_BEGIN_DECLS - - #define GST_TYPE_DXR3SPUSINK \ (dxr3spusink_get_type()) #define DXR3SPUSINK(obj) \ @@ -37,51 +35,49 @@ G_BEGIN_DECLS (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DXR3SPUSINK)) #define GST_IS_DXR3SPUSINK_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DXR3SPUSINK)) - - typedef struct _Dxr3SpuSink Dxr3SpuSink; typedef struct _Dxr3SpuSinkClass Dxr3SpuSinkClass; -typedef enum { +typedef enum +{ DXR3SPUSINK_OPEN = GST_ELEMENT_FLAG_LAST, - DXR3SPUSINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2, + DXR3SPUSINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2, } Dxr3SpuSinkFlags; -struct _Dxr3SpuSink { +struct _Dxr3SpuSink +{ GstElement element; - int card_number; /* The number of the card to open. */ + int card_number; /* The number of the card to open. */ - gchar *spu_filename; /* File name for the spu device. */ - int spu_fd; /* File descriptor for the spu device. */ + gchar *spu_filename; /* File name for the spu device. */ + int spu_fd; /* File descriptor for the spu device. */ gchar *control_filename; /* File name for the control device. */ int control_fd; /* File descriptor for the control - device. */ + device. */ GstClock *clock; /* The clock for this element. */ }; -struct _Dxr3SpuSinkClass { +struct _Dxr3SpuSinkClass +{ GstElementClass parent_class; /* Signals */ - void (*set_clut) (Dxr3SpuSink *sink, const guint32 *clut); - void (*highlight_on) (Dxr3SpuSink *sink, unsigned palette, - unsigned sx, unsigned sy, - unsigned ex, unsigned ey, - unsigned pts); - void (*highlight_off) (Dxr3SpuSink *sink); - void (*flushed) (Dxr3SpuSink *sink); + void (*set_clut) (Dxr3SpuSink * sink, const guint32 * clut); + void (*highlight_on) (Dxr3SpuSink * sink, unsigned palette, + unsigned sx, unsigned sy, unsigned ex, unsigned ey, unsigned pts); + void (*highlight_off) (Dxr3SpuSink * sink); + void (*flushed) (Dxr3SpuSink * sink); }; -extern GType dxr3spusink_get_type (void); -extern gboolean dxr3spusink_factory_init (GstPlugin *plugin); +extern GType dxr3spusink_get_type (void); +extern gboolean dxr3spusink_factory_init (GstPlugin * plugin); G_END_DECLS - #endif /* __DXR3SPUSINK_H__ */ diff --git a/sys/dxr3/dxr3videosink.c b/sys/dxr3/dxr3videosink.c index a87a94d8..616c12f3 100644 --- a/sys/dxr3/dxr3videosink.c +++ b/sys/dxr3/dxr3videosink.c @@ -49,28 +49,32 @@ static GstElementDetails dxr3videosink_details = { /* Dxr3VideoSink signals and args */ -enum { +enum +{ SIGNAL_FLUSHED, LAST_SIGNAL }; -enum { +enum +{ ARG_0, }; /* Possible states for the MPEG start code scanner. */ -enum { - SCAN_STATE_WAITING, /* Waiting for a code. */ - SCAN_STATE_0, /* 0 seen. */ - SCAN_STATE_00, /* 00 seen. */ - SCAN_STATE_001 /* 001 seen. */ +enum +{ + SCAN_STATE_WAITING, /* Waiting for a code. */ + SCAN_STATE_0, /* 0 seen. */ + SCAN_STATE_00, /* 00 seen. */ + SCAN_STATE_001 /* 001 seen. */ }; /* Possible states for the MPEG sequence parser. */ -enum { - PARSE_STATE_WAITING, /* Waiting for the start of a sequence. */ - PARSE_STATE_START, /* Start of sequence seen. */ - PARSE_STATE_PICTURE, /* Picture start seen. */ +enum +{ + PARSE_STATE_WAITING, /* Waiting for the start of a sequence. */ + PARSE_STATE_START, /* Start of sequence seen. */ + PARSE_STATE_PICTURE, /* Picture start seen. */ }; @@ -80,64 +84,53 @@ enum { #define START_CODE_SEQUENCE_END 0xB7 static GstStaticPadTemplate dxr3videosink_sink_factory = -GST_STATIC_PAD_TEMPLATE ( - "sink", - GST_PAD_SINK, - GST_PAD_ALWAYS, - GST_STATIC_CAPS ( - "video/mpeg, " - "mpegversion = (int) { 1, 2 }, " - "systemstream = (boolean) FALSE" - /* width/height/framerate omitted, we don't - * need a parsed stream */ - ) -); - - -static void dxr3videosink_class_init (Dxr3VideoSinkClass *klass); -static void dxr3videosink_base_init (Dxr3VideoSinkClass *klass); -static void dxr3videosink_init (Dxr3VideoSink *dxr3videosink); - -static void dxr3videosink_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static void dxr3videosink_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); - -static gboolean dxr3videosink_open (Dxr3VideoSink *sink); -static void dxr3videosink_close (Dxr3VideoSink *sink); -static void dxr3videosink_set_clock (GstElement *element, - GstClock *clock); - -static void dxr3videosink_reset_parser (Dxr3VideoSink *sink); -static int dxr3videosink_next_start_code (Dxr3VideoSink *sink); -static void dxr3videosink_discard_data (Dxr3VideoSink *sink, - guint cut); -static void dxr3videosink_write_data (Dxr3VideoSink *sink, - guint cut); -static void dxr3videosink_parse_data (Dxr3VideoSink *sink); - -static gboolean dxr3videosink_handle_event (GstPad *pad, GstEvent *event); -static void dxr3videosink_chain (GstPad *pad,GstData *_data); - -static GstElementStateReturn dxr3videosink_change_state (GstElement *element); +GST_STATIC_PAD_TEMPLATE ("sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + GST_STATIC_CAPS ("video/mpeg, " + "mpegversion = (int) { 1, 2 }, " "systemstream = (boolean) FALSE" + /* width/height/framerate omitted, we don't + * need a parsed stream */ + ) + ); + + +static void dxr3videosink_class_init (Dxr3VideoSinkClass * klass); +static void dxr3videosink_base_init (Dxr3VideoSinkClass * klass); +static void dxr3videosink_init (Dxr3VideoSink * dxr3videosink); + +static void dxr3videosink_set_property (GObject * object, + guint prop_id, const GValue * value, GParamSpec * pspec); +static void dxr3videosink_get_property (GObject * object, + guint prop_id, GValue * value, GParamSpec * pspec); + +static gboolean dxr3videosink_open (Dxr3VideoSink * sink); +static void dxr3videosink_close (Dxr3VideoSink * sink); +static void dxr3videosink_set_clock (GstElement * element, GstClock * clock); + +static void dxr3videosink_reset_parser (Dxr3VideoSink * sink); +static int dxr3videosink_next_start_code (Dxr3VideoSink * sink); +static void dxr3videosink_discard_data (Dxr3VideoSink * sink, guint cut); +static void dxr3videosink_write_data (Dxr3VideoSink * sink, guint cut); +static void dxr3videosink_parse_data (Dxr3VideoSink * sink); + +static gboolean dxr3videosink_handle_event (GstPad * pad, GstEvent * event); +static void dxr3videosink_chain (GstPad * pad, GstData * _data); + +static GstElementStateReturn dxr3videosink_change_state (GstElement * element); /* static void dxr3videosink_wait (Dxr3VideoSink *sink, */ /* GstClockTime time); */ -static int dxr3videosink_mvcommand (Dxr3VideoSink *sink, - int command); +static int dxr3videosink_mvcommand (Dxr3VideoSink * sink, int command); -static void dxr3videosink_flushed (Dxr3VideoSink *sink); +static void dxr3videosink_flushed (Dxr3VideoSink * sink); static GstElementClass *parent_class = NULL; static guint dxr3videosink_signals[LAST_SIGNAL] = { 0 }; extern GType -dxr3videosink_get_type (void) +dxr3videosink_get_type (void) { static GType dxr3videosink_type = 0; @@ -154,8 +147,7 @@ dxr3videosink_get_type (void) (GInstanceInitFunc) dxr3videosink_init, }; dxr3videosink_type = g_type_register_static (GST_TYPE_ELEMENT, - "Dxr3VideoSink", - &dxr3videosink_info, 0); + "Dxr3VideoSink", &dxr3videosink_info, 0); } return dxr3videosink_type; @@ -163,34 +155,31 @@ dxr3videosink_get_type (void) static void -dxr3videosink_base_init (Dxr3VideoSinkClass *klass) +dxr3videosink_base_init (Dxr3VideoSinkClass * klass) { GstElementClass *element_class = GST_ELEMENT_CLASS (klass); gst_element_class_add_pad_template (element_class, - gst_static_pad_template_get (&dxr3videosink_sink_factory)); - gst_element_class_set_details (element_class, - &dxr3videosink_details); + gst_static_pad_template_get (&dxr3videosink_sink_factory)); + gst_element_class_set_details (element_class, &dxr3videosink_details); } static void -dxr3videosink_class_init (Dxr3VideoSinkClass *klass) +dxr3videosink_class_init (Dxr3VideoSinkClass * 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); dxr3videosink_signals[SIGNAL_FLUSHED] = - g_signal_new ("flushed", G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (Dxr3VideoSinkClass, 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 (Dxr3VideoSinkClass, flushed), + NULL, NULL, dxr3_marshal_VOID__VOID, G_TYPE_NONE, 0); klass->flushed = dxr3videosink_flushed; @@ -202,13 +191,14 @@ dxr3videosink_class_init (Dxr3VideoSinkClass *klass) } -static void -dxr3videosink_init (Dxr3VideoSink *sink) +static void +dxr3videosink_init (Dxr3VideoSink * sink) { GstPad *pad; - pad = gst_pad_new_from_template ( - gst_static_pad_template_get (&dxr3videosink_sink_factory), "sink"); + pad = + gst_pad_new_from_template (gst_static_pad_template_get + (&dxr3videosink_sink_factory), "sink"); gst_element_add_pad (GST_ELEMENT (sink), pad); gst_pad_set_chain_function (pad, dxr3videosink_chain); @@ -231,8 +221,8 @@ dxr3videosink_init (Dxr3VideoSink *sink) static void -dxr3videosink_set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) +dxr3videosink_set_property (GObject * object, guint prop_id, + const GValue * value, GParamSpec * pspec) { Dxr3VideoSink *sink; @@ -246,17 +236,17 @@ dxr3videosink_set_property (GObject *object, guint prop_id, } -static void -dxr3videosink_get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) +static void +dxr3videosink_get_property (GObject * object, guint prop_id, + GValue * value, GParamSpec * pspec) { Dxr3VideoSink *sink; - + /* it's not null if we got it, but it might not be ours */ g_return_if_fail (GST_IS_DXR3VIDEOSINK (object)); - + sink = DXR3VIDEOSINK (object); - + switch (prop_id) { default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -266,32 +256,31 @@ dxr3videosink_get_property (GObject *object, guint prop_id, static gboolean -dxr3videosink_open (Dxr3VideoSink *sink) +dxr3videosink_open (Dxr3VideoSink * sink) { - g_return_val_if_fail (!GST_FLAG_IS_SET (sink, - DXR3VIDEOSINK_OPEN), FALSE); + g_return_val_if_fail (!GST_FLAG_IS_SET (sink, DXR3VIDEOSINK_OPEN), FALSE); /* Compute the name of the video device file. */ sink->video_filename = g_strdup_printf ("/dev/em8300_mv-%d", - sink->card_number ); + sink->card_number); sink->video_fd = open (sink->video_filename, O_WRONLY); if (sink->video_fd < 0) { GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE, - (_("Could not open video device \"%s\" for writing."), sink->video_filename), - GST_ERROR_SYSTEM); + (_("Could not open video device \"%s\" for writing."), + sink->video_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; } @@ -302,23 +291,21 @@ dxr3videosink_open (Dxr3VideoSink *sink) static void -dxr3videosink_close (Dxr3VideoSink *sink) +dxr3videosink_close (Dxr3VideoSink * sink) { g_return_if_fail (GST_FLAG_IS_SET (sink, DXR3VIDEOSINK_OPEN)); - if (close (sink->video_fd) != 0) - { + if (close (sink->video_fd) != 0) { GST_ELEMENT_ERROR (sink, RESOURCE, CLOSE, - (_("Could not close video device \"%s\"."), sink->video_filename), - GST_ERROR_SYSTEM); + (_("Could not close video device \"%s\"."), sink->video_filename), + GST_ERROR_SYSTEM); return; } - if (close (sink->control_fd) != 0) - { + if (close (sink->control_fd) != 0) { GST_ELEMENT_ERROR (sink, RESOURCE, CLOSE, - (_("Could not close control device \"%s\"."), sink->control_filename), - GST_ERROR_SYSTEM); + (_("Could not close control device \"%s\"."), sink->control_filename), + GST_ERROR_SYSTEM); return; } @@ -330,7 +317,7 @@ dxr3videosink_close (Dxr3VideoSink *sink) static void -dxr3videosink_set_clock (GstElement *element, GstClock *clock) +dxr3videosink_set_clock (GstElement * element, GstClock * clock) { Dxr3VideoSink *src = DXR3VIDEOSINK (element); @@ -339,7 +326,7 @@ dxr3videosink_set_clock (GstElement *element, GstClock *clock) static void -dxr3videosink_reset_parser (Dxr3VideoSink *sink) +dxr3videosink_reset_parser (Dxr3VideoSink * sink) { if (sink->cur_buf != NULL) { gst_buffer_unref (sink->cur_buf); @@ -355,7 +342,7 @@ dxr3videosink_reset_parser (Dxr3VideoSink *sink) static int -dxr3videosink_next_start_code (Dxr3VideoSink *sink) +dxr3videosink_next_start_code (Dxr3VideoSink * sink) { guchar c; @@ -365,31 +352,29 @@ dxr3videosink_next_start_code (Dxr3VideoSink *sink) c = (GST_BUFFER_DATA (sink->cur_buf))[sink->scan_pos]; switch (sink->scan_state) { - case SCAN_STATE_WAITING: - if (c == 0x00) { - sink->scan_state = SCAN_STATE_0; - } - break; - case SCAN_STATE_0: - if (c == 0x00) { - sink->scan_state = SCAN_STATE_00; - } - else { - sink->scan_state = SCAN_STATE_WAITING; - } - break; - case SCAN_STATE_00: - if (c == 0x01) { - sink->scan_state = SCAN_STATE_001; - } - else if (c != 0x00) { - sink->scan_state = SCAN_STATE_WAITING; - } - break; - case SCAN_STATE_001: - sink->scan_pos++; - sink->scan_state = SCAN_STATE_WAITING; - return c; + case SCAN_STATE_WAITING: + if (c == 0x00) { + sink->scan_state = SCAN_STATE_0; + } + break; + case SCAN_STATE_0: + if (c == 0x00) { + sink->scan_state = SCAN_STATE_00; + } else { + sink->scan_state = SCAN_STATE_WAITING; + } + break; + case SCAN_STATE_00: + if (c == 0x01) { + sink->scan_state = SCAN_STATE_001; + } else if (c != 0x00) { + sink->scan_state = SCAN_STATE_WAITING; + } + break; + case SCAN_STATE_001: + sink->scan_pos++; + sink->scan_state = SCAN_STATE_WAITING; + return c; } sink->scan_pos++; @@ -400,7 +385,7 @@ dxr3videosink_next_start_code (Dxr3VideoSink *sink) static void -dxr3videosink_discard_data (Dxr3VideoSink *sink, guint cut) +dxr3videosink_discard_data (Dxr3VideoSink * sink, guint cut) { GstBuffer *sub; guint size; @@ -415,11 +400,10 @@ dxr3videosink_discard_data (Dxr3VideoSink *sink, guint cut) if (GST_BUFFER_SIZE (sink->cur_buf) == size) { gst_buffer_unref (sink->cur_buf); sink->cur_buf = NULL; - } - else { + } else { sub = gst_buffer_create_sub (sink->cur_buf, size, - GST_BUFFER_SIZE (sink->cur_buf) - - size); + GST_BUFFER_SIZE (sink->cur_buf) + - size); gst_buffer_unref (sink->cur_buf); sink->cur_buf = sub; } @@ -432,7 +416,7 @@ dxr3videosink_discard_data (Dxr3VideoSink *sink, guint cut) static void -dxr3videosink_write_data (Dxr3VideoSink *sink, guint cut) +dxr3videosink_write_data (Dxr3VideoSink * sink, guint cut) { guint size, written; guint8 *data; @@ -464,10 +448,10 @@ dxr3videosink_write_data (Dxr3VideoSink *sink, guint cut) while (size > 0) { written = write (sink->video_fd, data, size); if (written < 0) { - GST_ELEMENT_ERROR (sink, RESOURCE, WRITE, - (_("Could not write to device \"%s\"."), sink->video_filename), - GST_ERROR_SYSTEM); - break; + GST_ELEMENT_ERROR (sink, RESOURCE, WRITE, + (_("Could not write to device \"%s\"."), sink->video_filename), + GST_ERROR_SYSTEM); + break; } size = size - written; data = data + written; @@ -479,7 +463,7 @@ dxr3videosink_write_data (Dxr3VideoSink *sink, guint cut) static void -dxr3videosink_parse_data (Dxr3VideoSink *sink) +dxr3videosink_parse_data (Dxr3VideoSink * sink) { int code; @@ -491,46 +475,46 @@ dxr3videosink_parse_data (Dxr3VideoSink *sink) while (code >= 0) { switch (sink->parse_state) { - case PARSE_STATE_WAITING: - if (code == START_CODE_SEQUENCE_HEADER) { - dxr3videosink_discard_data (sink, 4); - sink->parse_state = PARSE_STATE_START; - sink->cur_ts = sink->last_ts; - } - break; - - case PARSE_STATE_START: - switch (code) { - case START_CODE_SEQUENCE_HEADER: - dxr3videosink_discard_data (sink, 4); - sink->cur_ts = sink->last_ts; - break; - case START_CODE_SEQUENCE_END: - dxr3videosink_discard_data (sink, 0); - sink->parse_state = PARSE_STATE_WAITING; - break; - case START_CODE_PICTURE: - sink->parse_state = PARSE_STATE_PICTURE; - break; - } - break; - - case PARSE_STATE_PICTURE: - switch (code) { - case START_CODE_SEQUENCE_HEADER: - dxr3videosink_write_data (sink, 4); - sink->parse_state = PARSE_STATE_START; - sink->cur_ts = sink->last_ts; - break; - case START_CODE_SEQUENCE_END: - dxr3videosink_write_data (sink, 0); - sink->parse_state = PARSE_STATE_WAITING; - break; - case START_CODE_PICTURE: - dxr3videosink_write_data (sink, 4); - break; - } - break; + case PARSE_STATE_WAITING: + if (code == START_CODE_SEQUENCE_HEADER) { + dxr3videosink_discard_data (sink, 4); + sink->parse_state = PARSE_STATE_START; + sink->cur_ts = sink->last_ts; + } + break; + + case PARSE_STATE_START: + switch (code) { + case START_CODE_SEQUENCE_HEADER: + dxr3videosink_discard_data (sink, 4); + sink->cur_ts = sink->last_ts; + break; + case START_CODE_SEQUENCE_END: + dxr3videosink_discard_data (sink, 0); + sink->parse_state = PARSE_STATE_WAITING; + break; + case START_CODE_PICTURE: + sink->parse_state = PARSE_STATE_PICTURE; + break; + } + break; + + case PARSE_STATE_PICTURE: + switch (code) { + case START_CODE_SEQUENCE_HEADER: + dxr3videosink_write_data (sink, 4); + sink->parse_state = PARSE_STATE_START; + sink->cur_ts = sink->last_ts; + break; + case START_CODE_SEQUENCE_END: + dxr3videosink_write_data (sink, 0); + sink->parse_state = PARSE_STATE_WAITING; + break; + case START_CODE_PICTURE: + dxr3videosink_write_data (sink, 4); + break; + } + break; } @@ -544,7 +528,7 @@ dxr3videosink_parse_data (Dxr3VideoSink *sink) static gboolean -dxr3videosink_handle_event (GstPad *pad, GstEvent *event) +dxr3videosink_handle_event (GstPad * pad, GstEvent * event) { GstEventType type; Dxr3VideoSink *sink; @@ -554,8 +538,8 @@ dxr3videosink_handle_event (GstPad *pad, GstEvent *event) type = event ? GST_EVENT_TYPE (event) : GST_EVENT_UNKNOWN; switch (type) { - case GST_EVENT_EMPTY: - //fprintf (stderr, "++++++ Video empty event\n"); + case GST_EVENT_EMPTY: + //fprintf (stderr, "++++++ Video empty event\n"); { /* FIXME: Handle this with a discontinuity or something. */ /* Write an MPEG2 sequence end code, to ensure that the card @@ -564,61 +548,59 @@ dxr3videosink_handle_event (GstPad *pad, GstEvent *event) static guint8 sec[4] = { 0x00, 0x00, 0x01, 0xb7 }; if (sink->cur_buf != NULL) { - dxr3videosink_write_data (sink, 0); + dxr3videosink_write_data (sink, 0); } write (sink->video_fd, &sec, 4); } - break; + break; - case GST_EVENT_DISCONTINUOUS: - //fprintf (stderr, "++++++ Video discont event\n"); + case GST_EVENT_DISCONTINUOUS: + //fprintf (stderr, "++++++ Video discont event\n"); { gint64 time; gboolean has_time; unsigned cur_scr, mpeg_scr, diff; - has_time = gst_event_discont_get_value (event, - GST_FORMAT_TIME, - &time); + has_time = gst_event_discont_get_value (event, GST_FORMAT_TIME, &time); if (has_time) { /* fprintf (stderr, "^^^^^^ Discontinuous event has time %.4f\n", */ /* (double) time / GST_SECOND); */ - /* If the SCR in the card is way off, fix it. */ - ioctl (sink->control_fd, EM8300_IOCTL_SCR_GET, &cur_scr); - mpeg_scr = MPEGTIME_TO_DXRTIME (GSTTIME_TO_MPEGTIME (time)); + /* If the SCR in the card is way off, fix it. */ + ioctl (sink->control_fd, EM8300_IOCTL_SCR_GET, &cur_scr); + mpeg_scr = MPEGTIME_TO_DXRTIME (GSTTIME_TO_MPEGTIME (time)); + + diff = cur_scr > mpeg_scr ? cur_scr - mpeg_scr : mpeg_scr - cur_scr; + if (diff > 1800) { + unsigned zero = 0; - diff = cur_scr > mpeg_scr ? cur_scr - mpeg_scr : mpeg_scr - cur_scr; - if (diff > 1800) { - unsigned zero = 0; /* fprintf (stderr, "====== Adjusting SCR from video\n"); */ - ioctl (sink->control_fd, EM8300_IOCTL_SCR_SET, &zero); - ioctl (sink->control_fd, EM8300_IOCTL_SCR_SET, &mpeg_scr); - } - } - else { + ioctl (sink->control_fd, EM8300_IOCTL_SCR_SET, &zero); + ioctl (sink->control_fd, EM8300_IOCTL_SCR_SET, &mpeg_scr); + } + } else { /* fprintf (stderr, "^^^^^^ Discontinuous event has no time\n"); */ } } - break; + break; - case GST_EVENT_FLUSH: - dxr3videosink_reset_parser (sink); - break; + case GST_EVENT_FLUSH: + dxr3videosink_reset_parser (sink); + break; - default: - gst_pad_event_default (pad, event); - break; + default: + gst_pad_event_default (pad, event); + break; } return TRUE; } -static void -dxr3videosink_chain (GstPad *pad, GstData *_data) +static void +dxr3videosink_chain (GstPad * pad, GstData * _data) { GstBuffer *buf = GST_BUFFER (_data); Dxr3VideoSink *sink; @@ -639,8 +621,7 @@ dxr3videosink_chain (GstPad *pad, GstData *_data) if (sink->cur_buf == NULL) { sink->cur_buf = buf; - } - else { + } else { merged = gst_buffer_merge (sink->cur_buf, buf); gst_buffer_unref (sink->cur_buf); gst_buffer_unref (buf); @@ -654,16 +635,16 @@ dxr3videosink_chain (GstPad *pad, GstData *_data) static GstElementStateReturn -dxr3videosink_change_state (GstElement *element) +dxr3videosink_change_state (GstElement * element) { g_return_val_if_fail (GST_IS_DXR3VIDEOSINK (element), GST_STATE_FAILURE); switch (GST_STATE_TRANSITION (element)) { case GST_STATE_NULL_TO_READY: if (!GST_FLAG_IS_SET (element, DXR3VIDEOSINK_OPEN)) { - if (!dxr3videosink_open (DXR3VIDEOSINK (element))) { - return GST_STATE_FAILURE; - } + if (!dxr3videosink_open (DXR3VIDEOSINK (element))) { + return GST_STATE_FAILURE; + } } break; case GST_STATE_READY_TO_PAUSED: @@ -680,7 +661,7 @@ dxr3videosink_change_state (GstElement *element) break; case GST_STATE_READY_TO_NULL: if (GST_FLAG_IS_SET (element, DXR3VIDEOSINK_OPEN)) { - dxr3videosink_close (DXR3VIDEOSINK (element)); + dxr3videosink_close (DXR3VIDEOSINK (element)); } break; } @@ -698,7 +679,7 @@ dxr3videosink_change_state (GstElement *element) * Make the sink wait the specified amount of time. */ static void -dxr3videosink_wait (Dxr3VideoSink *sink, GstClockTime time) +dxr3videosink_wait (Dxr3VideoSink * sink, GstClockTime time) { GstClockID id; GstClockTimeDiff jitter; @@ -717,14 +698,14 @@ dxr3videosink_wait (Dxr3VideoSink *sink, GstClockTime time) * Send an MVCOMMAND to the card. */ static int -dxr3videosink_mvcommand (Dxr3VideoSink *sink, int command) +dxr3videosink_mvcommand (Dxr3VideoSink * 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); } @@ -737,7 +718,7 @@ dxr3videosink_mvcommand (Dxr3VideoSink *sink, int command) * queues due to a received flush event */ static void -dxr3videosink_flushed (Dxr3VideoSink *sink) +dxr3videosink_flushed (Dxr3VideoSink * sink) { /* Do nothing. */ } diff --git a/sys/dxr3/dxr3videosink.h b/sys/dxr3/dxr3videosink.h index b0e5cadf..03aa8c36 100644 --- a/sys/dxr3/dxr3videosink.h +++ b/sys/dxr3/dxr3videosink.h @@ -25,8 +25,6 @@ #include <gst/gst.h> G_BEGIN_DECLS - - #define GST_TYPE_DXR3VIDEOSINK \ (dxr3videosink_get_type()) #define DXR3VIDEOSINK(obj) \ @@ -37,19 +35,19 @@ G_BEGIN_DECLS (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DXR3VIDEOSINK)) #define GST_IS_DXR3VIDEOSINK_CLASS(obj) \ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DXR3VIDEOSINK)) - - typedef struct _Dxr3VideoSink Dxr3VideoSink; typedef struct _Dxr3VideoSinkClass Dxr3VideoSinkClass; -typedef enum { +typedef enum +{ DXR3VIDEOSINK_OPEN = GST_ELEMENT_FLAG_LAST, - DXR3VIDEOSINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2, + DXR3VIDEOSINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST + 2, } Dxr3VideoSinkFlags; -struct _Dxr3VideoSink { +struct _Dxr3VideoSink +{ GstElement element; int card_number; /* The number of the card to open. */ @@ -58,40 +56,40 @@ struct _Dxr3VideoSink { int video_fd; /* File descriptor for the video device. */ gchar *control_filename; /* File name for the control device. */ - int control_fd; /* File descriptor for the control - device. */ + int control_fd; /* File descriptor for the control + device. */ GstClock *clock; /* The clock for this element. */ GstClockTime last_ts; /* Last timestamp received. */ GstBuffer *cur_buf; /* The buffer we are currently - building. */ + building. */ GstClockTime cur_ts; /* Timestamp associated to the - current buffer. */ + current buffer. */ guchar scan_state; /* The current state of the MPEG start - code scanner. */ + code scanner. */ guint scan_pos; /* The current position of the MPEG - start code scanner (with respect to - the start of the current buffer. */ + start code scanner (with respect to + the start of the current buffer. */ guchar parse_state; /* The current state of the MPEG - sequence parser. */ + sequence parser. */ }; -struct _Dxr3VideoSinkClass { +struct _Dxr3VideoSinkClass +{ GstElementClass parent_class; /* signals */ - void (*flushed) (Dxr3VideoSink *sink); + void (*flushed) (Dxr3VideoSink * sink); }; -extern GType dxr3videosink_get_type (void); -extern gboolean dxr3videosink_factory_init (GstPlugin *plugin); +extern GType dxr3videosink_get_type (void); +extern gboolean dxr3videosink_factory_init (GstPlugin * plugin); G_END_DECLS - #endif /* __DXR3VIDEOSINK_H__ */ |