commit a927d85725fe935b29fa286e9422f454b4da57de
Author: Jaroslav Tulach <jaroslav.tulach@gmail.org>
Date:   Sat Mar 17 07:13:27 2012 +0100

    Initial changes to make sure sys/dxr3 compiles

diff --git a/.gitignore b/.gitignore
index ddb619a..7d6b7cd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -39,3 +39,5 @@ tests/examples/shapewipe/shapewipe-example
 /m4
 Makefile.in
 Makefile
+sys/dxr3/dxr3marshal.h
+
diff --git a/configure.ac b/configure.ac
index 9d02d9e..62c3872 100644
--- a/configure.ac
+++ b/configure.ac
@@ -349,6 +349,20 @@ fi
 
 dnl *** sys plug-ins ***
 
+dnl *** DXR3 card ***
+translit(dnm, m, l) AM_CONDITIONAL(USE_DXR3, true)
+AG_GST_CHECK_FEATURE(DXR3, [DXR3 hardware MPEG DVD decoder],
+  dxr3videosink dxr3audiosink dxr3spusink, [
+  HAVE_DXR3=yes
+  AC_CHECK_HEADER(linux/em8300.h, ,
+                  [ AC_MSG_WARN([DXR3/em8300 header file not found]) &&
+                    HAVE_DXR3=no ] )
+  AC_CHECK_HEADER(linux/soundcard.h, ,
+                  [ AC_MSG_WARN([Generic sound header file not found]) &&
+                    HAVE_DXR3=no ] )
+])
+
+
 dnl DirectSound
 translit(dnm, m, l) AM_CONDITIONAL(USE_DIRECTSOUND, true)
 AG_GST_CHECK_FEATURE(DIRECTSOUND, [DirectSound], directsoundsrc, [
@@ -1683,6 +1697,7 @@ sys/directsound/Makefile
 sys/dshowsrcwrapper/Makefile
 sys/dshowvideosink/Makefile
 sys/dvb/Makefile
+sys/dxr3/Makefile
 sys/fbdev/Makefile
 sys/oss4/Makefile
 sys/osxvideo/Makefile
diff --git a/sys/Makefile.am b/sys/Makefile.am
index 5608a8e..1c4b815 100644
--- a/sys/Makefile.am
+++ b/sys/Makefile.am
@@ -1,8 +1,8 @@
-# if USE_DXR3
-# DXR3_DIR=dxr3
-# else
-# DXR3_DIR=
-# endif
+if USE_DXR3
+DXR3_DIR=dxr3
+else
+DXR3_DIR=
+endif
 
 # if USE_QCAM
 # QCAM_DIR=qcam
@@ -82,7 +82,7 @@ else
 VDPAU_DIR=
 endif
 
-SUBDIRS = $(ACM_DIR) $(DIRECTDRAW_DIR) $(DIRECTSOUND_DIR) $(DVB_DIR) $(FBDEV_DIR) $(OSS4_DIR) $(OSX_VIDEO_DIR) $(QT_DIR) $(VCD_DIR) $(VDPAU_DIR) $(WININET_DIR)
+SUBDIRS = $(ACM_DIR) $(DIRECTDRAW_DIR) $(DIRECTSOUND_DIR) $(DVB_DIR) $(DXR3_DIR) $(FBDEV_DIR) $(OSS4_DIR) $(OSX_VIDEO_DIR) $(QT_DIR) $(VCD_DIR) $(VDPAU_DIR) $(WININET_DIR)
 
 DIST_SUBDIRS = acmenc acmmp3dec directdraw directsound dvb fbdev dshowdecwrapper dshowsrcwrapper dshowvideosink \
 			   oss4 osxvideo qtwrapper vcd vdpau wasapi wininet winks winscreencap
diff --git a/sys/dxr3/dxr3audiosink.c b/sys/dxr3/dxr3audiosink.c
index 284ced2..8cca8bd 100644
--- a/sys/dxr3/dxr3audiosink.c
+++ b/sys/dxr3/dxr3audiosink.c
@@ -103,15 +103,14 @@ 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 gboolean dxr3audiosink_set_clock (GstElement * element, GstClock * clock);
 
-static GstPadLinkReturn dxr3audiosink_pcm_sinklink (GstPad * pad,
-    const GstCaps * caps);
+static GstPadLinkReturn dxr3audiosink_pcm_sinklink (GstPad * pad, GstPad * peer);
 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 GstFlowReturn dxr3audiosink_chain_pcm (GstPad * pad, GstBuffer * buf);
+static GstFlowReturn dxr3audiosink_chain_ac3 (GstPad * pad, GstBuffer * buf);
 
 /* static void  dxr3audiosink_wait              (Dxr3AudioSink *sink, */
 /*                                                  GstClockTime time); */
@@ -214,7 +213,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_OBJECT_FLAG_SET (GST_ELEMENT (sink), GST_ELEMENT_EVENT_AWARE);
+//  GST_OBJECT_FLAG_SET (GST_ELEMENT (sink), GST_ELEMENT_EVENT_AWARE);
 
   sink->card_number = 0;
 
@@ -447,24 +446,26 @@ dxr3audiosink_close (Dxr3AudioSink * sink)
 }
 
 
-static void
+static gboolean
 dxr3audiosink_set_clock (GstElement * element, GstClock * clock)
 {
   Dxr3AudioSink *src = DXR3AUDIOSINK (element);
 
   src->clock = clock;
+  return TRUE;
 }
 
 
 static GstPadLinkReturn
-dxr3audiosink_pcm_sinklink (GstPad * pad, const GstCaps * caps)
+dxr3audiosink_pcm_sinklink (GstPad * pad, GstPad  * peer)
 {
+  GstCaps* caps = gst_pad_get_caps(peer);
   Dxr3AudioSink *sink = DXR3AUDIOSINK (gst_pad_get_parent (pad));
   GstStructure *structure = gst_caps_get_structure (caps, 0);
   gint rate;
 
   if (!gst_caps_is_fixed (caps)) {
-    return GST_PAD_LINK_DELAYED;
+    return GST_PAD_LINK_NOSCHED;
   }
 
   gst_structure_get_int (structure, "rate", &rate);
@@ -494,7 +495,8 @@ dxr3audiosink_handle_event (GstPad * pad, GstEvent * event)
   type = event ? GST_EVENT_TYPE (event) : GST_EVENT_UNKNOWN;
 
   switch (type) {
-    case GST_EVENT_FLUSH:
+    case GST_EVENT_FLUSH_START:
+    case GST_EVENT_FLUSH_STOP:
       if (sink->control_fd >= 0) {
         unsigned audiomode;
 
@@ -519,26 +521,22 @@ dxr3audiosink_handle_event (GstPad * pad, GstEvent * event)
 }
 
 
-static void
-dxr3audiosink_chain_pcm (GstPad * pad, GstData * _data)
+static GstFlowReturn
+dxr3audiosink_chain_pcm (GstPad * pad, GstBuffer * buf)
 {
   Dxr3AudioSink *sink;
   gint bytes_written = 0;
-  GstBuffer *buf;
-
-  g_return_if_fail (pad != NULL);
-  g_return_if_fail (GST_IS_PAD (pad));
-  g_return_if_fail (_data != NULL);
+  g_return_val_if_fail (pad != NULL, GST_FLOW_CUSTOM_ERROR);
+  g_return_val_if_fail (GST_IS_PAD (pad), GST_FLOW_CUSTOM_ERROR);
+  g_return_val_if_fail (buf != NULL, GST_FLOW_CUSTOM_ERROR);
 
   sink = DXR3AUDIOSINK (gst_pad_get_parent (pad));
 
-  if (GST_IS_EVENT (_data)) {
-    dxr3audiosink_handle_event (pad, GST_EVENT (_data));
-    return;
+  if (GST_IS_EVENT (buf)) {
+    dxr3audiosink_handle_event (pad, GST_EVENT (buf));
+    return GST_FLOW_OK;
   }
 
-  buf = GST_BUFFER (_data);
-
   if (sink->mode != DXR3AUDIOSINK_MODE_PCM) {
     /* Switch to PCM mode. */
     dxr3audiosink_set_mode_pcm (sink);
@@ -581,29 +579,27 @@ dxr3audiosink_chain_pcm (GstPad * pad, GstData * _data)
   }
 
   gst_buffer_unref (buf);
+  return GST_FLOW_OK;
 }
 
 
-static void
-dxr3audiosink_chain_ac3 (GstPad * pad, GstData * _data)
+static GstFlowReturn
+dxr3audiosink_chain_ac3 (GstPad * pad, GstBuffer * buf)
 {
   Dxr3AudioSink *sink;
   gint bytes_written = 0;
-  GstBuffer *buf;
 
-  g_return_if_fail (pad != NULL);
-  g_return_if_fail (GST_IS_PAD (pad));
-  g_return_if_fail (_data != NULL);
+  g_return_val_if_fail (pad != NULL, GST_FLOW_CUSTOM_ERROR);
+  g_return_val_if_fail (GST_IS_PAD (pad), GST_FLOW_CUSTOM_ERROR);
+  g_return_val_if_fail (buf != NULL, GST_FLOW_CUSTOM_ERROR);
 
   sink = DXR3AUDIOSINK (gst_pad_get_parent (pad));
 
-  if (GST_IS_EVENT (_data)) {
-    dxr3audiosink_handle_event (pad, GST_EVENT (_data));
-    return;
+  if (GST_IS_EVENT (buf)) {
+    dxr3audiosink_handle_event (pad, GST_EVENT (buf));
+    return GST_FLOW_OK;
   }
 
-  buf = GST_BUFFER (_data);
-
   if (sink->mode != DXR3AUDIOSINK_MODE_AC3) {
     /* Switch to AC3 mode. */
     dxr3audiosink_set_mode_ac3 (sink);
@@ -669,6 +665,7 @@ dxr3audiosink_chain_ac3 (GstPad * pad, GstData * _data)
   }
 
   gst_buffer_unref (buf);
+  return GST_FLOW_OK;
 }
 
 #if 0
diff --git a/sys/dxr3/dxr3spusink.c b/sys/dxr3/dxr3spusink.c
index 0b220f8..0906bca 100644
--- a/sys/dxr3/dxr3spusink.c
+++ b/sys/dxr3/dxr3spusink.c
@@ -82,10 +82,10 @@ static void dxr3spusink_get_property (GObject * object,
 
 static gboolean dxr3spusink_open (Dxr3SpuSink * sink);
 static void dxr3spusink_close (Dxr3SpuSink * sink);
-static void dxr3spusink_set_clock (GstElement * element, GstClock * clock);
+static gboolean 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 GstFlowReturn dxr3spusink_chain (GstPad * pad, GstBuffer * _data);
 
 static GstStateChangeReturn dxr3spusink_change_state (GstElement * element,
     GstStateChange transition);
@@ -205,7 +205,7 @@ dxr3spusink_init (Dxr3SpuSink * sink)
   gst_element_add_pad (GST_ELEMENT (sink), pad);
   gst_pad_set_chain_function (pad, dxr3spusink_chain);
 
-  GST_OBJECT_FLAG_SET (GST_ELEMENT (sink), GST_ELEMENT_EVENT_AWARE);
+//  GST_OBJECT_FLAG_SET (GST_ELEMENT (sink), GST_ELEMENT_EVENT_AWARE);
 
   sink->card_number = 0;
 
@@ -312,12 +312,13 @@ dxr3spusink_close (Dxr3SpuSink * sink)
 }
 
 
-static void
+static gboolean
 dxr3spusink_set_clock (GstElement * element, GstClock * clock)
 {
   Dxr3SpuSink *src = DXR3SPUSINK (element);
 
   src->clock = clock;
+  return TRUE;
 }
 
 
@@ -332,7 +333,8 @@ dxr3spusink_handle_event (GstPad * pad, GstEvent * event)
   type = event ? GST_EVENT_TYPE (event) : GST_EVENT_UNKNOWN;
 
   switch (type) {
-    case GST_EVENT_FLUSH:
+    case GST_EVENT_FLUSH_START:
+    case GST_EVENT_FLUSH_STOP:
       if (sink->control_fd >= 0) {
         int subdevice;
 
@@ -358,22 +360,21 @@ dxr3spusink_handle_event (GstPad * pad, GstEvent * event)
 }
 
 
-static void
-dxr3spusink_chain (GstPad * pad, GstData * _data)
+static GstFlowReturn
+dxr3spusink_chain (GstPad * pad, GstBuffer * buf)
 {
-  GstBuffer *buf = GST_BUFFER (_data);
   Dxr3SpuSink *sink;
   gint bytes_written = 0;
 
-  g_return_if_fail (pad != NULL);
-  g_return_if_fail (GST_IS_PAD (pad));
-  g_return_if_fail (buf != NULL);
+  g_return_val_if_fail (pad != NULL, GST_FLOW_CUSTOM_ERROR);
+  g_return_val_if_fail (GST_IS_PAD (pad), GST_FLOW_CUSTOM_ERROR);
+  g_return_val_if_fail (buf != NULL, GST_FLOW_CUSTOM_ERROR);
 
   sink = DXR3SPUSINK (gst_pad_get_parent (pad));
 
   if (GST_IS_EVENT (buf)) {
     dxr3spusink_handle_event (pad, GST_EVENT (buf));
-    return;
+    return GST_FLOW_OK;
   }
 
   if (GST_OBJECT_FLAG_IS_SET (sink, DXR3SPUSINK_OPEN)) {
@@ -394,6 +395,7 @@ dxr3spusink_chain (GstPad * pad, GstData * _data)
   }
 
   gst_buffer_unref (buf);
+  return GST_FLOW_OK;
 }
 
 
diff --git a/sys/dxr3/dxr3videosink.c b/sys/dxr3/dxr3videosink.c
index 475cfbd..a0a80b2 100644
--- a/sys/dxr3/dxr3videosink.c
+++ b/sys/dxr3/dxr3videosink.c
@@ -106,7 +106,7 @@ static void dxr3videosink_get_property (GObject * object,
 
 static gboolean dxr3videosink_open (Dxr3VideoSink * sink);
 static void dxr3videosink_close (Dxr3VideoSink * sink);
-static void dxr3videosink_set_clock (GstElement * element, GstClock * clock);
+static gboolean dxr3videosink_set_clock (GstElement * element, GstClock * clock);
 
 static void dxr3videosink_reset_parser (Dxr3VideoSink * sink);
 static int dxr3videosink_next_start_code (Dxr3VideoSink * sink);
@@ -115,7 +115,7 @@ 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 GstFlowReturn dxr3videosink_chain (GstPad * pad, GstBuffer* _data);
 
 static GstStateChangeReturn dxr3videosink_change_state (GstElement * element,
     GstStateChange transition);
@@ -202,7 +202,7 @@ dxr3videosink_init (Dxr3VideoSink * sink)
   gst_element_add_pad (GST_ELEMENT (sink), pad);
   gst_pad_set_chain_function (pad, dxr3videosink_chain);
 
-  GST_OBJECT_FLAG_SET (GST_ELEMENT (sink), GST_ELEMENT_EVENT_AWARE);
+//  GST_OBJECT_FLAG_SET (GST_ELEMENT (sink), GST_ELEMENT_EVENT_AWARE);
 
   sink->card_number = 0;
 
@@ -315,12 +315,13 @@ dxr3videosink_close (Dxr3VideoSink * sink)
 }
 
 
-static void
+static gboolean
 dxr3videosink_set_clock (GstElement * element, GstClock * clock)
 {
   Dxr3VideoSink *src = DXR3VIDEOSINK (element);
 
   src->clock = clock;
+  return TRUE;
 }
 
 
@@ -537,7 +538,7 @@ dxr3videosink_handle_event (GstPad * pad, GstEvent * event)
   type = event ? GST_EVENT_TYPE (event) : GST_EVENT_UNKNOWN;
 
   switch (type) {
-    case GST_EVENT_EMPTY:
+    case GST_EVENT_EOS:
       //fprintf (stderr, "++++++ Video empty event\n");
     {
       /* FIXME: Handle this with a discontinuity or something. */
@@ -554,14 +555,15 @@ dxr3videosink_handle_event (GstPad * pad, GstEvent * event)
     }
       break;
 
-    case GST_EVENT_DISCONTINUOUS:
+    case GST_EVENT_SEEK:
       //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 = TRUE; 
+      time = GST_EVENT_TIMESTAMP(event);
       if (has_time) {
 /*         fprintf (stderr, "^^^^^^ Discontinuous event has time %.4f\n", */
 /*                  (double) time / GST_SECOND); */
@@ -585,7 +587,8 @@ dxr3videosink_handle_event (GstPad * pad, GstEvent * event)
     }
       break;
 
-    case GST_EVENT_FLUSH:
+    case GST_EVENT_FLUSH_START:
+    case GST_EVENT_FLUSH_STOP:
       dxr3videosink_reset_parser (sink);
       break;
 
@@ -598,22 +601,22 @@ dxr3videosink_handle_event (GstPad * pad, GstEvent * event)
 }
 
 
-static void
-dxr3videosink_chain (GstPad * pad, GstData * _data)
+static GstFlowReturn
+dxr3videosink_chain (GstPad * pad, GstBuffer * _data)
 {
   GstBuffer *buf = GST_BUFFER (_data);
   Dxr3VideoSink *sink;
   GstBuffer *merged;
 
-  g_return_if_fail (pad != NULL);
-  g_return_if_fail (GST_IS_PAD (pad));
-  g_return_if_fail (buf != NULL);
+  g_return_val_if_fail (pad != NULL, GST_FLOW_CUSTOM_ERROR);
+  g_return_val_if_fail (GST_IS_PAD (pad), GST_FLOW_CUSTOM_ERROR);
+  g_return_val_if_fail (buf != NULL, GST_FLOW_CUSTOM_ERROR);
 
   sink = DXR3VIDEOSINK (gst_pad_get_parent (pad));
 
   if (GST_IS_EVENT (buf)) {
     dxr3videosink_handle_event (pad, GST_EVENT (buf));
-    return;
+    return GST_FLOW_OK;
   }
 
 /*   fprintf (stderr, "^^^^^^ Video block\n"); */
@@ -630,6 +633,7 @@ dxr3videosink_chain (GstPad * pad, GstData * _data)
   sink->last_ts = GST_BUFFER_TIMESTAMP (buf);
 
   dxr3videosink_parse_data (sink);
+  return GST_FLOW_OK;
 }
 
 
