summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2011-04-15 15:37:58 (GMT)
committerChristian Pointner <equinox@helsinki.at>2011-04-15 15:37:58 (GMT)
commit5e183ae4ee1871b16689ef7d374474a71823ffb8 (patch)
treeb65b32803dbd210d6474dd3c3947682b2460530f
parent928303f9cc1f8daf8eb86ddcff842dfd7171f538 (diff)
writer thread stops loop at end of execution
-rw-r--r--src/rharchive.c2
-rw-r--r--src/writer.c11
-rw-r--r--src/writer.h4
3 files changed, 12 insertions, 5 deletions
diff --git a/src/rharchive.c b/src/rharchive.c
index fc5f442..03f549d 100644
--- a/src/rharchive.c
+++ b/src/rharchive.c
@@ -94,7 +94,7 @@ int main_loop(options_t* opt)
return -1;
}
- int ret = writer_init(&writer, opt->name_format_, opt->output_dir_, opt->interval_, opt->offset_);
+ int ret = writer_init(&writer, loop, opt->name_format_, opt->output_dir_, opt->interval_, opt->offset_);
if(ret) {
gst_object_unref(GST_OBJECT(pipeline));
gst_object_unref(GST_OBJECT(loop));
diff --git a/src/writer.c b/src/writer.c
index db20ec0..12ca9f3 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -60,6 +60,7 @@ static int init_time_boundaries(writer_t* writer)
return -2;
}
log_printf(INFO, "current filename is: %s(.?)", writer->current_.path_);
+ writer->current_.fd_ = -1;
bd_time.tm_sec = 0;
bd_time.tm_min = 0;
@@ -78,6 +79,7 @@ static int init_time_boundaries(writer_t* writer)
return -2;
}
log_printf(INFO, "next filename will be: %s(.?)", writer->next_.path_);
+ writer->next_.fd_ = -1;
struct timespec b = { T, 0 };
writer->next_boundary_ = b;
@@ -85,11 +87,12 @@ static int init_time_boundaries(writer_t* writer)
return 0;
}
-int writer_init(writer_t* writer, const char* name_format, const char* output_dir, int interval, int offset)
+int writer_init(writer_t* writer, GMainLoop *loop, const char* name_format, const char* output_dir, int interval, int offset)
{
if(!writer)
return -1;
+ writer->loop_ = loop;
writer->sink_ = gst_element_factory_make("fakesink", "writer");
if(!writer->sink_) {
log_printf(ERROR, "the writer object could not be created. Exiting.");
@@ -167,8 +170,8 @@ static gpointer writer_thread_func(gpointer data)
}
log_printf(NOTICE, "writer thread stopped");
- // TODO: stop pipeline!!
- return NULL;
+ g_main_loop_quit(writer->loop_);
+ return NULL;
}
int writer_start(writer_t* writer)
@@ -196,7 +199,9 @@ void writer_stop(writer_t* writer)
return;
if(writer->current_.path_) free(writer->current_.path_);
+ if(writer->current_.fd_ >= 0) close(writer->current_.fd_);
if(writer->next_.path_) free(writer->next_.path_);
+ if(writer->next_.fd_ >= 0) close(writer->next_.fd_);
if(writer->clock_id_) {
gst_clock_id_unschedule(writer->clock_id_);
diff --git a/src/writer.h b/src/writer.h
index f39b659..9e21dd3 100644
--- a/src/writer.h
+++ b/src/writer.h
@@ -29,6 +29,7 @@
#define RHARCHIVE_writer_h_INCLUDED
#include <gst/gst.h>
+#include <glib.h>
#include <time.h>
struct file_struct {
@@ -38,6 +39,7 @@ struct file_struct {
typedef struct file_struct file_t;
struct writer_struct {
+ GMainLoop *loop_;
GstElement* sink_;
GstClock* clock_;
GstClockID clock_id_;
@@ -52,7 +54,7 @@ struct writer_struct {
};
typedef struct writer_struct writer_t;
-int writer_init(writer_t* writer, const char* name_format, const char* output_dir, int interval, int offset);
+int writer_init(writer_t* writer, GMainLoop *loop, const char* name_format, const char* output_dir, int interval, int offset);
int writer_start(writer_t* writer);
void writer_stop(writer_t* writer);