GMutex* mutex = p->mutex;
free(p);
+ if(!name)
+ return NULL;
+
g_print("playing '../media/%s.ogg'\n", name);
char* path;
asprintf(&path, "../media/%s.ogg", name);
+ free(name);
if(!path)
return NULL;
g_main_loop_quit(p->loop);
}
+ g_print("read %d bytes from STDIN\n", len);
+
offset+=len;
if(offset > sizeof(buf)) offset = sizeof(buf);
- size_t i;
- for(i=0; i < offset; ++i) {
+ size_t i = 0;
+ for(;i < offset;) {
if(buf[i] == '\n') {
buf[i] = 0;
struct play_file_param* data = malloc(sizeof(struct play_file_param));
if(data) {
- data->name = buf;
+ data->name = strdup(buf);
data->pipeline = p->pipeline;
data->source = p->source;
data->sval = p->sval;
if(i < offset) {
memmove(buf, &(buf[i+1]), offset - (i+1));
offset -= i+1;
- } else offset = 0;
+ i = 0;
+ } else {
+ offset = 0;
+ break;
+ }
}
+ else i++;
}
return 1;
p.sval = &sval;
p.cond = cond;
p.mutex = mutex;
- if(!g_io_add_watch(chan, G_IO_IN, (GIOFunc)stdin_read, &p)) {
+ if(!g_io_add_watch(chan, G_IO_IN | G_IO_ERR | G_IO_HUP, (GIOFunc)stdin_read, &p)) {
g_printerr("watch for IO Channel could not be added.\n");
return 1;
}