Set a sync handler on the gstreamer bus to catch some other EOS events. Fixes issue #178

This commit is contained in:
David Sansome 2010-04-07 20:01:44 +00:00
parent 931273b9ea
commit 6122051b7d
2 changed files with 18 additions and 2 deletions

View File

@ -103,12 +103,27 @@ gboolean GstEngine::BusCallback(GstBus*, GstMessage* msg, gpointer) {
}
break;
}
default:
break;
}
return GST_BUS_DROP;
}
GstBusSyncReply GstEngine::BusCallbackSync(GstBus*, GstMessage* msg, gpointer) {
switch (GST_MESSAGE_TYPE(msg)) {
case GST_MESSAGE_EOS:
QMetaObject::invokeMethod(instance(), "EndOfStreamReached",
Qt::QueuedConnection);
break;
default:
break;
}
return GST_BUS_PASS;
}
void GstEngine::NewPadCallback(GstElement*, GstPad* pad, gboolean, gpointer) {
GstPad* const audiopad = gst_element_get_pad( instance()->gst_audiobin_, "sink" );
@ -133,6 +148,7 @@ void GstEngine::HandoffCallback(GstPad*, GstBuffer* buf, gpointer arg) {
}
void GstEngine::EventCallback(GstPad*, GstEvent* event, gpointer) {
switch ( static_cast<int>(event->type) )
{
case GST_EVENT_EOS:
@ -793,7 +809,7 @@ bool GstEngine::CreatePipeline() {
gst_audioscale_, gst_audiosink_, NULL );
gst_bin_add( GST_BIN(gst_pipeline_), gst_audiobin_);
//gst_bus_set_sync_handler(gst_pipeline_get_bus(GST_PIPELINE(gst_pipeline_)), bus_cb, NULL);
gst_bus_set_sync_handler(gst_pipeline_get_bus(GST_PIPELINE(gst_pipeline_)), BusCallbackSync, NULL);
gst_bus_add_watch(gst_pipeline_get_bus(GST_PIPELINE(gst_pipeline_)), BusCallback, NULL);
pipeline_filled_ = true;

View File

@ -122,7 +122,7 @@ class GstEngine : public Engine::Base {
// CALLBACKS:
/** Bus message */
//static GstBusSyncReply bus_cb( GstBus*, GstMessage*, gpointer );
static GstBusSyncReply BusCallbackSync( GstBus*, GstMessage*, gpointer );
static gboolean BusCallback(GstBus*, GstMessage*, gpointer);
/** Called when decodebin has generated a new pad */
static void NewPadCallback(GstElement*, GstPad*, gboolean, gpointer);