Actually show error messages that come from gstreamer. Fixes issue #230

This commit is contained in:
David Sansome 2010-04-19 12:04:35 +00:00
parent ca84b47361
commit 4bc704d7e3
3 changed files with 24 additions and 12 deletions

View File

@ -435,6 +435,8 @@ void GstEngine::HandlePipelineError(const QString& message) {
qWarning() << "Gstreamer error:" << message;
current_pipeline_.reset();
emit Error(message);
emit StateChanged(Engine::Empty);
}

View File

@ -72,8 +72,8 @@ bool GstEnginePipeline::Init(const QUrl &url) {
} else {
src_ = GstEngine::CreateElement("giosrc");
}
if (!src_)
return false;
if (!src_) // CreateElement will have shown an error dialog, so no need
return false; // one of our own.
g_object_set(G_OBJECT(src_), "location", url.toEncoded().constData(), NULL);
gst_bin_add(GST_BIN(pipeline_), src_);
@ -135,7 +135,7 @@ bool GstEnginePipeline::Init(const QUrl &url) {
audioscale_, convert, audiosink_, NULL);
gst_bus_set_sync_handler(gst_pipeline_get_bus(GST_PIPELINE(pipeline_)), BusCallbackSync, this);
gst_bus_add_watch(gst_pipeline_get_bus(GST_PIPELINE(pipeline_)), BusCallback, this);
bus_cb_id_ = gst_bus_add_watch(gst_pipeline_get_bus(GST_PIPELINE(pipeline_)), BusCallback, this);
return true;
}
@ -149,6 +149,8 @@ GstEnginePipeline::~GstEnginePipeline() {
}
if (pipeline_) {
gst_bus_set_sync_handler(gst_pipeline_get_bus(GST_PIPELINE(pipeline_)), NULL, NULL);
g_source_remove(bus_cb_id_);
gst_element_set_state(pipeline_, GST_STATE_NULL);
gst_object_unref(GST_OBJECT(pipeline_));
}
@ -160,16 +162,9 @@ gboolean GstEnginePipeline::BusCallback(GstBus*, GstMessage* msg, gpointer self)
GstEnginePipeline* instance = reinterpret_cast<GstEnginePipeline*>(self);
switch ( GST_MESSAGE_TYPE(msg)) {
case GST_MESSAGE_ERROR: {
GError* error;
gchar* debugs;
gst_message_parse_error(msg, &error, &debugs);
qWarning() << "ERROR RECEIVED IN BUS_CB <" << error->message << ">" ;
emit instance->Error(QString::fromAscii(error->message));
case GST_MESSAGE_ERROR:
instance->ErrorMessageReceived(msg);
break;
}
case GST_MESSAGE_TAG:
instance->TagMessageReceived(msg);
@ -192,6 +187,10 @@ GstBusSyncReply GstEnginePipeline::BusCallbackSync(GstBus*, GstMessage* msg, gpo
instance->TagMessageReceived(msg);
break;
case GST_MESSAGE_ERROR:
instance->ErrorMessageReceived(msg);
break;
default:
break;
}
@ -199,6 +198,15 @@ GstBusSyncReply GstEnginePipeline::BusCallbackSync(GstBus*, GstMessage* msg, gpo
return GST_BUS_PASS;
}
void GstEnginePipeline::ErrorMessageReceived(GstMessage* msg) {
GError* error;
gchar* debugs;
gst_message_parse_error(msg, &error, &debugs);
emit Error(QString::fromAscii(error->message));
}
void GstEnginePipeline::TagMessageReceived(GstMessage* msg) {
GstTagList* taglist = NULL;
gst_message_parse_tag(msg, &taglist);

View File

@ -77,6 +77,7 @@ class GstEnginePipeline : public QObject {
static void EventCallback(GstPad*, GstEvent*, gpointer);
void TagMessageReceived(GstMessage*);
QString ParseTag(GstTagList* list, const char* tag) const;
void ErrorMessageReceived(GstMessage*);
void UpdateVolume();
@ -112,6 +113,7 @@ class GstEnginePipeline : public QObject {
GstElement* audiosink_;
uint event_cb_id_;
uint bus_cb_id_;
};
#endif // GSTENGINEPIPELINE_H