summaryrefslogtreecommitdiffstats
path: root/content/renderer/media/remote_media_stream_impl.cc
diff options
context:
space:
mode:
Diffstat (limited to 'content/renderer/media/remote_media_stream_impl.cc')
-rw-r--r--content/renderer/media/remote_media_stream_impl.cc12
1 files changed, 10 insertions, 2 deletions
diff --git a/content/renderer/media/remote_media_stream_impl.cc b/content/renderer/media/remote_media_stream_impl.cc
index 057c104..06f4177 100644
--- a/content/renderer/media/remote_media_stream_impl.cc
+++ b/content/renderer/media/remote_media_stream_impl.cc
@@ -328,8 +328,7 @@ RemoteMediaStreamImpl::Observer::Observer(
}
RemoteMediaStreamImpl::Observer::~Observer() {
- DCHECK(ctor_thread_.CalledOnValidThread());
- webrtc_stream_->UnregisterObserver(this);
+ DCHECK(!webrtc_stream_.get()) << "Unregister hasn't been called";
}
void RemoteMediaStreamImpl::Observer::InitializeOnMainThread(
@@ -339,6 +338,14 @@ void RemoteMediaStreamImpl::Observer::InitializeOnMainThread(
media_stream_->InitializeOnMainThread(label);
}
+void RemoteMediaStreamImpl::Observer::Unregister() {
+ DCHECK(main_thread_->BelongsToCurrentThread());
+ webrtc_stream_->UnregisterObserver(this);
+ // Since we're guaranteed to not get further notifications, it's safe to
+ // release the webrtc_stream_ here.
+ webrtc_stream_ = nullptr;
+}
+
void RemoteMediaStreamImpl::Observer::OnChanged() {
scoped_ptr<RemoteAudioTrackAdapters> audio(new RemoteAudioTrackAdapters());
scoped_ptr<RemoteVideoTrackAdapters> video(new RemoteVideoTrackAdapters());
@@ -383,6 +390,7 @@ RemoteMediaStreamImpl::~RemoteMediaStreamImpl() {
DCHECK(observer_->main_thread()->BelongsToCurrentThread());
for (auto& track : audio_track_observers_)
track->Unregister();
+ observer_->Unregister();
}
void RemoteMediaStreamImpl::InitializeOnMainThread(const std::string& label) {