mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 03:31:05 +00:00
Fixed a severe timestamp bug in mpeg_play.
Original commit message from CVS: Fixed a severe timestamp bug in mpeg_play. Create a new thread upon a multisrc element in autoplugging: the autoplug example now correctly sets up 5 threads for an mpeg player.
This commit is contained in:
parent
f1d8e760fb
commit
870c6045b2
8 changed files with 39 additions and 30 deletions
|
@ -11,6 +11,11 @@ void eos(GstSrc *src)
|
||||||
playing = FALSE;
|
playing = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean idle_func(gpointer data) {
|
||||||
|
gst_bin_iterate(GST_BIN(data));
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc,char *argv[])
|
int main(int argc,char *argv[])
|
||||||
{
|
{
|
||||||
GstElement *disksrc, *audiosink, *videosink;
|
GstElement *disksrc, *audiosink, *videosink;
|
||||||
|
@ -22,6 +27,7 @@ int main(int argc,char *argv[])
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_thread_init(NULL);
|
||||||
gst_init(&argc,&argv);
|
gst_init(&argc,&argv);
|
||||||
gnome_init("autoplug","0.0.1", argc,argv);
|
gnome_init("autoplug","0.0.1", argc,argv);
|
||||||
|
|
||||||
|
@ -68,12 +74,9 @@ int main(int argc,char *argv[])
|
||||||
|
|
||||||
playing = TRUE;
|
playing = TRUE;
|
||||||
|
|
||||||
while (playing) {
|
gtk_idle_add(idle_func, pipeline);
|
||||||
gst_bin_iterate(GST_BIN(pipeline));
|
|
||||||
gdk_threads_enter();
|
gst_main();
|
||||||
while (gtk_events_pending()) gtk_main_iteration();
|
|
||||||
gdk_threads_leave();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* stop the bin */
|
/* stop the bin */
|
||||||
gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_NULL);
|
gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_NULL);
|
||||||
|
|
|
@ -76,7 +76,7 @@ noinst_HEADERS = \
|
||||||
gsti386.h \
|
gsti386.h \
|
||||||
gstppc.h
|
gstppc.h
|
||||||
|
|
||||||
CFLAGS += -g -O2 -Wall
|
CFLAGS += -O2 -Wall -fomit-frame-pointer
|
||||||
|
|
||||||
libgst_la_LIBADD = $(GLIB_LIBS) $(GTK_LIBS) $(XML_LIBS)
|
libgst_la_LIBADD = $(GLIB_LIBS) $(GTK_LIBS) $(XML_LIBS)
|
||||||
libgst_la_LDFLAGS = -version-info $(STREAMER_CURRENT):$(STREAMER_REVISION):$(STREAMER_AGE)
|
libgst_la_LDFLAGS = -version-info $(STREAMER_CURRENT):$(STREAMER_REVISION):$(STREAMER_AGE)
|
||||||
|
|
|
@ -231,9 +231,7 @@ void gst_audiosink_chain(GstPad *pad,GstBuffer *buf) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//g_print("a unref\n");
|
|
||||||
gst_buffer_unref(buf);
|
gst_buffer_unref(buf);
|
||||||
//g_print("a done\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gst_audiosink_set_arg(GtkObject *object,GtkArg *arg,guint id) {
|
static void gst_audiosink_set_arg(GtkObject *object,GtkArg *arg,guint id) {
|
||||||
|
|
|
@ -113,7 +113,7 @@ static void gst_queue_init(GstQueue *queue) {
|
||||||
|
|
||||||
queue->queue = NULL;
|
queue->queue = NULL;
|
||||||
queue->level_buffers = 0;
|
queue->level_buffers = 0;
|
||||||
queue->max_buffers = 10;
|
queue->max_buffers = 20;
|
||||||
queue->level_bytes = 0;
|
queue->level_bytes = 0;
|
||||||
queue->size_buffers = 0;
|
queue->size_buffers = 0;
|
||||||
queue->size_bytes = 0;
|
queue->size_bytes = 0;
|
||||||
|
|
|
@ -238,7 +238,8 @@ static void gst_pipeline_pads_autoplug(GstElement *src, GstElement *sink) {
|
||||||
|
|
||||||
end:
|
end:
|
||||||
if (!connected) {
|
if (!connected) {
|
||||||
g_print("gstpipeline: delaying pad connections\n");
|
g_print("gstpipeline: delaying pad connections for \"%s\" to \"%s\"\n",
|
||||||
|
gst_element_get_name(src), gst_element_get_name(sink));
|
||||||
gtk_signal_connect(GTK_OBJECT(src),"new_pad",
|
gtk_signal_connect(GTK_OBJECT(src),"new_pad",
|
||||||
GTK_SIGNAL_FUNC(gst_pipeline_pads_autoplug_func), sink);
|
GTK_SIGNAL_FUNC(gst_pipeline_pads_autoplug_func), sink);
|
||||||
}
|
}
|
||||||
|
@ -306,6 +307,7 @@ gboolean gst_pipeline_autoplug(GstPipeline *pipeline) {
|
||||||
GList *src_types;
|
GList *src_types;
|
||||||
guint16 src_type = 0, sink_type = 0;
|
guint16 src_type = 0, sink_type = 0;
|
||||||
guint i, numsinks;
|
guint i, numsinks;
|
||||||
|
gboolean use_thread = FALSE, have_common = FALSE;
|
||||||
|
|
||||||
g_return_val_if_fail(pipeline != NULL, FALSE);
|
g_return_val_if_fail(pipeline != NULL, FALSE);
|
||||||
g_return_val_if_fail(GST_IS_PIPELINE(pipeline), FALSE);
|
g_return_val_if_fail(GST_IS_PIPELINE(pipeline), FALSE);
|
||||||
|
@ -387,8 +389,9 @@ gboolean gst_pipeline_autoplug(GstPipeline *pipeline) {
|
||||||
|
|
||||||
// check to other paths for mathing elements (factories)
|
// check to other paths for mathing elements (factories)
|
||||||
for (i=1; i<numsinks; i++) {
|
for (i=1; i<numsinks; i++) {
|
||||||
if (factory != (GstElementFactory *)(factories[i]->data))
|
if (factory != (GstElementFactory *)(factories[i]->data)) {
|
||||||
goto differ;
|
goto differ;
|
||||||
|
}
|
||||||
factories[i] = g_list_next(factories[i]);
|
factories[i] = g_list_next(factories[i]);
|
||||||
}
|
}
|
||||||
factory = (GstElementFactory *)(factories[0]->data);
|
factory = (GstElementFactory *)(factories[0]->data);
|
||||||
|
@ -403,6 +406,8 @@ gboolean gst_pipeline_autoplug(GstPipeline *pipeline) {
|
||||||
srcelement = element;
|
srcelement = element;
|
||||||
|
|
||||||
factories[0] = g_list_next(factories[0]);
|
factories[0] = g_list_next(factories[0]);
|
||||||
|
|
||||||
|
have_common = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
differ:
|
differ:
|
||||||
|
@ -416,6 +421,8 @@ differ:
|
||||||
|
|
||||||
sinkelement = (GstElement *)elements->data;
|
sinkelement = (GstElement *)elements->data;
|
||||||
|
|
||||||
|
use_thread = have_common;
|
||||||
|
|
||||||
while (factories[i] || sinkelement) {
|
while (factories[i] || sinkelement) {
|
||||||
// fase 4: add other elements...
|
// fase 4: add other elements...
|
||||||
|
|
||||||
|
@ -432,20 +439,24 @@ differ:
|
||||||
}
|
}
|
||||||
|
|
||||||
// this element suggests the use of a thread, so we set one up...
|
// this element suggests the use of a thread, so we set one up...
|
||||||
if (GST_ELEMENT_IS_THREAD_SUGGESTED(element)) {
|
if (GST_ELEMENT_IS_THREAD_SUGGESTED(element) || use_thread) {
|
||||||
GstElement *queue;
|
GstElement *queue;
|
||||||
GList *sinkpads;
|
GList *sinkpads;
|
||||||
GstPad *srcpad, *sinkpad;
|
GstPad *srcpad, *sinkpad;
|
||||||
|
|
||||||
|
use_thread = FALSE;
|
||||||
|
|
||||||
g_print("GstPipeline: sugest new thread for \"%s\" %08x\n", element->name, GST_FLAGS(element));
|
g_print("GstPipeline: sugest new thread for \"%s\" %08x\n", element->name, GST_FLAGS(element));
|
||||||
|
|
||||||
// create a new queue and add to the previous bin
|
// create a new queue and add to the previous bin
|
||||||
queue = gst_elementfactory_make("queue", g_strconcat("queue_", gst_element_get_name(element), NULL));
|
queue = gst_elementfactory_make("queue", g_strconcat("queue_", gst_element_get_name(element), NULL));
|
||||||
gst_bin_add(GST_BIN(pipeline), queue);
|
gst_bin_add(GST_BIN(thebin), queue);
|
||||||
|
|
||||||
// this will be the new bin for all following elements
|
// this will be the new bin for all following elements
|
||||||
thebin = gst_thread_new("thread");
|
thebin = gst_elementfactory_make("thread", g_strconcat("thread_", gst_element_get_name(element), NULL));
|
||||||
|
|
||||||
srcpad = gst_element_get_pad(queue, "src");
|
srcpad = gst_element_get_pad(queue, "src");
|
||||||
|
|
||||||
sinkpads = gst_element_get_pad_list(element);
|
sinkpads = gst_element_get_pad_list(element);
|
||||||
while (sinkpads) {
|
while (sinkpads) {
|
||||||
sinkpad = (GstPad *)sinkpads->data;
|
sinkpad = (GstPad *)sinkpads->data;
|
||||||
|
@ -456,19 +467,15 @@ differ:
|
||||||
// the queue has the types of the element it connects
|
// the queue has the types of the element it connects
|
||||||
srcpad->type = sinkpad->type;
|
srcpad->type = sinkpad->type;
|
||||||
gst_element_get_pad(queue, "sink")->type = sinkpad->type;
|
gst_element_get_pad(queue, "sink")->type = sinkpad->type;
|
||||||
gst_pad_connect(srcpad, sinkpad);
|
|
||||||
g_print("gstpipeline: autoconnect pad \"%s\" (%d) in element %s <-> ",
|
|
||||||
srcpad->name, srcpad->type, gst_element_get_name(queue));
|
|
||||||
g_print("pad \"%s\" (%d) in element %s\n", sinkpad->name,
|
|
||||||
sinkpad->type, gst_element_get_name(element));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
sinkpads = g_list_next(sinkpads);
|
sinkpads = g_list_next(sinkpads);
|
||||||
}
|
}
|
||||||
|
gst_pipeline_pads_autoplug(thesrcelement, queue);
|
||||||
|
|
||||||
gst_bin_add(GST_BIN(thebin), element);
|
gst_bin_add(GST_BIN(thebin), element);
|
||||||
gst_bin_add(GST_BIN(pipeline), thebin);
|
gst_bin_add(GST_BIN(pipeline), thebin);
|
||||||
element = queue;
|
thesrcelement = queue;
|
||||||
}
|
}
|
||||||
// no thread needed, easy case
|
// no thread needed, easy case
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -231,9 +231,7 @@ void gst_audiosink_chain(GstPad *pad,GstBuffer *buf) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//g_print("a unref\n");
|
|
||||||
gst_buffer_unref(buf);
|
gst_buffer_unref(buf);
|
||||||
//g_print("a done\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gst_audiosink_set_arg(GtkObject *object,GtkArg *arg,guint id) {
|
static void gst_audiosink_set_arg(GtkObject *object,GtkArg *arg,guint id) {
|
||||||
|
|
|
@ -113,7 +113,7 @@ static void gst_queue_init(GstQueue *queue) {
|
||||||
|
|
||||||
queue->queue = NULL;
|
queue->queue = NULL;
|
||||||
queue->level_buffers = 0;
|
queue->level_buffers = 0;
|
||||||
queue->max_buffers = 10;
|
queue->max_buffers = 20;
|
||||||
queue->level_bytes = 0;
|
queue->level_bytes = 0;
|
||||||
queue->size_buffers = 0;
|
queue->size_buffers = 0;
|
||||||
queue->size_bytes = 0;
|
queue->size_bytes = 0;
|
||||||
|
|
|
@ -11,6 +11,11 @@ void eos(GstSrc *src)
|
||||||
playing = FALSE;
|
playing = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean idle_func(gpointer data) {
|
||||||
|
gst_bin_iterate(GST_BIN(data));
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc,char *argv[])
|
int main(int argc,char *argv[])
|
||||||
{
|
{
|
||||||
GstElement *disksrc, *audiosink, *videosink;
|
GstElement *disksrc, *audiosink, *videosink;
|
||||||
|
@ -22,6 +27,7 @@ int main(int argc,char *argv[])
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_thread_init(NULL);
|
||||||
gst_init(&argc,&argv);
|
gst_init(&argc,&argv);
|
||||||
gnome_init("autoplug","0.0.1", argc,argv);
|
gnome_init("autoplug","0.0.1", argc,argv);
|
||||||
|
|
||||||
|
@ -68,12 +74,9 @@ int main(int argc,char *argv[])
|
||||||
|
|
||||||
playing = TRUE;
|
playing = TRUE;
|
||||||
|
|
||||||
while (playing) {
|
gtk_idle_add(idle_func, pipeline);
|
||||||
gst_bin_iterate(GST_BIN(pipeline));
|
|
||||||
gdk_threads_enter();
|
gst_main();
|
||||||
while (gtk_events_pending()) gtk_main_iteration();
|
|
||||||
gdk_threads_leave();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* stop the bin */
|
/* stop the bin */
|
||||||
gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_NULL);
|
gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_NULL);
|
||||||
|
|
Loading…
Reference in a new issue