#include <gst/gst.h>
#include <glib.h>
#include <unistd.h>

void main (int argc, char *argv[])
{
  GstElement *pipeline, *source, *sink;
  GstMessage *msg;

  gst_init (&argc, &argv);

  pipeline = gst_pipeline_new ("test-pipe");
  source   = gst_element_factory_make ("pulsesrc", NULL);
  sink   = gst_element_factory_make ("fakesink", NULL);

  gst_bin_add_many (GST_BIN (pipeline), source, sink, NULL);
  gst_element_link (source, sink);

  gst_element_set_state (pipeline, GST_STATE_PLAYING);

  sleep (1);

  gst_element_send_event (source, gst_event_new_eos ());
  msg = gst_bus_timed_pop_filtered (GST_ELEMENT_BUS (pipeline), GST_SECOND, GST_MESSAGE_EOS | GST_MESSAGE_ERROR);
  gst_message_unref (msg);

  gst_element_set_state (source, GST_STATE_NULL);
  gst_element_set_state (pipeline, GST_STATE_NULL);
}
