gstreamer pipeline creation fails - in case of concurrent initialization

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

gstreamer pipeline creation fails - in case of concurrent initialization

pawan.ec
Hi All,

i am trying to initialize two gst pipeline concurrently
1. to play the webm files
2. to play the png images

When i am trying to create the pipeline, one of them start the process of init (like does gst_init_check(), and then proceed with pipeline creation) at the same time other comes for init and it fails.
while other continue to initialize and properly created.


so use case is:
1. webm pipeline creation started in thread1 and it is in middle of init
2. png pipeline ini started in thread2, and element creation started failing here
3. webm continued and success here, while png pipeline failed.

and idea guys
Reply | Threaded
Open this post in threaded view
|

Re: gstreamer pipeline creation fails - in case of concurrent initialization

pawan.ec
just to inform.
if i delay one thread by introducing sleep(). then both works fine
Reply | Threaded
Open this post in threaded view
|

Re: gstreamer pipeline creation fails - in case of concurrent initialization

pawan.ec
In reply to this post by pawan.ec
code which i am using:
below function runs in two different thread in two different object. ANd on the basis of the component type we decide that which pipeline to create.


Ias::IasResult initGst()
{

        setenv("GST_REGISTRY_UPDATE", "no", 1);
        setenv("GST_REGISTRY", "/opt/jlr/share/ngi_early_app/registry.i686.bin", 1);

 
  GstElement *appsink = NULL;
  GstElement *demux   = NULL;

 
  if (mComponentType == eVideo)
  {
    g_set_application_name ("early splash video");
  }
  else if(mComponentType == eImage)
  {
          g_set_application_name ("early Image upper");
  }
  else if (mComponentType == eImageLowerScreen)
  {
          g_set_application_name ("early Image lower");
  }

  if (IAS_SUCCEEDED(res))
  {

    GError *err;
    gboolean const ret = gst_init_check(NULL, NULL, &err);
    if (!ret)
    {
return ;
    }
  }

  if (IAS_SUCCEEDED(res))
  {
          if(mComponentType == eVideo)
          {
                  /* Pipeline is as follows:
                   *                           /---> queue ---> vp8dec    ---> appsink    // videopart
                   * filesrc --> matrioskademux
                   *                           \---> queue ---> vorbisdec ---> audioconvert ---> audioresample ---> autoaudiosink
                   *
                   *                          For now, the audio link will be not be supported
                   *
                   */
                  mPipeline = gst_pipeline_new ("splash-video");
                  GstElement *filesrc  = gst_element_factory_make("filesrc", "videosrc");
                  if (!filesrc)
                  {
                          EAPP_LOG_STRING(DLT_LOG_ERROR, "[STC:EAPP] NGIEarlyAppGStreamerWrapper::initGst() Unable to create filesrc");
                  }
                  demux = gst_element_factory_make("matroskademux", "demux");
                  if (!demux)
                  {
                          EAPP_LOG_STRING(DLT_LOG_ERROR, "[STC:EAPP] NGIEarlyAppGStreamerWrapper::initGst() Unable to create matroskademux");
                  }
                  pipelineData.mVideoQueue = gst_element_factory_make("queue", "videoqueue");
                  if (!pipelineData.mVideoQueue)
                  {
                          EAPP_LOG_STRING(DLT_LOG_ERROR, "[STC:EAPP] NGIEarlyAppGStreamerWrapper::initGst() Unable to create videoqueue");
                  }
                  GstElement *vp8dec = gst_element_factory_make("vp8dec", "vp8dec");
                  if (!vp8dec)
                  {
                          EAPP_LOG_STRING(DLT_LOG_ERROR, "[STC:EAPP] NGIEarlyAppGStreamerWrapper::initGst() Unable to create vp8dec");
                  }
                  appsink = gst_element_factory_make("appsink", "appsink");
                  if (!appsink)
                  {
                          EAPP_LOG_STRING(DLT_LOG_ERROR, "[STC:EAPP] NGIEarlyAppGStreamerWrapper::initGst() Unable to create appsink");
                  }
                  g_object_set(filesrc, "location", mFileSrcName.c_str(), NULL);
                  gst_bin_add_many (GST_BIN(mPipeline), filesrc, demux, pipelineData.mVideoQueue, vp8dec, appsink, NULL);

                  // link video-branch of pipeline
                  if (!gst_element_link_many (pipelineData.mVideoQueue, vp8dec, appsink, NULL))
                  {
                          EAPP_LOG_STRING(DLT_LOG_ERROR, "[STC:EAPP] NGIEarlyAppGStreamerWrapper::initGst() Cannot link video-branch");
                          gst_object_unref (GST_OBJECT (mPipeline));
                          mPipeline = NULL;
                          res = Ias::IasResult::cInitFailed;
                  }

                  // link start of pipeline, only filesrc and demux
                  if (!gst_element_link_many (filesrc, demux, NULL))
                  {
                          LOG_TIME("not able to create one of the element for video gst");
                          gst_object_unref (GST_OBJECT (mPipeline));
                          mPipeline = NULL;
                          res = Ias::IasResult::cInitFailed;
                  }
          }
          else if((mComponentType == eImage) || (mComponentType == eImageLowerScreen))
          {
                  mPipeline = gst_pipeline_new ("early_image");
                  GstElement *filesrc  = gst_element_factory_make("filesrc", "imagesrc");
                  if (!filesrc)
                  {
                          EAPP_LOG_STRING(DLT_LOG_ERROR, "[STC:EAPP] NGIEarlyAppGStreamerWrapper::initGst() Unable to create filesrc");
                  }
                  GstElement *pngdec = gst_element_factory_make("pngdec", "pngdec");
                  if (!pngdec)
                  {
                          EAPP_LOG_STRING(DLT_LOG_ERROR, "[STC:EAPP] NGIEarlyAppGStreamerWrapper::initGst() Unable to create pngdec");
                  }
                  GstElement *imagefreeze = gst_element_factory_make("imagefreeze", "imagefreeze");
                  if (!imagefreeze)
                  {
                          EAPP_LOG_STRING(DLT_LOG_ERROR, "[STC:EAPP] NGIEarlyAppGStreamerWrapper::initGst() Unable to create imagefreeze");
                  }
                  appsink = gst_element_factory_make("appsink", "appsink");
                  if (!appsink)
                  {
                          EAPP_LOG_STRING(DLT_LOG_ERROR, "[STC:EAPP] NGIEarlyAppGStreamerWrapper::initGst() Unable to create appsink");
                  }

                  g_object_set(filesrc, "location", mFileSrcName.c_str(), NULL);
                  gst_bin_add_many (GST_BIN(mPipeline), filesrc, pngdec, imagefreeze, appsink, NULL);

                  // link video-branch of pipeline
                  if (!gst_element_link_many (filesrc, pngdec, imagefreeze, appsink, NULL))
                  {
                          LOG_TIME("NGIEarlyAppGStreamerWrapper::initGst() not able to create one of the element for Image gst");
                          gst_object_unref (GST_OBJECT (mPipeline));
                          mPipeline = NULL;
                          res = Ias::IasResult::cInitFailed;
                  }
          }
          else
          {
                  LOG_TIME("NGIEarlyAppGStreamerWrapper::initGst() not my component");
          }
  }

  if (IAS_SUCCEEDED(res))
  {
        EAPP_LOG_STRING(DLT_LOG_VERBOSE, "[STC:EAPP] NGIEarlyAppGStreamerWrapper::initGst() is success");
    GstAppSinkCallbacks callbacks = { NULL, onPreroll, onNewImage, onNewImageList, { NULL } };
    gst_app_sink_set_callbacks (GST_APP_SINK(appsink), &callbacks, gpointer(mListener), NULL);

    if(mComponentType == eVideo)
    {
                /* Connect to the pad-added signal */
                g_signal_connect (demux, "pad-added", G_CALLBACK (onNewPad), &pipelineData);
    }
    mIsActive = true;
  }
  EAPP_LOG_STRING(DLT_LOG_VERBOSE, "[STC:EAPP] NGIEarlyAppGStreamerWrapper::initGst() Out");
  return res;
}

}
Reply | Threaded
Open this post in threaded view
|

