diff --git a/src/WebRTCSession.cpp b/src/WebRTCSession.cpp index e9822f7d6edd1313e9235a1a5ae100857573526c..a3900b482602127627e96c58c7341f5515b76c19 100644 --- a/src/WebRTCSession.cpp +++ b/src/WebRTCSession.cpp @@ -495,7 +495,7 @@ WebRTCSession::startPipeline(int opusPayloadType) } GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(pipe_)); - gst_bus_add_watch(bus, newBusMessage, this); + busWatchId_ = gst_bus_add_watch(bus, newBusMessage, this); gst_object_unref(bus); emit stateChanged(State::INITIATED); return true; @@ -601,6 +601,8 @@ WebRTCSession::end() gst_element_set_state(pipe_, GST_STATE_NULL); gst_object_unref(pipe_); pipe_ = nullptr; + g_source_remove(busWatchId_); + busWatchId_ = 0; } webrtc_ = nullptr; if (state_ != State::DISCONNECTED) diff --git a/src/WebRTCSession.h b/src/WebRTCSession.h index 56d76fa83b0d81d629eb2cf9b5c1a4b2dac3895f..8e78812f1004a6c1d23577844b801ff35753e5d2 100644 --- a/src/WebRTCSession.h +++ b/src/WebRTCSession.h @@ -64,10 +64,11 @@ private slots: private: WebRTCSession(); - bool initialised_ = false; - State state_ = State::DISCONNECTED; - GstElement *pipe_ = nullptr; - GstElement *webrtc_ = nullptr; + bool initialised_ = false; + State state_ = State::DISCONNECTED; + GstElement *pipe_ = nullptr; + GstElement *webrtc_ = nullptr; + unsigned int busWatchId_ = 0; std::string stunServer_; std::vector<std::string> turnServers_; GList *audioSources_ = nullptr;