diff options
Diffstat (limited to 'src/writer.c')
-rw-r--r-- | src/writer.c | 11 |
1 files changed, 8 insertions, 3 deletions
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_); |