[gst-devel] clutter_behaviour breaks gnonlinear gstreamer plugin, can anybody confirm this?

Aapo Rantalainen aapo.rantalainen at gmail.com
Fri Nov 13 14:20:37 CET 2009


Hi, I have problem with clutter1.0.6 behaviours and
gstreamer-gnonlinear-plugin. I think I'm using gnonlinear proper way
(Who can confirm this?), because it works.

If I add clutter and clutter_actor it still works. When I add
clutter_behaviour, application doesn't work anymore.

Application:
I'm playing two different length wav-clip starting on same time.

Expected:
Shorter ends and another continues playing.

What happens:
When shorter ends, there are silence moment (cap). Sometimes it is
short, sometimes long, and sometimes there are many caps.


If I'm using alsasink, there are no message, with pulsesink I got this:
pulse pulsesink.c:523:gst_pulsering_stream_underflow_cb:<sink-actual-sink-pulse>
Got underflow
(This message comes even when it works.)

And as I said application works if I disable all clutter_behaviours.
Therefor I first thought it was fault of clutter, but after rethinking
I decided post it to here too.
Any advice is welcome. (Do this happens to you? Is this clutter's
fault? Is this gstreamer's fault? Is this gnonlinear's fault?)

I made simple application which triggers this bug and it is easy to
reproduce, you can download it from here (1.6M):
http://cc.oulu.fi/~rantalai/clutter_gnonlin_bug.tar.gz

You need libclutter-1.0-dev and libgstreamer0.10-dev to compile it and
 gstreamer0.10-gnonlin to run it.

make
./works.sh
/trigger_bug.sh


-Aapo Rantalainen

And the application:

#include <gst/gst.h>
#include <glib.h>
#include <stdbool.h>
#include <clutter/clutter.h>


// Variables
GstElement *conv1, *conv2;
GstPad *audiopad;
GstBus *bus;
GMainLoop *loop;
GstFormat fmt;
gint64 pos, len;
GstElement *pipeline;

static gboolean my_bus_callback (GstBus *bus, GstMessage *msg, gpointer    data)
{
  switch (GST_MESSAGE_TYPE (msg)) {

    case GST_MESSAGE_EOS:
      g_print ("\nEnd of stream\n");
      break;

    case GST_MESSAGE_ERROR: {
      gchar  *debug;
      GError *error;

      gst_message_parse_error (msg, &error, &debug);
      g_free (debug);

      g_printerr ("Error: %s\n", error->message);
      g_error_free (error);
      break;
    }
    default:
      break;
  }

  return TRUE;
}




static void gnl_OnNewPad(GstElement *elem, GstPad *pad, gpointer data)
{
  GstPad *convsink;

  convsink = gst_element_get_compatible_pad(conv1, pad, gst_pad_get_caps(pad));
  if(convsink)
    printf("Compatible pad found...\n");
  else
    printf("Compatible pad not found!\n");
  gst_pad_link(pad, convsink);
  if(GST_PAD_LINK_SUCCESSFUL(GST_PAD_LINK_OK))
    printf("Linking successfully completed\n");

  printf("Element name: %s\n", gst_element_get_name(elem));

  gst_object_unref(convsink);
}

static void gnl_OnNewPad2(GstElement *elem, GstPad *pad, gpointer data)
{
  GstPad *convsink;

  convsink = gst_element_get_compatible_pad(conv2, pad, gst_pad_get_caps(pad));
  if(convsink)
    printf("Compatible pad found...\n");
  else
    printf("Compatible pad not found!\n");
  gst_pad_link(pad, convsink);
  if(GST_PAD_LINK_SUCCESSFUL(GST_PAD_LINK_OK))
    printf("Linking successfully completed\n");

  printf("Element name: %s\n", gst_element_get_name(elem));

  gst_object_unref(convsink);
}



