summaryrefslogtreecommitdiff
path: root/src/writer.c
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2011-04-16 13:44:39 (GMT)
committerChristian Pointner <equinox@helsinki.at>2011-04-16 13:44:39 (GMT)
commit1203b5f7c95b5a90d4d8c04121e4ea65f713e946 (patch)
tree0b48e980256df2b27cad3a68bc6f555816cba569 /src/writer.c
parent5e183ae4ee1871b16689ef7d374474a71823ffb8 (diff)
file modes can now be configured
Diffstat (limited to 'src/writer.c')
-rw-r--r--src/writer.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/writer.c b/src/writer.c
index 12ca9f3..d4a36ab 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -61,6 +61,7 @@ static int init_time_boundaries(writer_t* writer)
}
log_printf(INFO, "current filename is: %s(.?)", writer->current_.path_);
writer->current_.fd_ = -1;
+ writer->current_.mode_ = writer->mode_;
bd_time.tm_sec = 0;
bd_time.tm_min = 0;
@@ -80,6 +81,7 @@ static int init_time_boundaries(writer_t* writer)
}
log_printf(INFO, "next filename will be: %s(.?)", writer->next_.path_);
writer->next_.fd_ = -1;
+ writer->next_.mode_ = writer->mode_;
struct timespec b = { T, 0 };
writer->next_boundary_ = b;
@@ -87,7 +89,7 @@ static int init_time_boundaries(writer_t* writer)
return 0;
}
-int writer_init(writer_t* writer, GMainLoop *loop, const char* name_format, const char* output_dir, int interval, int offset)
+int writer_init(writer_t* writer, GMainLoop *loop, const char* name_format, mode_t mode, const char* output_dir, int interval, int offset)
{
if(!writer)
return -1;
@@ -104,13 +106,14 @@ int writer_init(writer_t* writer, GMainLoop *loop, const char* name_format, cons
return -1;
}
writer->name_format_ = name_format;
+ writer->mode_ = mode;
writer->output_dir_ = output_dir;
writer->interval_ = interval * GST_MSECOND;
writer->offset_ = offset * GST_MSECOND;
writer->current_.path_ = NULL;
writer->next_.path_ = NULL;
- writer->clock_id_ = 0; // TODO: NULL vs. 0
- writer->thread_ = 0; // TODO: NULL vs. 0
+ writer->clock_id_ = NULL;
+ writer->thread_ = NULL;
return init_time_boundaries(writer);
}
@@ -119,7 +122,7 @@ static int open_file(file_t* file)
char* orig_path = file->path_;
int cnt = 0;
do {
- file->fd_ = open(file->path_, O_WRONLY | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR | S_IRGRP); // make mode configurable
+ file->fd_ = open(file->path_, O_WRONLY | O_CREAT | O_EXCL, file->mode_);
if(file->fd_ < 0) {
if(errno != EEXIST) {
// TODO: thread safe strerror
@@ -141,6 +144,7 @@ static int open_file(file_t* file)
free(file->path_);
file->path_ = tmp;
}
+ fchmod(file->fd_, file->mode_);
}
while(file->fd_ < 0);
@@ -184,6 +188,10 @@ int writer_start(writer_t* writer)
return ret;
writer->clock_id_ = gst_clock_new_periodic_id(writer->clock_, 0, writer->interval_);
+ if(!writer->clock_id_) {
+ log_printf(ERROR, "clock id could not be created");
+ return -1;
+ }
writer->thread_ = g_thread_create(writer_thread_func, writer, TRUE, NULL);
if(!writer->thread_) {
log_printf(ERROR, "writer thread could not be started");