projects
/
svn42.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
43f6060
)
improvements (closing on error or EOF at STDIN)
author
Christian Pointner
<equinox@realraum.at>
Fri, 1 Jul 2011 03:15:56 +0000
(
03:15
+0000)
committer
Christian Pointner
<equinox@realraum.at>
Fri, 1 Jul 2011 03:15:56 +0000
(
03:15
+0000)
dart-sounds/src/dart-sounds.c
patch
|
blob
|
history
diff --git
a/dart-sounds/src/dart-sounds.c
b/dart-sounds/src/dart-sounds.c
index
d22ac51
..
58931ac
100644
(file)
--- a/
dart-sounds/src/dart-sounds.c
+++ b/
dart-sounds/src/dart-sounds.c
@@
-138,9
+138,13
@@
static gpointer play_file(gpointer data)
GMutex* mutex = p->mutex;
free(p);
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);
g_print("playing '../media/%s.ogg'\n", name);
char* path;
asprintf(&path, "../media/%s.ogg", name);
+ free(name);
if(!path)
return NULL;
if(!path)
return NULL;
@@
-179,17
+183,19
@@
static gboolean stdin_read(GIOChannel* src, GIOCondition cond, gpointer data)
g_main_loop_quit(p->loop);
}
g_main_loop_quit(p->loop);
}
+ g_print("read %d bytes from STDIN\n", len);
+
offset+=len;
if(offset > sizeof(buf)) offset = sizeof(buf);
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) {
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;
data->pipeline = p->pipeline;
data->source = p->source;
data->sval = p->sval;
@@
-201,8
+207,13
@@
static gboolean stdin_read(GIOChannel* src, GIOCondition cond, gpointer data)
if(i < offset) {
memmove(buf, &(buf[i+1]), offset - (i+1));
offset -= i+1;
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;
}
return 1;
@@
-244,7
+255,7
@@
int main(int argc, char *argv[])
p.sval = &sval;
p.cond = cond;
p.mutex = mutex;
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;
}
g_printerr("watch for IO Channel could not be added.\n");
return 1;
}