Use the new API to post flow ERROR messages on the bus

https://bugzilla.gnome.org/show_bug.cgi?id=770158
diff --git a/ext/gme/gstgme.c b/ext/gme/gstgme.c
index 1c5c83c..4fb4429 100644
--- a/ext/gme/gstgme.c
+++ b/ext/gme/gstgme.c
@@ -353,9 +353,7 @@
     if (flow_return == GST_FLOW_EOS) {
       gst_pad_push_event (pad, gst_event_new_eos ());
     } else if (flow_return < GST_FLOW_EOS || flow_return == GST_FLOW_NOT_LINKED) {
-      GST_ELEMENT_ERROR (gme, STREAM, FAILED, ("Internal data stream error."),
-          ("stream stopped, reason %s", gst_flow_get_name (flow_return)));
-
+      GST_ELEMENT_FLOW_ERROR (gme, flow_return);
       gst_pad_push_event (pad, gst_event_new_eos ());
     }
   }
diff --git a/ext/sndfile/gstsfsink.c b/ext/sndfile/gstsfsink.c
index 78f7098..219f1a9 100644
--- a/ext/sndfile/gstsfsink.c
+++ b/ext/sndfile/gstsfsink.c
@@ -433,9 +433,7 @@
     if (result == GST_FLOW_UNEXPECTED) {
       gst_pad_send_event (pad, gst_event_new_eos ());
     } else if (result < GST_FLOW_UNEXPECTED || result == GST_FLOW_NOT_LINKED) {
-      GST_ELEMENT_ERROR (basesink, STREAM, FAILED,
-          (_("Internal data stream error.")),
-          ("stream stopped, reason %s", gst_flow_get_name (result)));
+      GST_ELEMENT_FLOW_ERROR (basesink, result);
       gst_pad_send_event (pad, gst_event_new_eos ());
     }
     gst_object_unref (this);
diff --git a/ext/teletextdec/gstteletextdec.c b/ext/teletextdec/gstteletextdec.c
index 5909a76..7f8a8a6 100644
--- a/ext/teletextdec/gstteletextdec.c
+++ b/ext/teletextdec/gstteletextdec.c
@@ -743,9 +743,7 @@
   {
     if (ret != GST_FLOW_OK && ret != GST_FLOW_NOT_LINKED
         && ret != GST_FLOW_FLUSHING) {
-      GST_ELEMENT_ERROR (teletext, STREAM, FAILED,
-          ("Internal data stream error."), ("stream stopped, reason %s",
-              gst_flow_get_name (ret)));
+      GST_ELEMENT_FLOW_ERROR (teletext, ret);
       return GST_FLOW_ERROR;
     }
     return ret;
diff --git a/ext/timidity/gsttimidity.c b/ext/timidity/gsttimidity.c
index f7af843..2078694 100644
--- a/ext/timidity/gsttimidity.c
+++ b/ext/timidity/gsttimidity.c
@@ -743,9 +743,7 @@
   }
 error:
   {
-    GST_ELEMENT_ERROR (timidity, STREAM, FAILED,
-        ("Internal data stream error"),
-        ("Streaming stopped, reason %s", gst_flow_get_name (ret)));
+    GST_ELEMENT_FLOW_ERROR (timidity, ret);
     gst_pad_push_event (timidity->srcpad, gst_event_new_eos ());
     goto paused;
   }
diff --git a/ext/timidity/gstwildmidi.c b/ext/timidity/gstwildmidi.c
index f52ea9d..7f380d6 100644
--- a/ext/timidity/gstwildmidi.c
+++ b/ext/timidity/gstwildmidi.c
@@ -898,9 +898,7 @@
       event = gst_event_new_eos ();
       /* for fatal errors we post an error message, post the error
        * first so the app knows about the error first. */
-      GST_ELEMENT_ERROR (wildmidi, STREAM, FAILED,
-          ("Internal data flow error."),
-          ("streaming task paused, reason %s (%d)", reason, ret));
+      GST_ELEMENT_FLOW_ERROR (wildmidi, ret);
       gst_pad_push_event (wildmidi->srcpad, event);
     }
   }
