diff --git a/gst/gstinfo.c b/gst/gstinfo.c
index 3f56686..fa4534a 100644
--- a/gst/gstinfo.c
+++ b/gst/gstinfo.c
@@ -448,7 +448,6 @@ gst_debug_log (GstDebugCategory * category, GstDebugLevel level,
   va_end (var_args);
 }
 
-#ifdef G_OS_WIN32
 /* based on g_basename(), which we can't use because it was deprecated */
 static inline const gchar *
 gst_path_basename (const gchar * file_name)
@@ -471,7 +470,6 @@ gst_path_basename (const gchar * file_name)
 
   return file_name;
 }
-#endif
 
 /**
  * gst_debug_log_valist:
@@ -501,12 +499,11 @@ gst_debug_log_valist (GstDebugCategory * category, GstDebugLevel level,
   g_return_if_fail (function != NULL);
   g_return_if_fail (format != NULL);
 
-  /* The predefined macro __FILE__ is always the exact path given to the
-   * compiler with MSVC, which may or may not be the basename.  We work
-   * around it at runtime to improve the readability. */
-#ifdef G_OS_WIN32
+  /* The predefined macro __FILE__ can be an absolute path in some build
+   * environments, such as MSVC or out-of-tree cross-compiles. This may
+   * be significantly longer than the filename.  We work around it at
+   * runtime to improve the readability. */
   file = gst_path_basename (file);
-#endif
 
   message.message = NULL;
   message.format = format;
diff --git a/libs/gst/base/gstbaseparse.c b/libs/gst/base/gstbaseparse.c
index 57e78bb..31bf0c0 100644
--- a/libs/gst/base/gstbaseparse.c
+++ b/libs/gst/base/gstbaseparse.c
@@ -1151,8 +1151,10 @@ gst_base_parse_sink_event_default (GstBaseParse * parse, GstEvent * event)
 
       /* If we STILL have zero frames processed, fire an error */
       if (parse->priv->framecount == 0) {
-        GST_ELEMENT_ERROR (parse, STREAM, WRONG_TYPE,
-            ("No valid frames found before end of stream"), (NULL));
+      /*  GST_ELEMENT_ERROR (parse, STREAM, WRONG_TYPE,
+            ("No valid frames found before end of stream"), (NULL));*/
+        GST_ERROR_OBJECT(parse, "No valid frames decoded before end of stream");
+
       }
       /* newsegment and other serialized events before eos */
       gst_base_parse_push_pending_events (parse);
diff --git a/libs/gst/base/gstbasesink.c b/libs/gst/base/gstbasesink.c
index de295a5..ed5822c 100644
--- a/libs/gst/base/gstbasesink.c
+++ b/libs/gst/base/gstbasesink.c
@@ -3356,10 +3356,28 @@ gst_base_sink_chain_unlocked (GstBaseSink * basesink, GstPad * pad,
     if (G_UNLIKELY (stepped))
       goto dropped;
 
-    if (syncable && do_sync)
-      late =
-          gst_base_sink_is_too_late (basesink, obj, rstart, rstop,
-          GST_CLOCK_EARLY, 0, FALSE);
+    if (syncable && do_sync && gst_base_sink_get_sync (basesink)) {
+      GstClock *clock;
+
+      GST_OBJECT_LOCK (basesink);
+      clock = GST_ELEMENT_CLOCK (basesink);
+      if (clock && GST_STATE (basesink) == GST_STATE_PLAYING) {
+        GstClockTime base_time;
+        GstClockTime stime;
+        GstClockTime now;
+
+        base_time = GST_ELEMENT_CAST (basesink)->base_time;
+        stime = base_time + gst_base_sink_adjust_time (basesink, rstart);
+        now = gst_clock_get_time (clock);
+        GST_OBJECT_UNLOCK (basesink);
+
+        late =
+            gst_base_sink_is_too_late (basesink, obj, rstart, rstop,
+            GST_CLOCK_EARLY, GST_CLOCK_DIFF (stime, now), FALSE);
+      } else {
+        GST_OBJECT_UNLOCK (basesink);
+      }
+    }
 
     if (G_UNLIKELY (late))
       goto dropped;
diff --git a/plugins/elements/gstinputselector.c b/plugins/elements/gstinputselector.c
index fb50802..4461f7c 100644
--- a/plugins/elements/gstinputselector.c
+++ b/plugins/elements/gstinputselector.c
@@ -440,6 +440,17 @@ gst_selector_pad_iterate_linked_pads (GstPad * pad, GstObject * parent)
 }
 
 static gboolean
