[Bug 760873] GstGLVideoMixerPad vertex_buffer leaks when pad dynamic removed

GStreamer (GNOME Bugzilla) bugzilla at gnome.org
Wed Mar 23 03:38:10 UTC 2016


https://bugzilla.gnome.org/show_bug.cgi?id=760873

--- Comment #11 from comicfans44 <comicfans44 at gmail.com> ---
(In reply to Matthew Waters (ystreet00) from comment #10)
> Can you share an example program ?

to confirm this situation, I add finalize to GstGLVideoMixerPadClass

static void
gst_gl_video_mixer_pad_finalize (GstGLVideoMixerPad * pad)
{ 
  if (pad->vertex_buffer) {
    g_assert (FALSE); --------------> should trap here
  }
  G_OBJECT_CLASS (g_type_class_peek_parent (G_OBJECT_GET_CLASS (pad)))
      ->finalize (pad);
}


example code as following:

if you change pipeline state and call gst_element_release_request_pad
on some other thread, this bug triggered. this is why I think some lock should
be hold during test and set pad->vertex_buffer. 
gst_gl_video_mixer_callback holds GST_OBJECT_LOCK during painting,
but gst_gl_video_mixer_release_pad didn't have it
(gst_element_release_request_pad have GST_OBJECT_LOCK, but that's after
gst_gl_video_release_pad body run.)




#include <unistd.h>
#include <glib.h>
#include <gst/gst.h>
#include <gst/gstelement.h>
#include <gst/gstpad.h>
#include <gst/gstparse.h>


static GstBin *pipeline;
static GstElement *mixer;
static GstElement *prevsrc;

static void setSinkPad(GstElement* ele){

}

static
void changePipeline(){

  GstElement *next = gst_element_factory_make("videotestsrc", "to_change");

  GstClock *clock=GST_ELEMENT_CLOCK(pipeline);
  GstClockTime now=gst_clock_get_time(clock);

  gst_element_set_base_time(next,now);


  gst_element_set_state (prevsrc, GST_STATE_NULL);


  GstPad *old_request_pad=gst_pad_get_peer(
          gst_element_get_static_pad(prevsrc,"src"));


  gst_bin_remove (GST_BIN (pipeline), prevsrc);


  gst_element_release_request_pad(mixer,old_request_pad);

  gst_bin_add (GST_BIN (pipeline), next);

  GstPad* new_request_pad=gst_element_get_request_pad(mixer,"sink_%u");

  GstPad *srcPad=gst_element_get_static_pad(next,"src");

  gst_pad_link(srcPad,new_request_pad);

  g_object_set(G_OBJECT(new_request_pad),
            "xpos",400,"ypos",400,
            "width",400,"height",400,NULL);

  gst_element_set_state (next, GST_STATE_PLAYING);

  prevsrc=next;
}



static void thread_func(void *){

    while(true){

        sleep(1);

        changePipeline();

    }

}

static gboolean
start_thread(gpointer user_data)
{
    g_thread_new("test",(GThreadFunc)thread_func,NULL);

  return FALSE;
}


int
main (int argc, char **argv)
{

    gst_init(NULL,NULL);

    GMainLoop *loop=g_main_loop_new(NULL,FALSE);

    pipeline=(GstBin*)gst_parse_launch("videotestsrc name=no_change !
glvideomixer name=videomixer ! "
            "glimagesinkelement name=sink  videotestsrc name=to_change !
videomixer.",NULL);

    mixer=gst_bin_get_by_name(pipeline,"sink");

    prevsrc=gst_bin_get_by_name(pipeline,"to_change");

    GstPad
*src=gst_element_get_static_pad(gst_bin_get_by_name(pipeline,"no_change"),"src");

    GstPad *sinkPad=gst_pad_get_peer(src);


    g_object_set(G_OBJECT(sinkPad),
            "xpos",0,"ypos",0,
            "width",400,"height",400,NULL);

    mixer=gst_bin_get_by_name(pipeline,"videomixer");

    GstPad*
mixerPad1=gst_pad_get_peer(gst_element_get_static_pad(prevsrc,"src"));


    g_object_set(G_OBJECT(mixerPad1),
            "xpos",400,"ypos",400,
            "width",400,"height",400,NULL);

    g_timeout_add_seconds (5, start_thread, NULL); -->wait something already
shown

    gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PLAYING);

    g_main_loop_run(loop);


  return 0;
}

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
You are the assignee for the bug.


More information about the gstreamer-bugs mailing list