Remove async bus callback from transcoder. This caused the UI to get unresponsive after a song was converted.

A bit more information:
Normal transcoding worked fine, the transcoder object was in the main thread. In the network remote, a new transcoder object is created which runs in the network remote thread. When a song was transcoded there, the UI became unresponsive.
Removing the async bus callback solved the problem, exactly the g_source_remove() method caused it. Since the bus callback returned FALSE (GST_BUS_DROP), the watch was already removed. (See http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstBus.html#gst-bus-add-watch)
This commit is contained in:
Andreas 2014-11-14 23:50:59 +01:00
parent 86a375f952
commit 880308c205
2 changed files with 1 additions and 24 deletions

View File

@ -358,21 +358,6 @@ void Transcoder::NewPadCallback(GstElement*, GstPad* pad,
gst_object_unref(audiopad);
}
gboolean Transcoder::BusCallback(GstBus*, GstMessage* msg, gpointer data) {
JobState* state = reinterpret_cast<JobState*>(data);
switch (GST_MESSAGE_TYPE(msg)) {
case GST_MESSAGE_ERROR:
state->ReportError(msg);
state->PostFinished(false);
break;
default:
break;
}
return GST_BUS_DROP;
}
GstBusSyncReply Transcoder::BusCallbackSync(GstBus*, GstMessage* msg,
gpointer data) {
JobState* state = reinterpret_cast<JobState*>(data);
@ -461,9 +446,6 @@ bool Transcoder::StartJob(const Job& job) {
CHECKED_GCONNECT(decode, "pad-added", &NewPadCallback, state.get());
gst_bus_set_sync_handler(gst_pipeline_get_bus(GST_PIPELINE(state->pipeline_)),
BusCallbackSync, state.get(), nullptr);
state->bus_callback_id_ = gst_bus_add_watch(
gst_pipeline_get_bus(GST_PIPELINE(state->pipeline_)),
BusCallback, state.get());
// Start the pipeline
gst_element_set_state(state->pipeline_, GST_STATE_PLAYING);
@ -507,7 +489,6 @@ bool Transcoder::event(QEvent* e) {
gst_bus_set_sync_handler(
gst_pipeline_get_bus(GST_PIPELINE(finished_event->state_->pipeline_)),
nullptr, nullptr, nullptr);
g_source_remove(finished_event->state_->bus_callback_id_);
// Remove it from the list - this will also destroy the GStreamer pipeline
current_jobs_.erase(it);
@ -537,7 +518,6 @@ void Transcoder::Cancel() {
// called after the pipeline is shutting down
gst_bus_set_sync_handler(gst_pipeline_get_bus(
GST_PIPELINE(state->pipeline_)), nullptr, nullptr, nullptr);
g_source_remove(state->bus_callback_id_);
// Stop the pipeline
if (gst_element_set_state(state->pipeline_, GST_STATE_NULL) ==

View File

@ -90,8 +90,7 @@ signals:
: job_(job),
parent_(parent),
pipeline_(nullptr),
convert_element_(nullptr),
bus_callback_id_(0) {}
convert_element_(nullptr) {}
~JobState();
void PostFinished(bool success);
@ -101,7 +100,6 @@ signals:
Transcoder* parent_;
GstElement* pipeline_;
GstElement* convert_element_;
int bus_callback_id_;
};
// Event passed from a GStreamer callback to the Transcoder when a job
@ -134,7 +132,6 @@ signals:
void SetElementProperties(const QString& name, GObject* element);
static void NewPadCallback(GstElement*, GstPad* pad, gpointer data);
static gboolean BusCallback(GstBus*, GstMessage* msg, gpointer data);
static GstBusSyncReply BusCallbackSync(GstBus*, GstMessage* msg,
gpointer data);