GCond* cond;
GMutex* mutex;
GAsyncQueue* queue;
+ const char* media_d;
};
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");
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);
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) {
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");
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) {
}
gint sval = 1;
- GstElement *pipeline = init_pipeline(loop, queue, &sval);
+ GstElement *pipeline = init_pipeline(loop, media_d, queue, &sval);
if(!pipeline) return 1;