summaryrefslogtreecommitdiff
path: root/src/writer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/writer.c')
-rw-r--r--src/writer.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/writer.c b/src/writer.c
index 1355125..192dea9 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -2,10 +2,10 @@
* rharchive
*
* The Radio Helsinki Archive Daemon
- *
*
- * Copyright (C) 2010-2011 Christian Pointner <equinox@helsinki.at>
- *
+ *
+ * Copyright (C) 2010-2014 Christian Pointner <equinox@helsinki.at>
+ *
* This file is part of rharchive.
*
* rharchive is free software: you can redistribute it and/or modify
@@ -43,10 +43,10 @@ static int init_time_boundaries(writer_t* writer)
struct timespec now;
clock_gettime(CLOCK_REALTIME, &now);
-
+
struct tm bd_time;
localtime_r(&(now.tv_sec), &bd_time);
-
+
writer->current_ = file_list_add(&(writer->files_), &bd_time, "current", writer->name_format_, writer->output_dir_, writer->mode_);
if(writer->current_ == NULL) return -2;
@@ -75,14 +75,14 @@ static void added_cb(GstElement* sink, gint fd, gpointer data)
static void removed_cb(GstElement* sink, gint fd, gpointer data)
{
gint num_fds;
- g_object_get(G_OBJECT(sink), "num_fds", &num_fds, NULL);
+ g_object_get(G_OBJECT(sink), "num_fds", &num_fds, NULL);
log_printf(INFO, "fdsink: successfully removed client %d (sink has now %d fds)", fd, num_fds);
}
static void fdremoved_cb(GstElement* sink, gint fd, gpointer data)
{
gint num_fds;
- g_object_get(G_OBJECT(sink), "num_fds", &num_fds, NULL);
+ g_object_get(G_OBJECT(sink), "num_fds", &num_fds, NULL);
log_printf(INFO, "fdsink: successfully removed fd %d (sink has now %d fds)", fd, num_fds);
writer_t *writer = (writer_t*)data;
@@ -144,18 +144,18 @@ static int check_boundaries(writer_t* writer)
{
struct timespec now;
clock_gettime(CLOCK_REALTIME, &now);
-
- GstClockTime tmp = GST_TIMESPEC_TO_TIME(now);
+
+ GstClockTime tmp = GST_TIMESPEC_TO_TIME(now);
GstClockTime boundary = GST_TIMESPEC_TO_TIME(writer->next_boundary_);
tmp -= writer->offset_;
if(tmp >= boundary) {
struct tm now_bd;
localtime_r(&(now.tv_sec), &now_bd);
log_printf(INFO, "boundary reached! it's now: %02d:%02d:%02d.%06d on %d.%d.%d%s (%d ms offset)", now_bd.tm_hour, now_bd.tm_min, now_bd.tm_sec, now.tv_nsec/1000, now_bd.tm_mday, now_bd.tm_mon+1, now_bd.tm_year+1900, now_bd.tm_isdst > 0 ? " (DST)": "", GST_TIME_AS_MSECONDS(writer->offset_));
-
+
int ret = open_file(writer->next_);
if(ret) return ret; // TODO: stop writer on open_file error ???
-
+
add_fd(writer, writer->next_->fd_);
remove_fd(writer, writer->current_->fd_);
writer->current_ = writer->next_;
@@ -163,19 +163,19 @@ static int check_boundaries(writer_t* writer)
writer->next_boundary_.tv_sec += 3600;
struct tm bd_time;
localtime_r(&(writer->next_boundary_.tv_sec), &bd_time);
-
+
writer->next_ = file_list_add(&(writer->files_), &bd_time, "next", writer->name_format_, writer->output_dir_, writer->mode_);
if(writer->next_ == NULL) return -2;
}
return 0;
}
-
+
static gpointer writer_thread_func(gpointer data)
{
writer_t *writer = (writer_t*)data;
log_printf(NOTICE, "writer thread started");
-
+
for(;;) {
GstClockReturn wret = gst_clock_id_wait(writer->clock_id_, NULL);
if(GST_CLOCK_UNSCHEDULED == wret)
@@ -189,7 +189,7 @@ static gpointer writer_thread_func(gpointer data)
ret = file_list_waitpid(&(writer->files_));
if(ret) break;
}
-
+
log_printf(NOTICE, "writer thread stopped");
g_main_loop_quit(writer->loop_);
return NULL;