Re: gstreamer pipeline creation fails - in case of concurrent initialization

Sebastian Dröge-3
In reply to this post by pawan.ec
On Fr, 2016-05-13 at 06:00 -0700, pawan.ec wrote:

> Hi All,
>
> i am trying to initialize two gst pipeline concurrently 
> 1. to play the webm files
> 2. to play the png images
>
> When i am trying to create the pipeline, one of them start the process of
> init (like does gst_init_check(), and then proceed with pipeline creation)
> at the same time other comes for init and it fails.
> while other continue to initialize and properly created.
gst_init() and gst_init_check() are not thread-safe. Only call it once
at the same time, or even better only call it once at all.

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (968 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: gstreamer pipeline creation fails - in case of concurrent initialization

Tim Müller
On Sat, 2016-05-14 at 10:42 +0300, Sebastian Dröge wrote:

> gst_init() and gst_init_check() are not thread-safe. Only call it
> once at the same time, or even better only call it once at all.

It should be thread-safe these days. What version is this with?
(Still good advice to only do it once)

Cheers
 -Tim

--
Tim Müller, Centricular Ltd - http://www.centricular.com


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: gstreamer pipeline creation fails - in case of concurrent initialization

pawan.ec

Its 0.10. Pretty old.

On May 14, 2016 1:29 PM, "Tim Müller" <[hidden email]> wrote:
On Sat, 2016-05-14 at 10:42 +0300, Sebastian Dröge wrote:

> gst_init() and gst_init_check() are not thread-safe. Only call it
> once at the same time, or even better only call it once at all.

It should be thread-safe these days. What version is this with?
(Still good advice to only do it once)

Cheers
 -Tim

--
Tim Müller, Centricular Ltd - http://www.centricular.com


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: gstreamer pipeline creation fails - in case of concurrent initialization

pawan.ec

Is there any way yo find out if initgstcheck is already called?

On May 14, 2016 2:21 PM, "pawan gupta" <[hidden email]> wrote:

Its 0.10. Pretty old.

On May 14, 2016 1:29 PM, "Tim Müller" <[hidden email]> wrote:
On Sat, 2016-05-14 at 10:42 +0300, Sebastian Dröge wrote:

> gst_init() and gst_init_check() are not thread-safe. Only call it
> once at the same time, or even better only call it once at all.

It should be thread-safe these days. What version is this with?
(Still good advice to only do it once)

Cheers
 -Tim

--
Tim Müller, Centricular Ltd - http://www.centricular.com


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: gstreamer pipeline creation fails - in case of concurrent initialization

Sebastian Dröge-3
On So, 2016-05-15 at 15:39 +0530, pawan gupta wrote:
> Is there any way yo find out if initgstcheck is already called?
> On May 14, 2016 2:21 PM, "pawan gupta" <[hidden email]> wrote:
> > Its 0.10. Pretty old.

In 0.10 it was not threadsafe and you need to add locking anyway, so
just remember if you called it before or not.

Also you should really upgrade to 1.x, 0.10 is no longer maintained
since more than 3 years.

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (968 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: gstreamer pipeline creation fails - in case of concurrent initialization

pawan.ec

Thanks sebastian. Upgrading to 1.0 sounds good.

On May 15, 2016 4:05 PM, "Sebastian Dröge" <[hidden email]> wrote:
On So, 2016-05-15 at 15:39 +0530, pawan gupta wrote:
> Is there any way yo find out if initgstcheck is already called?
> On May 14, 2016 2:21 PM, "pawan gupta" <[hidden email]> wrote:
> > Its 0.10. Pretty old.

In 0.10 it was not threadsafe and you need to add locking anyway, so
just remember if you called it before or not.

Also you should really upgrade to 1.x, 0.10 is no longer maintained
since more than 3 years.

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel