From 3b35f69ac92259f20cd69c08993a89c7a52f19ab Mon Sep 17 00:00:00 2001 From: ghost Date: Wed, 28 Oct 2009 00:45:37 +0100 Subject: [PATCH] servicemp3.cpp: fix possible segfault/asserting (bug #216) --- lib/service/servicemp3.cpp | 17 +++++++++++++++-- lib/service/servicemp3.h | 1 + 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/service/servicemp3.cpp b/lib/service/servicemp3.cpp index 7701d4d..7f87ffa 100644 --- a/lib/service/servicemp3.cpp +++ b/lib/service/servicemp3.cpp @@ -302,7 +302,7 @@ eServiceMP3::eServiceMP3(eServiceReference ref) eDebug("eServiceMP3::sorry, can't play: missing gst-plugin-appsink"); else { - g_signal_connect (subsink, "new-buffer", G_CALLBACK (gstCBsubtitleAvail), this); + m_subs_to_pull_handler_id = g_signal_connect (subsink, "new-buffer", G_CALLBACK (gstCBsubtitleAvail), this); g_object_set (G_OBJECT (m_gst_playbin), "text-sink", subsink, NULL); } @@ -340,10 +340,23 @@ eServiceMP3::eServiceMP3(eServiceReference ref) eServiceMP3::~eServiceMP3() { + // disconnect subtitle callback + GstElement *sink; + g_object_get (G_OBJECT (m_gst_playbin), "text-sink", &sink, NULL); + if (sink) + { + g_signal_handler_disconnect (sink, m_subs_to_pull_handler_id); + gst_object_unref(sink); + } + delete m_subtitle_widget; + + // disconnect sync handler callback + gst_bus_set_sync_handler(gst_pipeline_get_bus (GST_PIPELINE (m_gst_playbin)), NULL, NULL); + if (m_state == stRunning) stop(); - + if (m_stream_tags) gst_tag_list_free(m_stream_tags); diff --git a/lib/service/servicemp3.h b/lib/service/servicemp3.h index d2a8fb0..15ed0b0 100644 --- a/lib/service/servicemp3.h +++ b/lib/service/servicemp3.h @@ -204,6 +204,7 @@ private: void pullSubtitle(); int m_subs_to_pull; eSingleLock m_subs_to_pull_lock; + gulong m_subs_to_pull_handler_id; RESULT seekToImpl(pts_t to); -- 2.7.4