mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-16 19:25:18 +00:00
Some code cleanup
Original commit message from CVS: Some code cleanup Let the parent GstBin decide when to do a create_plan (bin inside a thread)
This commit is contained in:
parent
9500bd2128
commit
e8ea96d23b
11 changed files with 65 additions and 51 deletions
|
@ -1,19 +1,17 @@
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
|
|
||||||
static gboolean playing;
|
|
||||||
|
|
||||||
/* eos will be called when the src element has an end of stream */
|
/* eos will be called when the src element has an end of stream */
|
||||||
void eos(GstSrc *src)
|
void eos(GstSrc *src)
|
||||||
{
|
{
|
||||||
g_print("have eos, quitting\n");
|
g_print("have eos, quitting\n");
|
||||||
|
|
||||||
playing = FALSE;
|
gst_main_quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc,char *argv[])
|
int main(int argc,char *argv[])
|
||||||
{
|
{
|
||||||
GstElement *disksrc, *audiosink;
|
GstElement *disksrc, *audiosink;
|
||||||
GstElement *pipeline;
|
GstElement *pipeline, *thread;
|
||||||
|
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
g_print("usage: %s <filename>\n", argv[0]);
|
g_print("usage: %s <filename>\n", argv[0]);
|
||||||
|
@ -22,10 +20,15 @@ int main(int argc,char *argv[])
|
||||||
|
|
||||||
gst_init(&argc,&argv);
|
gst_init(&argc,&argv);
|
||||||
|
|
||||||
|
thread = gst_thread_new("main_thread");
|
||||||
|
g_assert(thread != NULL);
|
||||||
|
|
||||||
/* create a new bin to hold the elements */
|
/* create a new bin to hold the elements */
|
||||||
pipeline = gst_pipeline_new("pipeline");
|
pipeline = gst_pipeline_new("pipeline");
|
||||||
g_assert(pipeline != NULL);
|
g_assert(pipeline != NULL);
|
||||||
|
|
||||||
|
gst_bin_add(GST_BIN(thread), pipeline);
|
||||||
|
|
||||||
/* create a disk reader */
|
/* create a disk reader */
|
||||||
disksrc = gst_elementfactory_make("disksrc", "disk_source");
|
disksrc = gst_elementfactory_make("disksrc", "disk_source");
|
||||||
g_assert(disksrc != NULL);
|
g_assert(disksrc != NULL);
|
||||||
|
@ -47,20 +50,16 @@ int main(int argc,char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
/* make it ready */
|
/* make it ready */
|
||||||
gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_READY);
|
gst_element_set_state(GST_ELEMENT(thread), GST_STATE_READY);
|
||||||
/* start playing */
|
/* start playing */
|
||||||
gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_PLAYING);
|
gst_element_set_state(GST_ELEMENT(thread), GST_STATE_PLAYING);
|
||||||
|
|
||||||
playing = TRUE;
|
gst_main();
|
||||||
|
|
||||||
while (playing) {
|
|
||||||
gst_bin_iterate(GST_BIN(pipeline));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* stop the bin */
|
/* stop the bin */
|
||||||
gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_NULL);
|
gst_element_set_state(GST_ELEMENT(thread), GST_STATE_NULL);
|
||||||
|
|
||||||
gst_pipeline_destroy(pipeline);
|
gst_pipeline_destroy(thread);
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,8 @@ cothread_state *cothread_create(cothread_context *ctx) {
|
||||||
cothread_state *s;
|
cothread_state *s;
|
||||||
|
|
||||||
DEBUG("cothread: pthread_self() %ld\n",pthread_self());
|
DEBUG("cothread: pthread_self() %ld\n",pthread_self());
|
||||||
if (0) {
|
//if (0) {
|
||||||
//if (pthread_self() == 0) {
|
if (pthread_self() == 0) {
|
||||||
s = (cothread_state *)malloc(sizeof(int) * COTHREAD_STACKSIZE);
|
s = (cothread_state *)malloc(sizeof(int) * COTHREAD_STACKSIZE);
|
||||||
DEBUG("cothread: new stack at %p\n",s);
|
DEBUG("cothread: new stack at %p\n",s);
|
||||||
} else {
|
} else {
|
||||||
|
@ -139,7 +139,7 @@ void cothread_switch(cothread_state *thread) {
|
||||||
|
|
||||||
/* save the current stack pointer, frame pointer, and pc */
|
/* save the current stack pointer, frame pointer, and pc */
|
||||||
GET_SP(current->sp);
|
GET_SP(current->sp);
|
||||||
enter = sigsetjmp(current->jmp, 1);
|
enter = setjmp(current->jmp);
|
||||||
if (enter != 0) {
|
if (enter != 0) {
|
||||||
DEBUG("cothread: enter thread #%d %d %p<->%p (%d)\n",current->threadnum, enter,
|
DEBUG("cothread: enter thread #%d %d %p<->%p (%d)\n",current->threadnum, enter,
|
||||||
current->sp, current->top_sp, current->top_sp-current->sp);
|
current->sp, current->top_sp, current->top_sp-current->sp);
|
||||||
|
@ -155,7 +155,7 @@ void cothread_switch(cothread_state *thread) {
|
||||||
DEBUG("cothread: in thread \n");
|
DEBUG("cothread: in thread \n");
|
||||||
SET_SP(thread->sp);
|
SET_SP(thread->sp);
|
||||||
// switch to it
|
// switch to it
|
||||||
siglongjmp(thread->jmp,1);
|
longjmp(thread->jmp,1);
|
||||||
} else {
|
} else {
|
||||||
SETUP_STACK(thread->sp);
|
SETUP_STACK(thread->sp);
|
||||||
SET_SP(thread->sp);
|
SET_SP(thread->sp);
|
||||||
|
|
|
@ -31,7 +31,7 @@ struct _cothread_state {
|
||||||
int *sp;
|
int *sp;
|
||||||
int *top_sp;
|
int *top_sp;
|
||||||
int *pc;
|
int *pc;
|
||||||
sigjmp_buf jmp;
|
jmp_buf jmp;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _cothread_context {
|
struct _cothread_context {
|
||||||
|
|
|
@ -42,7 +42,7 @@ noinst_HEADERS = \
|
||||||
gsttypefind.h \
|
gsttypefind.h \
|
||||||
gstsinesrc.h
|
gstsinesrc.h
|
||||||
|
|
||||||
CFLAGS += -O2 -Wall
|
CFLAGS += -g -O2 -Wall
|
||||||
|
|
||||||
libgstelements_la_LIBADD = $(GLIB_LIBS) $(GTK_LIBS) $(GHTTP_LIBS)
|
libgstelements_la_LIBADD = $(GLIB_LIBS) $(GTK_LIBS) $(GHTTP_LIBS)
|
||||||
libgstelements_la_LDFLAGS = -version-info $(STREAMER_CURRENT):$(STREAMER_REVISION):$(STREAMER_AGE)
|
libgstelements_la_LDFLAGS = -version-info $(STREAMER_CURRENT):$(STREAMER_REVISION):$(STREAMER_AGE)
|
||||||
|
|
|
@ -167,8 +167,8 @@ static void gst_queue_chain(GstPad *pad,GstBuffer *buf) {
|
||||||
/* we have to lock the queue since we span threads */
|
/* we have to lock the queue since we span threads */
|
||||||
|
|
||||||
DEBUG("queue: try have queue lock\n");
|
DEBUG("queue: try have queue lock\n");
|
||||||
DEBUG("queue: %s adding buffer %p %ld\n", name, buf, pthread_self());
|
|
||||||
GST_LOCK(queue);
|
GST_LOCK(queue);
|
||||||
|
DEBUG("queue: %s adding buffer %p %ld\n", name, buf, pthread_self());
|
||||||
DEBUG("queue: have queue lock\n");
|
DEBUG("queue: have queue lock\n");
|
||||||
|
|
||||||
if (GST_BUFFER_FLAG_IS_SET(buf, GST_BUFFER_FLUSH)) {
|
if (GST_BUFFER_FLAG_IS_SET(buf, GST_BUFFER_FLUSH)) {
|
||||||
|
@ -202,11 +202,11 @@ static void gst_queue_chain(GstPad *pad,GstBuffer *buf) {
|
||||||
GST_UNLOCK(queue);
|
GST_UNLOCK(queue);
|
||||||
|
|
||||||
if (tosignal) {
|
if (tosignal) {
|
||||||
STATUS("%s: >\n");
|
|
||||||
g_mutex_lock(queue->emptylock);
|
g_mutex_lock(queue->emptylock);
|
||||||
|
STATUS("%s: >\n");
|
||||||
g_cond_signal(queue->emptycond);
|
g_cond_signal(queue->emptycond);
|
||||||
g_mutex_unlock(queue->emptylock);
|
|
||||||
STATUS("%s: >>\n");
|
STATUS("%s: >>\n");
|
||||||
|
g_mutex_unlock(queue->emptylock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,19 +220,19 @@ static void gst_queue_push(GstConnection *connection) {
|
||||||
name = gst_element_get_name(GST_ELEMENT(queue));
|
name = gst_element_get_name(GST_ELEMENT(queue));
|
||||||
|
|
||||||
/* have to lock for thread-safety */
|
/* have to lock for thread-safety */
|
||||||
DEBUG("queue: try have queue lock\n");
|
DEBUG("queue: %s try have queue lock\n", name);
|
||||||
GST_LOCK(queue);
|
GST_LOCK(queue);
|
||||||
DEBUG("queue: %s push %d %ld %p\n", name, queue->level_buffers, pthread_self(), queue->emptycond);
|
DEBUG("queue: %s push %d %ld %p\n", name, queue->level_buffers, pthread_self(), queue->emptycond);
|
||||||
DEBUG("queue: have queue lock\n");
|
DEBUG("queue: %s have queue lock\n", name);
|
||||||
|
|
||||||
while (!queue->level_buffers) {
|
while (!queue->level_buffers) {
|
||||||
STATUS("%s: U released lock\n");
|
STATUS("queue: %s U released lock\n");
|
||||||
GST_UNLOCK(queue);
|
GST_UNLOCK(queue);
|
||||||
g_mutex_lock(queue->emptylock);
|
g_mutex_lock(queue->emptylock);
|
||||||
g_cond_wait(queue->emptycond,queue->emptylock);
|
g_cond_wait(queue->emptycond,queue->emptylock);
|
||||||
g_mutex_unlock(queue->emptylock);
|
g_mutex_unlock(queue->emptylock);
|
||||||
GST_LOCK(queue);
|
GST_LOCK(queue);
|
||||||
STATUS("%s: U- getting lock\n");
|
STATUS("queue: %s U- getting lock\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
front = queue->queue;
|
front = queue->queue;
|
||||||
|
|
15
gst/gstbin.c
15
gst/gstbin.c
|
@ -206,7 +206,12 @@ static GstElementStateReturn gst_bin_change_state(GstElement *element) {
|
||||||
_gst_print_statename(GST_STATE_PENDING(element)));
|
_gst_print_statename(GST_STATE_PENDING(element)));
|
||||||
|
|
||||||
if (GST_STATE_PENDING(element) == GST_STATE_READY) {
|
if (GST_STATE_PENDING(element) == GST_STATE_READY) {
|
||||||
gst_bin_create_plan(bin);
|
GstObject *parent;
|
||||||
|
|
||||||
|
parent = gst_object_get_parent(GST_OBJECT(element));
|
||||||
|
|
||||||
|
if (!parent || !GST_IS_BIN(parent))
|
||||||
|
gst_bin_create_plan(bin);
|
||||||
}
|
}
|
||||||
// g_return_val_if_fail(bin->numchildren != 0, GST_STATE_FAILURE);
|
// g_return_val_if_fail(bin->numchildren != 0, GST_STATE_FAILURE);
|
||||||
|
|
||||||
|
@ -491,6 +496,7 @@ static int gst_bin_loopfunc_wrapper(int argc,char *argv[]) {
|
||||||
buf = gst_pad_pull(pad);
|
buf = gst_pad_pull(pad);
|
||||||
DEBUG("** gst_bin_loopfunc_wrapper(): calling chain function of %s:%s\n", name, gst_pad_get_name(pad));
|
DEBUG("** gst_bin_loopfunc_wrapper(): calling chain function of %s:%s\n", name, gst_pad_get_name(pad));
|
||||||
(pad->chainfunc)(pad,buf);
|
(pad->chainfunc)(pad,buf);
|
||||||
|
DEBUG("** gst_bin_loopfunc_wrapper(): calling chain function of %s:%s done\n", name, gst_pad_get_name(pad));
|
||||||
}
|
}
|
||||||
pads = g_list_next(pads);
|
pads = g_list_next(pads);
|
||||||
}
|
}
|
||||||
|
@ -589,6 +595,10 @@ static void gst_bin_create_plan_func(GstBin *bin) {
|
||||||
cothread_setfunc(element->threadstate,gst_bin_loopfunc_wrapper,
|
cothread_setfunc(element->threadstate,gst_bin_loopfunc_wrapper,
|
||||||
0,(char **)element);
|
0,(char **)element);
|
||||||
}
|
}
|
||||||
|
if (GST_IS_BIN(element)) {
|
||||||
|
gst_bin_create_plan( GST_BIN (element));
|
||||||
|
}
|
||||||
|
|
||||||
if (GST_IS_SRC(element)) {
|
if (GST_IS_SRC(element)) {
|
||||||
g_print("gstbin: adding '%s' as entry point\n",gst_element_get_name(element));
|
g_print("gstbin: adding '%s' as entry point\n",gst_element_get_name(element));
|
||||||
bin->entries = g_list_prepend(bin->entries,element);
|
bin->entries = g_list_prepend(bin->entries,element);
|
||||||
|
@ -655,6 +665,9 @@ static void gst_bin_create_plan_func(GstBin *bin) {
|
||||||
while (elements) {
|
while (elements) {
|
||||||
element = GST_ELEMENT(elements->data);
|
element = GST_ELEMENT(elements->data);
|
||||||
g_print("gstbin: found element \"%s\"\n", gst_element_get_name(element));
|
g_print("gstbin: found element \"%s\"\n", gst_element_get_name(element));
|
||||||
|
if (GST_IS_BIN(element)) {
|
||||||
|
gst_bin_create_plan( GST_BIN (element));
|
||||||
|
}
|
||||||
if (GST_IS_SRC(element)) {
|
if (GST_IS_SRC(element)) {
|
||||||
g_print("gstbin: adding '%s' as entry point\n",gst_element_get_name(element));
|
g_print("gstbin: adding '%s' as entry point\n",gst_element_get_name(element));
|
||||||
bin->entries = g_list_prepend(bin->entries,element);
|
bin->entries = g_list_prepend(bin->entries,element);
|
||||||
|
|
|
@ -178,7 +178,7 @@ GstElement *gst_thread_new(guchar *name) {
|
||||||
|
|
||||||
static GstElementStateReturn gst_thread_change_state(GstElement *element) {
|
static GstElementStateReturn gst_thread_change_state(GstElement *element) {
|
||||||
GstThread *thread;
|
GstThread *thread;
|
||||||
gboolean stateset = TRUE;
|
gboolean stateset = GST_STATE_SUCCESS;
|
||||||
gint pending;
|
gint pending;
|
||||||
|
|
||||||
g_return_val_if_fail(GST_IS_THREAD(element), FALSE);
|
g_return_val_if_fail(GST_IS_THREAD(element), FALSE);
|
||||||
|
@ -218,7 +218,7 @@ static GstElementStateReturn gst_thread_change_state(GstElement *element) {
|
||||||
gst_info("gstthread: NOT starting thread \"%s\"\n",
|
gst_info("gstthread: NOT starting thread \"%s\"\n",
|
||||||
gst_element_get_name(GST_ELEMENT(element)));
|
gst_element_get_name(GST_ELEMENT(element)));
|
||||||
}
|
}
|
||||||
return GST_STATE_SUCCESS;
|
return GST_STATE_ASYNC;
|
||||||
break;
|
break;
|
||||||
case GST_STATE_PLAYING:
|
case GST_STATE_PLAYING:
|
||||||
if (!stateset) return FALSE;
|
if (!stateset) return FALSE;
|
||||||
|
@ -253,7 +253,9 @@ static GstElementStateReturn gst_thread_change_state(GstElement *element) {
|
||||||
* The main loop of the thread. The thread will iterate
|
* The main loop of the thread. The thread will iterate
|
||||||
* while the state is GST_THREAD_STATE_SPINNING
|
* while the state is GST_THREAD_STATE_SPINNING
|
||||||
*/
|
*/
|
||||||
static void *gst_thread_main_loop(void *arg) {
|
static void *
|
||||||
|
gst_thread_main_loop (void *arg)
|
||||||
|
{
|
||||||
GstThread *thread = GST_THREAD(arg);
|
GstThread *thread = GST_THREAD(arg);
|
||||||
|
|
||||||
gst_info("gstthread: thread \"%s\" is running with PID %d\n",
|
gst_info("gstthread: thread \"%s\" is running with PID %d\n",
|
||||||
|
|
|
@ -167,6 +167,7 @@ gst_status_area_expose(GtkWidget *widget,
|
||||||
widget->allocation.width-width-20, 15, status_area->playtime);
|
widget->allocation.width-width-20, 15, status_area->playtime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ noinst_HEADERS = \
|
||||||
gsttypefind.h \
|
gsttypefind.h \
|
||||||
gstsinesrc.h
|
gstsinesrc.h
|
||||||
|
|
||||||
CFLAGS += -O2 -Wall
|
CFLAGS += -g -O2 -Wall
|
||||||
|
|
||||||
libgstelements_la_LIBADD = $(GLIB_LIBS) $(GTK_LIBS) $(GHTTP_LIBS)
|
libgstelements_la_LIBADD = $(GLIB_LIBS) $(GTK_LIBS) $(GHTTP_LIBS)
|
||||||
libgstelements_la_LDFLAGS = -version-info $(STREAMER_CURRENT):$(STREAMER_REVISION):$(STREAMER_AGE)
|
libgstelements_la_LDFLAGS = -version-info $(STREAMER_CURRENT):$(STREAMER_REVISION):$(STREAMER_AGE)
|
||||||
|
|
|
@ -167,8 +167,8 @@ static void gst_queue_chain(GstPad *pad,GstBuffer *buf) {
|
||||||
/* we have to lock the queue since we span threads */
|
/* we have to lock the queue since we span threads */
|
||||||
|
|
||||||
DEBUG("queue: try have queue lock\n");
|
DEBUG("queue: try have queue lock\n");
|
||||||
DEBUG("queue: %s adding buffer %p %ld\n", name, buf, pthread_self());
|
|
||||||
GST_LOCK(queue);
|
GST_LOCK(queue);
|
||||||
|
DEBUG("queue: %s adding buffer %p %ld\n", name, buf, pthread_self());
|
||||||
DEBUG("queue: have queue lock\n");
|
DEBUG("queue: have queue lock\n");
|
||||||
|
|
||||||
if (GST_BUFFER_FLAG_IS_SET(buf, GST_BUFFER_FLUSH)) {
|
if (GST_BUFFER_FLAG_IS_SET(buf, GST_BUFFER_FLUSH)) {
|
||||||
|
@ -202,11 +202,11 @@ static void gst_queue_chain(GstPad *pad,GstBuffer *buf) {
|
||||||
GST_UNLOCK(queue);
|
GST_UNLOCK(queue);
|
||||||
|
|
||||||
if (tosignal) {
|
if (tosignal) {
|
||||||
STATUS("%s: >\n");
|
|
||||||
g_mutex_lock(queue->emptylock);
|
g_mutex_lock(queue->emptylock);
|
||||||
|
STATUS("%s: >\n");
|
||||||
g_cond_signal(queue->emptycond);
|
g_cond_signal(queue->emptycond);
|
||||||
g_mutex_unlock(queue->emptylock);
|
|
||||||
STATUS("%s: >>\n");
|
STATUS("%s: >>\n");
|
||||||
|
g_mutex_unlock(queue->emptylock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,19 +220,19 @@ static void gst_queue_push(GstConnection *connection) {
|
||||||
name = gst_element_get_name(GST_ELEMENT(queue));
|
name = gst_element_get_name(GST_ELEMENT(queue));
|
||||||
|
|
||||||
/* have to lock for thread-safety */
|
/* have to lock for thread-safety */
|
||||||
DEBUG("queue: try have queue lock\n");
|
DEBUG("queue: %s try have queue lock\n", name);
|
||||||
GST_LOCK(queue);
|
GST_LOCK(queue);
|
||||||
DEBUG("queue: %s push %d %ld %p\n", name, queue->level_buffers, pthread_self(), queue->emptycond);
|
DEBUG("queue: %s push %d %ld %p\n", name, queue->level_buffers, pthread_self(), queue->emptycond);
|
||||||
DEBUG("queue: have queue lock\n");
|
DEBUG("queue: %s have queue lock\n", name);
|
||||||
|
|
||||||
while (!queue->level_buffers) {
|
while (!queue->level_buffers) {
|
||||||
STATUS("%s: U released lock\n");
|
STATUS("queue: %s U released lock\n");
|
||||||
GST_UNLOCK(queue);
|
GST_UNLOCK(queue);
|
||||||
g_mutex_lock(queue->emptylock);
|
g_mutex_lock(queue->emptylock);
|
||||||
g_cond_wait(queue->emptycond,queue->emptylock);
|
g_cond_wait(queue->emptycond,queue->emptylock);
|
||||||
g_mutex_unlock(queue->emptylock);
|
g_mutex_unlock(queue->emptylock);
|
||||||
GST_LOCK(queue);
|
GST_LOCK(queue);
|
||||||
STATUS("%s: U- getting lock\n");
|
STATUS("queue: %s U- getting lock\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
front = queue->queue;
|
front = queue->queue;
|
||||||
|
|
|
@ -1,19 +1,17 @@
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
|
|
||||||
static gboolean playing;
|
|
||||||
|
|
||||||
/* eos will be called when the src element has an end of stream */
|
/* eos will be called when the src element has an end of stream */
|
||||||
void eos(GstSrc *src)
|
void eos(GstSrc *src)
|
||||||
{
|
{
|
||||||
g_print("have eos, quitting\n");
|
g_print("have eos, quitting\n");
|
||||||
|
|
||||||
playing = FALSE;
|
gst_main_quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc,char *argv[])
|
int main(int argc,char *argv[])
|
||||||
{
|
{
|
||||||
GstElement *disksrc, *audiosink;
|
GstElement *disksrc, *audiosink;
|
||||||
GstElement *pipeline;
|
GstElement *pipeline, *thread;
|
||||||
|
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
g_print("usage: %s <filename>\n", argv[0]);
|
g_print("usage: %s <filename>\n", argv[0]);
|
||||||
|
@ -22,10 +20,15 @@ int main(int argc,char *argv[])
|
||||||
|
|
||||||
gst_init(&argc,&argv);
|
gst_init(&argc,&argv);
|
||||||
|
|
||||||
|
thread = gst_thread_new("main_thread");
|
||||||
|
g_assert(thread != NULL);
|
||||||
|
|
||||||
/* create a new bin to hold the elements */
|
/* create a new bin to hold the elements */
|
||||||
pipeline = gst_pipeline_new("pipeline");
|
pipeline = gst_pipeline_new("pipeline");
|
||||||
g_assert(pipeline != NULL);
|
g_assert(pipeline != NULL);
|
||||||
|
|
||||||
|
gst_bin_add(GST_BIN(thread), pipeline);
|
||||||
|
|
||||||
/* create a disk reader */
|
/* create a disk reader */
|
||||||
disksrc = gst_elementfactory_make("disksrc", "disk_source");
|
disksrc = gst_elementfactory_make("disksrc", "disk_source");
|
||||||
g_assert(disksrc != NULL);
|
g_assert(disksrc != NULL);
|
||||||
|
@ -47,20 +50,16 @@ int main(int argc,char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
/* make it ready */
|
/* make it ready */
|
||||||
gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_READY);
|
gst_element_set_state(GST_ELEMENT(thread), GST_STATE_READY);
|
||||||
/* start playing */
|
/* start playing */
|
||||||
gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_PLAYING);
|
gst_element_set_state(GST_ELEMENT(thread), GST_STATE_PLAYING);
|
||||||
|
|
||||||
playing = TRUE;
|
gst_main();
|
||||||
|
|
||||||
while (playing) {
|
|
||||||
gst_bin_iterate(GST_BIN(pipeline));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* stop the bin */
|
/* stop the bin */
|
||||||
gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_NULL);
|
gst_element_set_state(GST_ELEMENT(thread), GST_STATE_NULL);
|
||||||
|
|
||||||
gst_pipeline_destroy(pipeline);
|
gst_pipeline_destroy(thread);
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue