[gst-devel] Problem with a threading test app...

Brett Kosinski brettk at frodo.dyn.gno.org
Fri May 30 10:15:08 CEST 2003

Don't ask why I'm doing things this way, I have my reasons :), but for
some reason, the following test program isn't doing what I expect.  It
seems like the second thread isn't pulling any data off the queue.  The
first statistics element generates output, indicating that the decoder is
working and data is being pushed onto the queue, but nothing is generated
at the second statistics node, hence my suspicion that, for some reason,
the second thread isn't pulling the data.  Any thoughts?

#include <stdlib.h>
#include <gst/gst.h>

void eos(GstElement *element, gpointer data)
  g_print("have eos, quitting\n");


void update(GstElement *element, gpointer data)
  g_print("Stats update...\n");

int main (int argc, char *argv[])
  GstElement *thread1, *thread2;
  GstElement *filesrc, *decoder, *queue, *sink;
  GstElement *stats1, *stats2;

  gst_init (&argc, &argv);

  thread1 = gst_thread_new("thread1");
  thread2 = gst_thread_new("thread2");

  filesrc = gst_element_factory_make("filesrc", "input");
  g_object_set(G_OBJECT(filesrc), "location", argv[1], NULL);

  decoder = gst_element_factory_make("vorbisfile", "decoder");

  queue = gst_element_factory_make("queue", "queue");

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

  stats1 = gst_element_factory_make("statistics", "stats1");
  stats2 = gst_element_factory_make("statistics", "stats2");

  g_object_set(G_OBJECT(stats1), "buffer_update_freq", 5, NULL);
  g_object_set(G_OBJECT(stats2), "buffer_update_freq", 5, NULL);

  gst_bin_add_many(GST_BIN(thread1), filesrc, decoder, stats1, queue, NULL);
  gst_bin_add_many(GST_BIN(thread2), stats2, sink, NULL);

  gst_element_link_many(filesrc, decoder, stats1, queue, stats2, sink, NULL);

  g_signal_connect(G_OBJECT(filesrc), "eos", G_CALLBACK(eos), NULL);

  g_signal_connect(G_OBJECT(stats1), "update", G_CALLBACK(update), NULL);
  g_signal_connect(G_OBJECT(stats2), "update", G_CALLBACK(update), NULL);

  gst_element_set_state(thread1, GST_STATE_READY);
  gst_element_set_state(thread2, GST_STATE_READY);

  gst_element_set_state(thread1, GST_STATE_PLAYING);
  gst_element_set_state(thread2, GST_STATE_PLAYING);


  return 0;

More information about the gstreamer-devel mailing list