From: Christian Pointner Date: Thu, 30 Jun 2011 23:48:05 +0000 (+0000) Subject: added GIOChannel for stdin X-Git-Url: https://git.realraum.at/?a=commitdiff_plain;h=7508e808843082970a2274a6b78d028806dfaf37;p=svn42.git added GIOChannel for stdin --- diff --git a/dart-sounds/src/dart-sounds.c b/dart-sounds/src/dart-sounds.c index 075ca75..6d11df8 100644 --- a/dart-sounds/src/dart-sounds.c +++ b/dart-sounds/src/dart-sounds.c @@ -32,7 +32,7 @@ static gboolean bus_call(GstBus *bus, GstMessage *msg, gpointer data) { case GST_MESSAGE_EOS: g_print("End of stream\n"); - g_main_loop_quit(loop); +// g_main_loop_quit(loop); break; case GST_MESSAGE_ERROR: { @@ -75,7 +75,7 @@ GstElement* init(GMainLoop *loop, int pipe_out) GstElement *sink = gst_element_factory_make("autoaudiosink", "sink"); if (!pipeline || !source || !demuxer || !decoder || !conv || !sink) { - g_printerr ("One element could not be created. Exiting.\n"); + g_printerr("One element could not be created. Exiting.\n"); return NULL; } @@ -96,6 +96,13 @@ GstElement* init(GMainLoop *loop, int pipe_out) return pipeline; } +static void stdin_read(gpointer data) +{ + u_int8_t buf[100]; + int len = read(0, buf, sizeof(buf)); + g_print("read %d bytes from stdin\n", len); +} + int main(int argc, char *argv[]) { gst_init(&argc, &argv); @@ -107,6 +114,17 @@ int main(int argc, char *argv[]) GMainContext *ctx = g_main_loop_get_context(loop); + GIOChannel* chan = g_io_channel_unix_new(0); + if(!chan) { + g_printerr("IO Channel could not be created.\n"); + return 1; + } + + GSource* src = g_io_create_watch(chan, G_IO_IN); + + g_source_set_callback(src, (GSourceFunc)stdin_read, (gpointer)pipeline, NULL); + g_source_attach(src, ctx); + g_print("Running...\n"); g_main_loop_run(loop);