Bug 825439: Disconnect pipeline on STS Thread r=jesup
authorEKR <ekr@rtfm.com>
Sat, 29 Dec 2012 09:24:34 -0800
changeset 126481 ad35aa6a56cae5f6d7666f84e98f8fd816d7df51
parent 126480 288b327769f0d80728b10956b3787bccde897b55
child 126482 da905fbd3113ab866ab6d6f97f4a93cf06dc5d14
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup
bugs825439
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 825439: Disconnect pipeline on STS Thread r=jesup
media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
media/webrtc/signaling/src/mediapipeline/MediaPipeline.h
--- a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
+++ b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
@@ -45,16 +45,27 @@ using namespace mozilla;
 MOZ_MTLOG_MODULE("mediapipeline");
 
 namespace mozilla {
 
 static char kDTLSExporterLabel[] = "EXTRACTOR-dtls_srtp";
 
 nsresult MediaPipeline::Init() {
   ASSERT_ON_THREAD(main_thread_);
+
+  // TODO(ekr@rtfm.com): is there a way to make this async?
+  nsresult ret;
+  RUN_ON_THREAD(sts_thread_,
+		WrapRunnableRet(this, &MediaPipeline::Init_s, &ret),
+		NS_DISPATCH_SYNC);
+  return ret;
+}
+
+nsresult MediaPipeline::Init_s() {
+  ASSERT_ON_THREAD(sts_thread_);
   conduit_->AttachTransport(transport_);
 
   MOZ_ASSERT(rtp_transport_);
 
   nsresult res;
 
   // Look to see if the transport is ready
   rtp_transport_->SignalStateChange.connect(this,
@@ -84,16 +95,17 @@ nsresult MediaPipeline::Init() {
 }
 
 
 // Disconnect us from the transport so that we can cleanly destruct
 // the pipeline on the main thread.
 void MediaPipeline::DetachTransport_s() {
   ASSERT_ON_THREAD(sts_thread_);
 
+  disconnect_all();
   transport_->Detach();
   rtp_transport_ = NULL;
   rtcp_transport_ = NULL;
 }
 
 void MediaPipeline::DetachTransport() {
   RUN_ON_THREAD(sts_thread_,
                 WrapRunnable(this, &MediaPipeline::DetachTransport_s),
--- a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.h
+++ b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.h
@@ -202,16 +202,17 @@ class MediaPipeline : public sigslot::ha
   int rtcp_packets_received_;
 
   // Written on Init. Read on STS thread.
   bool muxed_;
   std::string pc_;
   std::string description_;
 
  private:
+  nsresult Init_s();
   void DetachTransport();
   void DetachTransport_s();
 
   nsresult TransportReadyInt(TransportFlow *flow);
 
   bool IsRtp(const unsigned char *data, size_t len);
 };