diff --git a/gst-libs/gst/adaptivedemux/gstadaptivedemux.c b/gst-libs/gst/adaptivedemux/gstadaptivedemux.c
index e51f6dd..c465226 100644
--- a/gst-libs/gst/adaptivedemux/gstadaptivedemux.c
+++ b/gst-libs/gst/adaptivedemux/gstadaptivedemux.c
@@ -2230,8 +2230,7 @@
     gboolean finished = FALSE;
 
     if (ret < GST_FLOW_EOS) {
-      GST_ELEMENT_ERROR (demux, STREAM, FAILED, (NULL),
-          ("stream stopped, reason %s", gst_flow_get_name (ret)));
+      GST_ELEMENT_FLOW_ERROR (demux, ret);
 
       /* TODO push this on all pads */
       gst_pad_push_event (stream->pad, gst_event_new_eos ());
@@ -3285,13 +3284,15 @@
       break;
 
     case GST_FLOW_NOT_LINKED:
+    {
+      GstFlowReturn ret;
       gst_task_stop (stream->download_task);
-      if (gst_adaptive_demux_combine_flows (demux)
-          == GST_FLOW_NOT_LINKED) {
-        GST_ELEMENT_ERROR (demux, STREAM, FAILED,
-            (_("Internal data stream error.")), ("stream stopped, reason %s",
-                gst_flow_get_name (GST_FLOW_NOT_LINKED)));
+
+      ret = gst_adaptive_demux_combine_flows (demux);
+      if (ret == GST_FLOW_NOT_LINKED) {
+        GST_ELEMENT_FLOW_ERROR (demux, ret);
       }
+    }
       break;
 
     case GST_FLOW_FLUSHING:{
diff --git a/gst/aiff/aiffparse.c b/gst/aiff/aiffparse.c
index 194857b..faa2647 100644
--- a/gst/aiff/aiffparse.c
+++ b/gst/aiff/aiffparse.c
@@ -1527,9 +1527,7 @@
     } else if (ret < GST_FLOW_EOS || ret == GST_FLOW_NOT_LINKED) {
       /* for fatal errors we post an error message, post the error
        * first so the app knows about the error first. */
-      GST_ELEMENT_ERROR (aiff, STREAM, FAILED,
-          (_("Internal data flow error.")),
-          ("streaming task paused, reason %s (%d)", reason, ret));
+      GST_ELEMENT_FLOW_ERROR (aiff, ret);
       gst_pad_push_event (aiff->srcpad, gst_event_new_eos ());
     }
     return;
diff --git a/gst/midi/midiparse.c b/gst/midi/midiparse.c
index d52539b..d58ea3f 100644
--- a/gst/midi/midiparse.c
+++ b/gst/midi/midiparse.c
@@ -1282,9 +1282,7 @@
       event = gst_event_new_eos ();
       /* for fatal errors we post an error message, post the error
        * first so the app knows about the error first. */
-      GST_ELEMENT_ERROR (midiparse, STREAM, FAILED,
-          ("Internal data flow error."),
-          ("streaming task paused, reason %s (%d)", reason, ret));
+      GST_ELEMENT_FLOW_ERROR (midiparse, ret);
       gst_pad_push_event (midiparse->srcpad, event);
     }
   }
diff --git a/gst/mpegdemux/gstmpegdemux.c b/gst/mpegdemux/gstmpegdemux.c
index 68985b2..b608db8 100644
--- a/gst/mpegdemux/gstmpegdemux.c
+++ b/gst/mpegdemux/gstmpegdemux.c
@@ -3005,9 +3005,7 @@
         }
       }
     } else if (ret == GST_FLOW_NOT_LINKED || ret < GST_FLOW_EOS) {
-      GST_ELEMENT_ERROR (demux, STREAM, FAILED,
-          ("Internal data stream error."),
-          ("stream stopped, reason %s", reason));
+      GST_ELEMENT_FLOW_ERROR (demux, ret);
       gst_ps_demux_send_event (demux, gst_event_new_eos ());
     }
 
diff --git a/gst/mpegtsdemux/mpegtsbase.c b/gst/mpegtsdemux/mpegtsbase.c
index cf69a18..e736f9b 100644
--- a/gst/mpegtsdemux/mpegtsbase.c
+++ b/gst/mpegtsdemux/mpegtsbase.c
@@ -1382,9 +1382,7 @@
             (_("Internal data stream error.")),
             ("No program activated before EOS"));
     } else if (ret == GST_FLOW_NOT_LINKED || ret < GST_FLOW_EOS) {
-      GST_ELEMENT_ERROR (base, STREAM, FAILED,
-          (_("Internal data stream error.")),
-          ("stream stopped, reason %s", reason));
+      GST_ELEMENT_FLOW_ERROR (base, ret);
       GST_MPEGTS_BASE_GET_CLASS (base)->push_event (base, gst_event_new_eos ());
     }
     gst_pad_pause_task (base->sinkpad);
