From: Christian Pointner Date: Fri, 1 Jul 2011 12:26:49 +0000 (+0000) Subject: added parameter to dart-sounds X-Git-Url: https://git.realraum.at/?a=commitdiff_plain;h=fb206ac0c5fbd2c043f80cb91519e1559e7e1d08;p=svn42.git added parameter to dart-sounds --- diff --git a/dart-sounds/src/dart-sounds.c b/dart-sounds/src/dart-sounds.c index 25482a7..254dc10 100644 --- a/dart-sounds/src/dart-sounds.c +++ b/dart-sounds/src/dart-sounds.c @@ -89,6 +89,7 @@ struct play_file_param GCond* cond; GMutex* mutex; GAsyncQueue* queue; + const char* media_d; }; static gpointer player(gpointer data) @@ -100,6 +101,7 @@ static gpointer player(gpointer data) GCond* cond = p->cond; GMutex* mutex = p->mutex; GAsyncQueue* queue = p->queue; + const char* media_d = p->media_d; free(p); g_printf("Player thread started\n"); @@ -117,13 +119,13 @@ static gpointer player(gpointer data) gst_element_set_state(pipeline, GST_STATE_READY); - g_print("playing '../media/%s.ogg'\n", name); char* path; - asprintf(&path, "../media/%s.ogg", name); + asprintf(&path, "%s/%s.ogg", media_d, name); free(name); if(!path) return NULL; - + + g_print("playing '%s'\n", path); g_object_set(G_OBJECT(source), "location", path, NULL); free(path); gst_element_set_state(pipeline, GST_STATE_PLAYING); @@ -132,7 +134,7 @@ static gpointer player(gpointer data) return NULL; } -GstElement* init_pipeline(GMainLoop *loop, GAsyncQueue* queue, gint* sval) +GstElement* init_pipeline(GMainLoop *loop, const char* media_d, GAsyncQueue* queue, gint* sval) { GCond* cond = g_cond_new(); if(!cond) { @@ -183,6 +185,7 @@ GstElement* init_pipeline(GMainLoop *loop, GAsyncQueue* queue, gint* sval) datap->cond = cond; datap->mutex = mutex; datap->queue = queue; + datap->media_d = media_d; g_thread_create(player, datap, 0, NULL); } else { g_printerr("Memory Error\n"); @@ -239,7 +242,13 @@ static gboolean stdin_read(GIOChannel* src, GIOCondition cond, gpointer data) int main(int argc, char *argv[]) { - gst_init(&argc, &argv); + if(argc < 2) { + fprintf(stderr, "Please specify the path to the media directory"); + return 2; + } + char* media_d = argv[1]; + + gst_init(NULL, NULL); GMainLoop *loop = g_main_loop_new(NULL, FALSE); if(!loop) { @@ -254,7 +263,7 @@ int main(int argc, char *argv[]) } gint sval = 1; - GstElement *pipeline = init_pipeline(loop, queue, &sval); + GstElement *pipeline = init_pipeline(loop, media_d, queue, &sval); if(!pipeline) return 1;