gint player_init (gchar *location1, gchar *location2)
{
  GstElement *dec,  *track1, *track2, *adder, *audio1, *audio1_2,
*audio2, *sink;

  gst_init (NULL, NULL);

  /* setup */
  pipeline = gst_pipeline_new ("pipeline");

  bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
  gst_bus_add_watch (bus, my_bus_callback, NULL);
  gst_object_unref (bus);

  /* track 1 */
  track1 = gst_element_factory_make("gnlcomposition", "track1");
  gst_bin_add(GST_BIN (pipeline), track1);
  g_signal_connect (track1, "pad-added", G_CALLBACK (gnl_OnNewPad), NULL);

  /* add audio file to composition / track 1 */
  audio1_2 = gst_element_factory_make("gnlfilesource", "audio1_2");
  gst_bin_add(GST_BIN (track1), audio1_2);
  g_object_set(G_OBJECT (audio1_2), "location", location1, NULL);
  g_object_set(G_OBJECT (audio1_2), "start", 2 * GST_SECOND, NULL);
  g_object_set(G_OBJECT (audio1_2), "duration", 5 * GST_SECOND, NULL);
  g_object_set(G_OBJECT (audio1_2), "media-start", 0 * GST_SECOND, NULL);
  g_object_set(G_OBJECT (audio1_2), "media-duration", 30 * GST_SECOND, NULL);
  g_object_set(G_OBJECT (audio1_2), "priority", 0, NULL);


  /* track 2 */
  track2 = gst_element_factory_make("gnlcomposition", "track2");
  gst_bin_add(GST_BIN (pipeline), track2);
  g_signal_connect (track2, "pad-added", G_CALLBACK (gnl_OnNewPad2), NULL);

  /* add audio file to composition / track 2 */
  audio2 = gst_element_factory_make("gnlfilesource", "audio2");
  gst_bin_add(GST_BIN (track2), audio2);
  g_object_set(G_OBJECT (audio2), "location", location2, NULL);
  g_object_set(G_OBJECT (audio2), "start", 2 * GST_SECOND, NULL);
  g_object_set(G_OBJECT (audio2), "duration", 6 * GST_SECOND, NULL);
  g_object_set(G_OBJECT (audio2), "media-start", 0 * GST_SECOND, NULL);
  g_object_set(G_OBJECT (audio2), "media-duration", 50 * GST_SECOND, NULL);
  g_object_set(G_OBJECT (audio2), "priority", 0, NULL);


  conv1 = gst_element_factory_make("audioconvert", "conv1");
  conv2 = gst_element_factory_make("audioconvert", "conv2");

  adder = gst_element_factory_make("adder", "adder");
  if(!adder)
    printf("Couldn't create adder element!");

  sink = gst_element_factory_make("autoaudiosink", "sink");

  /* add elements to pipeline */
  gst_bin_add_many(GST_BIN(pipeline), conv1, conv2, adder, sink, NULL);

  /* adder combines multiple channels (in our case tracks) to single output */
  gst_element_link(conv1, adder);
  gst_element_link(conv2, adder);
  gst_element_link(adder, sink);

  return 0;
}


int main (int argc, char *argv[])
{
  if (argc<3)
  {
  printf("Usage: give 1.wav 2.wav [trigger_bug]\n");
  printf("last parameter can be anything\n");
  exit(0);
  }


  g_thread_init(NULL);
  clutter_init (&argc, &argv);
  clutter_threads_init();

  GMainLoop *loop= g_main_loop_new (NULL, FALSE);
  ClutterActor     *stage;
  ClutterActor     *actor;
  stage = clutter_stage_get_default ();

  actor = clutter_texture_new_from_file("forest.png", NULL);
          clutter_container_add_actor(CLUTTER_CONTAINER(stage), actor);
  clutter_actor_set_position (actor, 150, 150);
  ///////////////////////////////////////////
  /* Make a timeline */
  ClutterTimeline  *timeline;
  ClutterBehaviour *behave;
  ClutterAlpha     *behaviours_alpha;

  timeline = clutter_timeline_new (2000);
  g_object_set(timeline, "loop", TRUE, NULL);

  behaviours_alpha = clutter_alpha_new_full (timeline, CLUTTER_LINEAR);
  behave = clutter_behaviour_rotate_new (behaviours_alpha, CLUTTER_X_AXIS,
                                          CLUTTER_ROTATE_CW, 0.0, 360.0);

  clutter_behaviour_apply (behave, actor);
  if (argc==4)
    clutter_timeline_start (timeline);
  ///////////////////////////////////////////
  clutter_actor_show_all(stage);

  player_init(argv[1],argv[2]);


  gst_element_set_state(pipeline, GST_STATE_PLAYING);

  //g_main_loop_run (loop);
  clutter_main();
  return 0;
}




More information about the gstreamer-devel mailing list