-GstElement* init(GMainLoop *loop, gint* sval, GCond* cond, GMutex* mutex, GstElement** source)
+struct play_file_param
+{
+ GstElement *pipeline;
+ GstElement *source;
+ gint* sval;
+ GCond* cond;
+ GMutex* mutex;
+ GAsyncQueue* queue;
+};
+
+static gpointer player(gpointer data)
+{
+ struct play_file_param *p = (struct play_file_param*)data;
+ GstElement* pipeline = p->pipeline;
+ GstElement* source = p->source;
+ gint* sval = p->sval;
+ GCond* cond = p->cond;
+ GMutex* mutex = p->mutex;
+ GAsyncQueue* queue = p->queue;
+ free(p);
+
+ g_printf("Player thread started\n");
+
+ for(;;) {
+ g_mutex_lock(mutex);
+ while((*sval) < 1)
+ g_cond_wait(cond, mutex);
+ *sval = 0;
+ g_mutex_unlock(mutex);
+
+ char* name = (char*)g_async_queue_pop(queue);
+ if(!name)
+ return NULL;
+
+ gst_element_set_state(pipeline, GST_STATE_READY);
+
+ g_print("playing '../media/%s.ogg'\n", name);
+ char* path;
+ asprintf(&path, "../media/%s.ogg", name);
+ free(name);
+ if(!path)
+ return NULL;
+
+ g_object_set(G_OBJECT(source), "location", path, NULL);
+ free(path);
+ gst_element_set_state(pipeline, GST_STATE_PLAYING);
+ }
+
+ return NULL;
+}
+
+GstElement* init_pipeline(GMainLoop *loop, GAsyncQueue* queue, gint* sval)