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:
Wim Taymans 2000-10-09 20:01:17 +00:00
parent f1d8e760fb
commit 870c6045b2
8 changed files with 39 additions and 30 deletions

View file

@ -11,6 +11,11 @@ void eos(GstSrc *src)
playing = FALSE;
}
gboolean idle_func(gpointer data) {
gst_bin_iterate(GST_BIN(data));
return TRUE;
}
int main(int argc,char *argv[])
{
GstElement *disksrc, *audiosink, *videosink;
@ -22,6 +27,7 @@ int main(int argc,char *argv[])
exit(-1);
}
g_thread_init(NULL);
gst_init(&argc,&argv);
gnome_init("autoplug","0.0.1", argc,argv);
@ -68,12 +74,9 @@ int main(int argc,char *argv[])
playing = TRUE;
while (playing) {
gst_bin_iterate(GST_BIN(pipeline));
gdk_threads_enter();
while (gtk_events_pending()) gtk_main_iteration();
gdk_threads_leave();
}
gtk_idle_add(idle_func, pipeline);
gst_main();
/* stop the bin */
gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_NULL);

View file

@ -76,7 +76,7 @@ noinst_HEADERS = \
gsti386.h \
gstppc.h
CFLAGS += -g -O2 -Wall
CFLAGS += -O2 -Wall -fomit-frame-pointer
libgst_la_LIBADD = $(GLIB_LIBS) $(GTK_LIBS) $(XML_LIBS)
libgst_la_LDFLAGS = -version-info $(STREAMER_CURRENT):$(STREAMER_REVISION):$(STREAMER_AGE)

View file

@ -231,9 +231,7 @@ void gst_audiosink_chain(GstPad *pad,GstBuffer *buf) {
}
}
}
//g_print("a unref\n");
gst_buffer_unref(buf);
//g_print("a done\n");
}
static void gst_audiosink_set_arg(GtkObject *object,GtkArg *arg,guint id) {

View file

@ -113,7 +113,7 @@ static void gst_queue_init(GstQueue *queue) {
queue->queue = NULL;
queue->level_buffers = 0;
queue->max_buffers = 10;
queue->max_buffers = 20;
queue->level_bytes = 0;
queue->size_buffers = 0;
queue->size_bytes = 0;

View file

@ -238,7 +238,8 @@ static void gst_pipeline_pads_autoplug(GstElement *src, GstElement *sink) {
end:
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_FUNC(gst_pipeline_pads_autoplug_func), sink);
}
@ -306,6 +307,7 @@ gboolean gst_pipeline_autoplug(GstPipeline *pipeline) {
GList *src_types;
guint16 src_type = 0, sink_type = 0;
guint i, numsinks;
gboolean use_thread = FALSE, have_common = FALSE;
g_return_val_if_fail(pipeline != NULL, 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)
for (i=1; i<numsinks; i++) {
if (factory != (GstElementFactory *)(factories[i]->data))
if (factory != (GstElementFactory *)(factories[i]->data)) {
goto differ;
}
factories[i] = g_list_next(factories[i]);
}
factory = (GstElementFactory *)(factories[0]->data);
@ -403,6 +406,8 @@ gboolean gst_pipeline_autoplug(GstPipeline *pipeline) {
srcelement = element;
factories[0] = g_list_next(factories[0]);
have_common = TRUE;
}
differ:
@ -416,6 +421,8 @@ differ:
sinkelement = (GstElement *)elements->data;
use_thread = have_common;
while (factories[i] || sinkelement) {
// fase 4: add other elements...
@ -432,20 +439,24 @@ differ:
}
// 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;
GList *sinkpads;
GstPad *srcpad, *sinkpad;
use_thread = FALSE;
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
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
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");
sinkpads = gst_element_get_pad_list(element);
while (sinkpads) {
sinkpad = (GstPad *)sinkpads->data;
@ -456,19 +467,15 @@ differ:
// the queue has the types of the element it connects
srcpad->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;
}
sinkpads = g_list_next(sinkpads);
}
gst_pipeline_pads_autoplug(thesrcelement, queue);
gst_bin_add(GST_BIN(thebin), element);
gst_bin_add(GST_BIN(pipeline), thebin);
element = queue;
thesrcelement = queue;
}
// no thread needed, easy case
else {

View file

@ -231,9 +231,7 @@ void gst_audiosink_chain(GstPad *pad,GstBuffer *buf) {
}
}
}
//g_print("a unref\n");
gst_buffer_unref(buf);
//g_print("a done\n");
}
static void gst_audiosink_set_arg(GtkObject *object,GtkArg *arg,guint id) {

View file

@ -113,7 +113,7 @@ static void gst_queue_init(GstQueue *queue) {
queue->queue = NULL;
queue->level_buffers = 0;
queue->max_buffers = 10;
queue->max_buffers = 20;
queue->level_bytes = 0;
queue->size_buffers = 0;
queue->size_bytes = 0;

View file

@ -11,6 +11,11 @@ void eos(GstSrc *src)
playing = FALSE;
}
gboolean idle_func(gpointer data) {
gst_bin_iterate(GST_BIN(data));
return TRUE;
}
int main(int argc,char *argv[])
{
GstElement *disksrc, *audiosink, *videosink;
@ -22,6 +27,7 @@ int main(int argc,char *argv[])
exit(-1);
}
g_thread_init(NULL);
gst_init(&argc,&argv);
gnome_init("autoplug","0.0.1", argc,argv);
@ -68,12 +74,9 @@ int main(int argc,char *argv[])
playing = TRUE;
while (playing) {
gst_bin_iterate(GST_BIN(pipeline));
gdk_threads_enter();
while (gtk_events_pending()) gtk_main_iteration();
gdk_threads_leave();
}
gtk_idle_add(idle_func, pipeline);
gst_main();
/* stop the bin */
gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_NULL);