From 6f80905b6b976e1355b8556fc3a1dd6288701593 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sun, 20 Feb 2011 05:05:53 +0000 Subject: no app sink anymore tests with clocks diff --git a/src/configure b/src/configure index ecb9cb2..ef6e03a 100755 --- a/src/configure +++ b/src/configure @@ -91,8 +91,8 @@ if [ -n "$ERRORS" ] && [ $EBUILD_COMPAT -ne 1 ]; then exit 1 fi -CFLAGS="$CFLAGS $(pkg-config --cflags gstreamer-0.10 gstreamer-app-0.10)" -LDFLAGS="$LDFLAGS $(pkg-config --libs gstreamer-0.10 gstreamer-app-0.10)" +CFLAGS="$CFLAGS $(pkg-config --cflags gstreamer-0.10)" +LDFLAGS="$LDFLAGS $(pkg-config --libs gstreamer-0.10)" rm -f include.mk rm -f config.h diff --git a/src/rharchive.c b/src/rharchive.c index 39ee0bc..699738b 100644 --- a/src/rharchive.c +++ b/src/rharchive.c @@ -87,19 +87,19 @@ int main_loop(options_t* opt) GstBus *bus; writer_t writer; - int ret = writer_init(&writer, opt->name_format_, opt->output_dir_, opt->length_, opt->offset_); - if(ret) return ret; - loop = g_main_loop_new(NULL, FALSE); pipeline = gst_pipeline_new("rharchive"); if(!pipeline || !loop) { log_printf(ERROR, "the pipeline/loop object could not be created. Exiting."); - gst_object_unref(GST_OBJECT(writer.sink_)); return -1; } - bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline)); - gst_bus_add_watch(bus, bus_call, loop); - gst_object_unref(bus); + + int ret = writer_init(&writer, opt->name_format_, opt->output_dir_, opt->length_, opt->offset_); + if(ret) { + gst_object_unref(GST_OBJECT(pipeline)); + gst_object_unref(GST_OBJECT(loop)); + return ret; + } GError *error = NULL; source = gst_parse_bin_from_description(opt->src_bin_desc_, TRUE, &error); @@ -114,6 +114,9 @@ int main_loop(options_t* opt) gst_bin_add_many(GST_BIN(pipeline), source, writer.sink_, NULL); gst_element_link_many(source, writer.sink_, NULL); + bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline)); + gst_bus_add_watch(bus, bus_call, loop); + gst_object_unref(bus); log_printf(INFO, "Set State: Paused"); gst_element_set_state(pipeline, GST_STATE_PAUSED); diff --git a/src/writer.c b/src/writer.c index ead0168..6322a00 100644 --- a/src/writer.c +++ b/src/writer.c @@ -26,7 +26,10 @@ */ #include -#include + +#include +#include +#include #include "writer.h" @@ -38,11 +41,16 @@ int writer_init(writer_t* writer, const char* name_format, const char* output_di if(!writer) return -1; - writer->sink_ = gst_element_factory_make("appsink", "writer"); + writer->sink_ = gst_element_factory_make("fakesink", "writer"); if(!writer->sink_) { log_printf(ERROR, "the writer object could not be created. Exiting."); return -1; } + writer->clock_ = gst_system_clock_obtain(); + if(!writer->clock_) { + log_printf(ERROR, "unable to obtain the system clock"); + return -1; + } writer->name_format_ = name_format; writer->output_dir_ = output_dir; writer->length_ = length; @@ -55,16 +63,18 @@ static gpointer writer_thread_func(gpointer data) { writer_t *writer = (writer_t*)data; log_printf(NOTICE, "writer thread started"); - + GstBuffer* buf = NULL; for(;;) { - buf = gst_app_sink_pull_buffer((GstAppSink*)writer->sink_); - if(!buf) { + GstClockReturn ret = gst_clock_id_wait(writer->clock_id_, NULL); + if(GST_CLOCK_UNSCHEDULED == ret) break; - } - log_printf(DEBUG, "got buffer of size %d", buf->size); - } + if(GST_CLOCK_EARLY == ret) + continue; + log_printf(NOTICE, "just woke up"); + } + log_printf(NOTICE, "writer thread stopped"); return NULL; } @@ -74,20 +84,23 @@ int writer_start(writer_t* writer) if(!writer) return; + writer->clock_id_ = gst_clock_new_periodic_id(writer->clock_, 0, writer->length_*GST_SECOND); writer->thread_ = g_thread_create(writer_thread_func, writer, TRUE, NULL); if(!writer->thread_) { log_printf(ERROR, "writer thread could not be started"); return -1; - } + } } void writer_stop(writer_t* writer) { if(!writer) return; - + + gst_clock_id_unschedule(writer->clock_id_); if(writer->thread_) { log_printf(NOTICE, "waiting for writer thread to stop"); g_thread_join(writer->thread_); } + gst_object_unref(GST_OBJECT(writer->clock_)); } diff --git a/src/writer.h b/src/writer.h index 7ef5c26..5189f50 100644 --- a/src/writer.h +++ b/src/writer.h @@ -32,6 +32,8 @@ struct writer_struct { GstElement* sink_; + GstClock* clock_; + GstClockID clock_id_; GThread* thread_; const char* name_format_; const char* output_dir_; -- cgit v0.10.2