+gst_input_selector_eos_wait (GstInputSelector * self, GstSelectorPad * pad)
+{
+  while (!self->eos && !self->flushing && !pad->flushing) {
+    /* we can be unlocked here when we are shutting down (flushing) or when we
+     * get unblocked */
+    GST_INPUT_SELECTOR_WAIT (self);
+  }
+  return self->flushing;
+}
+
+static gboolean
 gst_selector_pad_event (GstPad * pad, GstObject * parent, GstEvent * event)
 {
   gboolean res = TRUE;
@@ -486,6 +497,7 @@ gst_selector_pad_event (GstPad * pad, GstObject * parent, GstEvent * event)
     case GST_EVENT_FLUSH_START:
       /* Unblock the pad if it's waiting */
       selpad->flushing = TRUE;
+      sel->eos = FALSE;
       GST_INPUT_SELECTOR_BROADCAST (sel);
       break;
     case GST_EVENT_FLUSH_STOP:
@@ -523,21 +535,12 @@ gst_selector_pad_event (GstPad * pad, GstObject * parent, GstEvent * event)
     case GST_EVENT_EOS:
       selpad->eos = TRUE;
 
-      if (forward) {
-        selpad->eos_sent = TRUE;
-      } else {
-        GstSelectorPad *active_selpad;
-
-        /* If the active sinkpad is in EOS state but EOS
-         * was not sent downstream this means that the pad
-         * got EOS before it was set as active pad and that
-         * the previously active pad got EOS after it was
-         * active
-         */
-        active_selpad = GST_SELECTOR_PAD (active_sinkpad);
-        forward = (active_selpad->eos && !active_selpad->eos_sent);
-        active_selpad->eos_sent = TRUE;
+      if (!forward) {
+        /* blocked until active the sind pad or flush */
+        gst_input_selector_eos_wait (sel, selpad);
+        forward = TRUE;
       }
+      selpad->eos_sent = TRUE;
       GST_DEBUG_OBJECT (pad, "received EOS");
       break;
     case GST_EVENT_GAP:{
@@ -676,6 +679,12 @@ gst_input_selector_wait_running_time (GstInputSelector * sel,
         gst_input_selector_activate_sinkpad (sel, GST_PAD_CAST (selpad));
     active_selpad = GST_SELECTOR_PAD_CAST (active_sinkpad);
 
+    if (sel->eos) {
+      GST_DEBUG_OBJECT (sel, "Not waiting because inputselector reach EOS.");
+      GST_INPUT_SELECTOR_UNLOCK (sel);
+      return FALSE;
+    }
+
     if (seg->format != GST_FORMAT_TIME) {
       GST_DEBUG_OBJECT (selpad,
           "Not waiting because we don't have a TIME segment");
@@ -971,6 +980,12 @@ gst_selector_pad_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
       GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)));
 
   GST_INPUT_SELECTOR_LOCK (sel);
+  if (sel->eos) {
+    GST_DEBUG_OBJECT (pad, "inputselector eos.");
+    GST_INPUT_SELECTOR_UNLOCK (sel);
+    goto eos;
+  }
+
   /* wait or check for flushing */
   if (gst_input_selector_wait (sel, selpad)) {
     GST_INPUT_SELECTOR_UNLOCK (sel);
@@ -1151,6 +1166,13 @@ flushing:
     res = GST_FLOW_FLUSHING;
     goto done;
   }
+eos:
+  {
+    GST_DEBUG_OBJECT (pad, "We are eos, discard buffer %p", buf);
+    gst_buffer_unref (buf);
+    res = GST_FLOW_EOS;
+    goto done;
+  }
 }
 
 static void gst_input_selector_dispose (GObject * object);
@@ -1309,6 +1331,7 @@ gst_input_selector_init (GstInputSelector * sel)
   g_mutex_init (&sel->lock);
   g_cond_init (&sel->cond);
   sel->blocked = FALSE;
+  sel->eos = FALSE;
 
   /* lets give a change for downstream to do something on
    * active-pad change before we start pushing new buffers */
@@ -1377,6 +1400,11 @@ gst_input_selector_set_active_pad (GstInputSelector * self, GstPad * pad)
   GST_DEBUG_OBJECT (self, "New active pad is %" GST_PTR_FORMAT,
       self->active_sinkpad);
 
+  if (old != new && new->eos && !new->eos_sent) {
+    self->eos = TRUE;
+    GST_INPUT_SELECTOR_BROADCAST (self);
+  }
+
   return TRUE;
 }
 
@@ -1771,6 +1799,7 @@ gst_input_selector_change_state (GstElement * element,
   switch (transition) {
     case GST_STATE_CHANGE_READY_TO_PAUSED:
       GST_INPUT_SELECTOR_LOCK (self);
+      self->eos = FALSE;
       self->blocked = FALSE;
       self->flushing = FALSE;
       GST_INPUT_SELECTOR_UNLOCK (self);
@@ -1779,6 +1808,7 @@ gst_input_selector_change_state (GstElement * element,
       /* first unlock before we call the parent state change function, which
        * tries to acquire the stream lock when going to ready. */
       GST_INPUT_SELECTOR_LOCK (self);
+      self->eos = TRUE;
       self->blocked = FALSE;
       self->flushing = TRUE;
       GST_INPUT_SELECTOR_BROADCAST (self);
diff --git a/plugins/elements/gstinputselector.h b/plugins/elements/gstinputselector.h
index 96c680f..9bf924f 100644
--- a/plugins/elements/gstinputselector.h
+++ b/plugins/elements/gstinputselector.h
@@ -77,6 +77,7 @@ struct _GstInputSelector {
   GMutex lock;
   GCond cond;
   gboolean blocked;
+  gboolean eos;
   gboolean flushing;
 };
 
diff --git a/tools/gst-inspect.c b/tools/gst-inspect.c
index f97eb2a..2026722 100644
--- a/tools/gst-inspect.c
+++ b/tools/gst-inspect.c
@@ -1494,7 +1494,7 @@ main (int argc, char *argv[])
   g_option_context_add_main_entries (ctx, options, GETTEXT_PACKAGE);
   g_option_context_add_group (ctx, gst_init_get_option_group ());
   if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
-    g_printerr ("Error initializing: %s\n", err->message);
+    g_printerr ("Error initializing: %s\n", err ? err->message : "(null)");
     return -1;
   }
   g_option_context_free (ctx);
-- 
2.1.4

