title: GStreamer multiple appsrc cause the application to crash
body: <p>I have a problem with GStreamer 1.0 when multiple appsrc are used in the same pipeline.
  The pipeline receives data from two different sources, and mix them into a single video using videomixer element. Pipeline is as following:</p>
  
  <pre><code> videomixer name=mix \
   appsrc name=src0 ! video/x-raw,format=RGB,width=640,height=480,framerate=60/1 ! videoconvert  ! video/x-raw,format=I420  ! videobox left=-0  ! mix.sink_0 \
   appsrc name=src1 ! video/x-raw,format=RGB,width=640,height=480,framerate=60/1 ! videoconvert  ! video/x-raw,format=I420  ! videobox left=-640  ! mix.sink_1 \
   mix.  ! videoconvert ! autovideosink sync=false
  </code></pre>
  
  <p>Each appsrc registers callback functions using: GstAppSrcCallbacks</p>
  
  <p>When I run the application, it immediately crashes after each appsrc receives two or three frames (it crashes randomly). No error being reported on the console, or in the pipeline bus message listener. I don't get any error messages at all.</p>
  
  <p>If I tried to run with a single appsrc without the mixer, it runs without any problem:</p>
  
  <pre><code>appsrc name=src0 ! video/x-raw,format=RGB,width=640,height=480,framerate=60/1 ! videoconvert  ! video/x-raw,format=I420  ! videoconvert ! autovideosink sync=false
  </code></pre>
  
  <p>GStreamer Version:1.5.2 / Windows</p>
  
  <p><strong>Edit</strong>
  Here is the code I am using to init the appsrc:</p>
  
  <pre><code>GstAppSrcCallbacks srcCB;
  GstAppSrc* videoSrc;
  videoSrc = GST_APP_SRC(gst_bin_get_by_name(GST_BIN(GetPipeline()), "src0"));
  srcCB.need_data = &amp;start_feed;
  srcCB.enough_data = &amp;stop_feed;
  srcCB.seek_data = &amp;seek_data;
  gst_app_src_set_callbacks(videoSrc, &amp;srcCB, this, NULL);
  
  
  static void start_feed(GstAppSrc *source, guint size, gpointer data)
  {
      VideoSrcData* o = static_cast&lt;VideoSrcData*&gt;(data);
      if (o-&gt;sourceID == 0) {
          GST_DEBUG("start feeding");
          o-&gt;sourceID = g_idle_add((GSourceFunc)read_data, o);
      }
  }
  
  static gboolean read_data(VideoSrcData *d)
  {
      GstFlowReturn ret;
  
      GstBuffer *buffer;
      if (NeedBuffer(0, &amp;buffer) == GST_FLOW_OK)
      {
          ret = gst_app_src_push_buffer(d-&gt;videoSrc, buffer);
          if (ret != GST_FLOW_OK){
              ret = gst_app_src_end_of_stream(d-&gt;videoSrc);
              return FALSE;
          }
      }
      return TRUE;
  
  }
  
  GstFlowReturn NeedBuffer(GstMySrc * sink, GstBuffer ** buffer)
  {
      if (!m_grabber-&gt;GrabFrame()) //ask video grabber to prepare image frame
      {
          return GST_FLOW_ERROR;
      }
      m_grabber-&gt;Lock();
  
      //Get Image frame
      const video::ImageInfo* ifo = m_grabber-&gt;GetLastFrame();
      int len = ifo-&gt;imageDataSize;
      GstMapInfo map;
      GstBuffer* outbuf = gst_buffer_new_and_alloc(len);
      gst_buffer_map(outbuf, &amp;map, GST_MAP_WRITE);
      memcpy(map.data, ifo-&gt;imageData, len);
      gst_buffer_unmap(outbuf, &amp;map);
      m_grabber-&gt;Unlock();
      *buffer = outbuf;
      return GST_FLOW_OK;
  }
  </code></pre>
  
  <p>I confirmed that data size and format is matching the requested one in the pipeline caps</p>
  
  <p><strong>Update 1:</strong></p>
  
  <p>After several trials, it seems even when one appsrc is used in a videomixer, the application would crash. Example pipeline:</p>
  
  <pre><code> videomixer name=mix \
   appsrc name=src0 ! video/x-raw,format=RGB,width=640,height=480,framerate=60/1 ! videoconvert  ! video/x-raw,format=I420  ! videobox left=-0  ! mix.sink_0 \
   videotestsrc ! video/x-raw,format=RGB,width=640,height=480,framerate=60/1 ! videoconvert  ! video/x-raw,format=I420  ! videobox left=-640  ! mix.sink_1 \
   mix.  ! videoconvert ! autovideosink sync=false
  </code></pre>