diff --git a/gst/mxf/mxfdemux.c b/gst/mxf/mxfdemux.c
index ca09cc7..823b1b6 100644
--- a/gst/mxf/mxfdemux.c
+++ b/gst/mxf/mxfdemux.c
@@ -3098,9 +3098,7 @@
     } else if (flow == GST_FLOW_NOT_LINKED || flow < GST_FLOW_EOS) {
       GstEvent *e;
 
-      GST_ELEMENT_ERROR (demux, STREAM, FAILED,
-          ("Internal data stream error."),
-          ("stream stopped, reason %s", reason));
+      GST_ELEMENT_FLOW_ERROR (demux, flow);
       e = gst_event_new_eos ();
       gst_event_set_seqnum (e, demux->seqnum);
       gst_mxf_demux_push_src_event (demux, e);
diff --git a/gst/nuvdemux/gstnuvdemux.c b/gst/nuvdemux/gstnuvdemux.c
index b98d35d..88968f0 100644
--- a/gst/nuvdemux/gstnuvdemux.c
+++ b/gst/nuvdemux/gstnuvdemux.c
@@ -729,9 +729,7 @@
   if (res == GST_FLOW_UNEXPECTED) {
     gst_nuv_demux_send_eos (nuv);
   } else if (res == GST_FLOW_NOT_LINKED || res < GST_FLOW_UNEXPECTED) {
-    GST_ELEMENT_ERROR (nuv, STREAM, FAILED,
-        (_("Internal data stream error.")),
-        ("streaming stopped, reason %s", gst_flow_get_name (res)));
+    GST_ELEMENT_FLOW_ERROR (nuv, res);
 
     gst_nuv_demux_send_eos (nuv);
   }
diff --git a/gst/tta/gstttaparse.c b/gst/tta/gstttaparse.c
index 5479350..485a197 100644
--- a/gst/tta/gstttaparse.c
+++ b/gst/tta/gstttaparse.c
@@ -468,9 +468,7 @@
   if (ret == GST_FLOW_UNEXPECTED) {
     gst_pad_push_event (ttaparse->srcpad, gst_event_new_eos ());
   } else if (ret < GST_FLOW_UNEXPECTED || ret == GST_FLOW_NOT_LINKED) {
-    GST_ELEMENT_ERROR (ttaparse, STREAM, FAILED,
-        ("Internal data stream error."),
-        ("streaming stopped, reason %s", gst_flow_get_name (ret)));
+    GST_ELEMENT_FLOW_ERROR (ttaparse, ret);
     gst_pad_push_event (ttaparse->srcpad, gst_event_new_eos ());
   }
 }
diff --git a/sys/androidmedia/gstamcaudiodec.c b/sys/androidmedia/gstamcaudiodec.c
index 9a34c37..49c8c60 100644
--- a/sys/androidmedia/gstamcaudiodec.c
+++ b/sys/androidmedia/gstamcaudiodec.c
@@ -670,9 +670,7 @@
           gst_event_new_eos ());
       gst_pad_pause_task (GST_AUDIO_DECODER_SRC_PAD (self));
     } else if (flow_ret < GST_FLOW_EOS) {
-      GST_ELEMENT_ERROR (self, STREAM, FAILED,
-          ("Internal data stream error."), ("stream stopped, reason %s",
-              gst_flow_get_name (flow_ret)));
+      GST_ELEMENT_FLOW_ERROR (self, flow_ret);
       gst_pad_push_event (GST_AUDIO_DECODER_SRC_PAD (self),
           gst_event_new_eos ());
       gst_pad_pause_task (GST_AUDIO_DECODER_SRC_PAD (self));
diff --git a/sys/androidmedia/gstamcvideodec.c b/sys/androidmedia/gstamcvideodec.c
index 397b585..bd772b7 100644
--- a/sys/androidmedia/gstamcvideodec.c
+++ b/sys/androidmedia/gstamcvideodec.c
@@ -1590,9 +1590,7 @@
           gst_event_new_eos ());
       gst_pad_pause_task (GST_VIDEO_DECODER_SRC_PAD (self));
     } else if (flow_ret < GST_FLOW_EOS) {
-      GST_ELEMENT_ERROR (self, STREAM, FAILED,
-          ("Internal data stream error."), ("stream stopped, reason %s",
-              gst_flow_get_name (flow_ret)));
+      GST_ELEMENT_FLOW_ERROR (self, flow_ret);
       gst_pad_push_event (GST_VIDEO_DECODER_SRC_PAD (self),
           gst_event_new_eos ());
       gst_pad_pause_task (GST_VIDEO_DECODER_SRC_PAD (self));
diff --git a/sys/androidmedia/gstamcvideoenc.c b/sys/androidmedia/gstamcvideoenc.c
index 136df41..1742d44 100644
--- a/sys/androidmedia/gstamcvideoenc.c
+++ b/sys/androidmedia/gstamcvideoenc.c
@@ -1129,9 +1129,7 @@
           gst_event_new_eos ());
       gst_pad_pause_task (GST_VIDEO_ENCODER_SRC_PAD (self));
     } else if (flow_ret == GST_FLOW_NOT_LINKED || flow_ret < GST_FLOW_EOS) {
-      GST_ELEMENT_ERROR (self, STREAM, FAILED,
-          ("Internal data stream error."), ("stream stopped, reason %s",
-              gst_flow_get_name (flow_ret)));
+      GST_ELEMENT_FLOW_ERROR (self, flow_ret);
       gst_pad_push_event (GST_VIDEO_ENCODER_SRC_PAD (self),
           gst_event_new_eos ());
       gst_pad_pause_task (GST_VIDEO_ENCODER_SRC_PAD (self));
diff --git a/sys/applemedia/avfassetsrc.m b/sys/applemedia/avfassetsrc.m
index 388d7e1..8568281 100644
--- a/sys/applemedia/avfassetsrc.m
+++ b/sys/applemedia/avfassetsrc.m
@@ -535,8 +535,7 @@
     }
 
     if (combined_ret != GST_FLOW_OK) {
-      GST_ELEMENT_ERROR (self, STREAM, FAILED, ("Internal data stream error."),
-          ("stream stopped reason %s", gst_flow_get_name (ret)));
+      GST_ELEMENT_FLOW_ERROR (self, ret);
     }
 
     gst_pad_pause_task (pad);