From d8bf65f800b9faf0f743025b905f536ad1f28909 Mon Sep 17 00:00:00 2001 From: Andreas Pehrson Date: Fri, 4 Jan 2019 06:39:40 +0000 Subject: [PATCH] Bug 1513973 - Make MediaEngineSource::SetTrack return void. r=jib All subclasses are now returning NS_OK, so there's no point in keeping nsresult as the return type. Differential Revision: https://phabricator.services.mozilla.com/D15193 --HG-- extra : moz-landing-system : lando --- dom/media/MediaManager.cpp | 23 +++++++------------ dom/media/MediaManager.h | 4 ++-- dom/media/webrtc/MediaEngineDefault.cpp | 6 ++--- dom/media/webrtc/MediaEngineDefault.h | 12 +++++----- .../webrtc/MediaEngineRemoteVideoSource.cpp | 3 +-- .../webrtc/MediaEngineRemoteVideoSource.h | 6 ++--- dom/media/webrtc/MediaEngineSource.h | 8 +++---- .../webrtc/MediaEngineTabVideoSource.cpp | 3 +-- dom/media/webrtc/MediaEngineTabVideoSource.h | 6 ++--- dom/media/webrtc/MediaEngineWebRTCAudio.cpp | 6 ++--- dom/media/webrtc/MediaEngineWebRTCAudio.h | 12 +++++----- 11 files changed, 38 insertions(+), 51 deletions(-) diff --git a/dom/media/MediaManager.cpp b/dom/media/MediaManager.cpp index 386a9ed2af6c..00b6459bc09c 100644 --- a/dom/media/MediaManager.cpp +++ b/dom/media/MediaManager.cpp @@ -976,13 +976,12 @@ nsresult MediaDevice::Allocate(const dom::MediaTrackConstraints& aConstraints, aOutBadConstraint); } -nsresult MediaDevice::SetTrack(const RefPtr& aStream, - TrackID aTrackID, - const PrincipalHandle& aPrincipalHandle) { +void MediaDevice::SetTrack(const RefPtr& aStream, + TrackID aTrackID, + const PrincipalHandle& aPrincipalHandle) { MOZ_ASSERT(MediaManager::IsInMediaThread()); MOZ_ASSERT(mSource); - return mSource->SetTrack(mAllocationHandle, aStream, aTrackID, - aPrincipalHandle); + mSource->SetTrack(mAllocationHandle, aStream, aTrackID, aPrincipalHandle); } nsresult MediaDevice::Start() { @@ -4123,11 +4122,8 @@ SourceListener::InitializeAsync() { mVideoDeviceState ? mVideoDeviceState->mDevice : nullptr]( MozPromiseHolder& aHolder) { if (audioDevice) { - nsresult rv = - audioDevice->SetTrack(stream, kAudioTrack, principal); - if (NS_SUCCEEDED(rv)) { - rv = audioDevice->Start(); - } + audioDevice->SetTrack(stream, kAudioTrack, principal); + nsresult rv = audioDevice->Start(); if (NS_FAILED(rv)) { nsString log; if (rv == NS_ERROR_NOT_AVAILABLE) { @@ -4147,11 +4143,8 @@ SourceListener::InitializeAsync() { } if (videoDevice) { - nsresult rv = - videoDevice->SetTrack(stream, kVideoTrack, principal); - if (NS_SUCCEEDED(rv)) { - rv = videoDevice->Start(); - } + videoDevice->SetTrack(stream, kVideoTrack, principal); + nsresult rv = videoDevice->Start(); if (NS_FAILED(rv)) { if (audioDevice) { if (NS_WARN_IF(NS_FAILED(audioDevice->Stop()))) { diff --git a/dom/media/MediaManager.h b/dom/media/MediaManager.h index 64712f063647..fbe1e66474c5 100644 --- a/dom/media/MediaManager.h +++ b/dom/media/MediaManager.h @@ -86,8 +86,8 @@ class MediaDevice : public nsIMediaDevice { const MediaEnginePrefs& aPrefs, const mozilla::ipc::PrincipalInfo& aPrincipalInfo, const char** aOutBadConstraint); - nsresult SetTrack(const RefPtr& aStream, TrackID aTrackID, - const PrincipalHandle& aPrincipal); + void SetTrack(const RefPtr& aStream, TrackID aTrackID, + const PrincipalHandle& aPrincipal); nsresult Start(); nsresult Reconfigure(const dom::MediaTrackConstraints& aConstraints, const MediaEnginePrefs& aPrefs, diff --git a/dom/media/webrtc/MediaEngineDefault.cpp b/dom/media/webrtc/MediaEngineDefault.cpp index 2dceae765bf1..199e5a50e4dc 100644 --- a/dom/media/webrtc/MediaEngineDefault.cpp +++ b/dom/media/webrtc/MediaEngineDefault.cpp @@ -160,7 +160,7 @@ static void ReleaseFrame(layers::PlanarYCbCrData& aData) { free(aData.mYChannel); } -nsresult MediaEngineDefaultVideoSource::SetTrack( +void MediaEngineDefaultVideoSource::SetTrack( const RefPtr& aHandle, const RefPtr& aStream, TrackID aTrackID, const PrincipalHandle& aPrincipal) { @@ -177,7 +177,6 @@ nsresult MediaEngineDefaultVideoSource::SetTrack( } aStream->AddTrack(aTrackID, new VideoSegment(), SourceMediaStream::ADDTRACK_QUEUED); - return NS_OK; } nsresult MediaEngineDefaultVideoSource::Start( @@ -424,7 +423,7 @@ nsresult MediaEngineDefaultAudioSource::Deallocate( return NS_OK; } -nsresult MediaEngineDefaultAudioSource::SetTrack( +void MediaEngineDefaultAudioSource::SetTrack( const RefPtr& aHandle, const RefPtr& aStream, TrackID aTrackID, const PrincipalHandle& aPrincipal) { @@ -439,7 +438,6 @@ nsresult MediaEngineDefaultAudioSource::SetTrack( mTrackID = aTrackID; aStream->AddAudioTrack(aTrackID, aStream->GraphRate(), new AudioSegment(), SourceMediaStream::ADDTRACK_QUEUED); - return NS_OK; } nsresult MediaEngineDefaultAudioSource::Start( diff --git a/dom/media/webrtc/MediaEngineDefault.h b/dom/media/webrtc/MediaEngineDefault.h index edd2858dbc57..326bff8aa30c 100644 --- a/dom/media/webrtc/MediaEngineDefault.h +++ b/dom/media/webrtc/MediaEngineDefault.h @@ -47,9 +47,9 @@ class MediaEngineDefaultVideoSource : public MediaEngineSource { const ipc::PrincipalInfo& aPrincipalInfo, AllocationHandle** aOutHandle, const char** aOutBadConstraint) override; - nsresult SetTrack(const RefPtr& aHandle, - const RefPtr& aStream, TrackID aTrackID, - const PrincipalHandle& aPrincipal) override; + void SetTrack(const RefPtr& aHandle, + const RefPtr& aStream, TrackID aTrackID, + const PrincipalHandle& aPrincipal) override; nsresult Start(const RefPtr& aHandle) override; nsresult Reconfigure(const RefPtr& aHandle, const dom::MediaTrackConstraints& aConstraints, @@ -114,9 +114,9 @@ class MediaEngineDefaultAudioSource : public MediaEngineSource { const ipc::PrincipalInfo& aPrincipalInfo, AllocationHandle** aOutHandle, const char** aOutBadConstraint) override; - nsresult SetTrack(const RefPtr& aHandle, - const RefPtr& aStream, TrackID aTrackID, - const PrincipalHandle& aPrincipal) override; + void SetTrack(const RefPtr& aHandle, + const RefPtr& aStream, TrackID aTrackID, + const PrincipalHandle& aPrincipal) override; nsresult Start(const RefPtr& aHandle) override; nsresult Reconfigure(const RefPtr& aHandle, const dom::MediaTrackConstraints& aConstraints, diff --git a/dom/media/webrtc/MediaEngineRemoteVideoSource.cpp b/dom/media/webrtc/MediaEngineRemoteVideoSource.cpp index e5796891a82f..caca0ae82248 100644 --- a/dom/media/webrtc/MediaEngineRemoteVideoSource.cpp +++ b/dom/media/webrtc/MediaEngineRemoteVideoSource.cpp @@ -259,7 +259,7 @@ nsresult MediaEngineRemoteVideoSource::Deallocate( return NS_OK; } -nsresult MediaEngineRemoteVideoSource::SetTrack( +void MediaEngineRemoteVideoSource::SetTrack( const RefPtr& aHandle, const RefPtr& aStream, TrackID aTrackID, const PrincipalHandle& aPrincipal) { @@ -285,7 +285,6 @@ nsresult MediaEngineRemoteVideoSource::SetTrack( } aStream->AddTrack(aTrackID, new VideoSegment(), SourceMediaStream::ADDTRACK_QUEUED); - return NS_OK; } nsresult MediaEngineRemoteVideoSource::Start( diff --git a/dom/media/webrtc/MediaEngineRemoteVideoSource.h b/dom/media/webrtc/MediaEngineRemoteVideoSource.h index 0514be6c72ab..2697e70ad264 100644 --- a/dom/media/webrtc/MediaEngineRemoteVideoSource.h +++ b/dom/media/webrtc/MediaEngineRemoteVideoSource.h @@ -124,9 +124,9 @@ class MediaEngineRemoteVideoSource : public MediaEngineSource, AllocationHandle** aOutHandle, const char** aOutBadConstraint) override; nsresult Deallocate(const RefPtr& aHandle) override; - nsresult SetTrack(const RefPtr& aHandle, - const RefPtr& aStream, TrackID aTrackID, - const PrincipalHandle& aPrincipal) override; + void SetTrack(const RefPtr& aHandle, + const RefPtr& aStream, TrackID aTrackID, + const PrincipalHandle& aPrincipal) override; nsresult Start(const RefPtr& aHandle) override; nsresult Reconfigure(const RefPtr& aHandle, const dom::MediaTrackConstraints& aConstraints, diff --git a/dom/media/webrtc/MediaEngineSource.h b/dom/media/webrtc/MediaEngineSource.h index 727f18998070..174c132c2a88 100644 --- a/dom/media/webrtc/MediaEngineSource.h +++ b/dom/media/webrtc/MediaEngineSource.h @@ -145,10 +145,10 @@ class MediaEngineSourceInterface { * * This must be called before Start for the given AllocationHandle. */ - virtual nsresult SetTrack(const RefPtr& aHandle, - const RefPtr& aStream, - TrackID aTrackID, - const PrincipalHandle& aPrincipal) = 0; + virtual void SetTrack(const RefPtr& aHandle, + const RefPtr& aStream, + TrackID aTrackID, + const PrincipalHandle& aPrincipal) = 0; /** * Called by MediaEngine to start feeding data to the track associated with diff --git a/dom/media/webrtc/MediaEngineTabVideoSource.cpp b/dom/media/webrtc/MediaEngineTabVideoSource.cpp index ff6dc0e67d31..6e249a589190 100644 --- a/dom/media/webrtc/MediaEngineTabVideoSource.cpp +++ b/dom/media/webrtc/MediaEngineTabVideoSource.cpp @@ -193,7 +193,7 @@ nsresult MediaEngineTabVideoSource::Deallocate( return NS_OK; } -nsresult MediaEngineTabVideoSource::SetTrack( +void MediaEngineTabVideoSource::SetTrack( const RefPtr& aHandle, const RefPtr& aStream, TrackID aTrackID, const mozilla::PrincipalHandle& aPrincipal) { @@ -207,7 +207,6 @@ nsresult MediaEngineTabVideoSource::SetTrack( mStream = aStream; mTrackID = aTrackID; mStream->AddTrack(mTrackID, new VideoSegment()); - return NS_OK; } nsresult MediaEngineTabVideoSource::Start( diff --git a/dom/media/webrtc/MediaEngineTabVideoSource.h b/dom/media/webrtc/MediaEngineTabVideoSource.h index 8a698e26d7e4..1b6e42ce627b 100644 --- a/dom/media/webrtc/MediaEngineTabVideoSource.h +++ b/dom/media/webrtc/MediaEngineTabVideoSource.h @@ -30,9 +30,9 @@ class MediaEngineTabVideoSource : public MediaEngineSource { AllocationHandle** aOutHandle, const char** aOutBadConstraint) override; nsresult Deallocate(const RefPtr& aHandle) override; - nsresult SetTrack(const RefPtr& aHandle, - const RefPtr& aStream, TrackID aTrackID, - const PrincipalHandle& aPrincipal) override; + void SetTrack(const RefPtr& aHandle, + const RefPtr& aStream, TrackID aTrackID, + const PrincipalHandle& aPrincipal) override; nsresult Start(const RefPtr& aHandle) override; nsresult Reconfigure(const RefPtr& aHandle, const dom::MediaTrackConstraints& aConstraints, diff --git a/dom/media/webrtc/MediaEngineWebRTCAudio.cpp b/dom/media/webrtc/MediaEngineWebRTCAudio.cpp index dc50f8820f8f..1f2deb9550ba 100644 --- a/dom/media/webrtc/MediaEngineWebRTCAudio.cpp +++ b/dom/media/webrtc/MediaEngineWebRTCAudio.cpp @@ -503,7 +503,7 @@ nsresult MediaEngineWebRTCMicrophoneSource::Deallocate( return NS_OK; } -nsresult MediaEngineWebRTCMicrophoneSource::SetTrack( +void MediaEngineWebRTCMicrophoneSource::SetTrack( const RefPtr&, const RefPtr& aStream, TrackID aTrackID, const PrincipalHandle& aPrincipal) { @@ -524,7 +524,6 @@ nsresult MediaEngineWebRTCMicrophoneSource::SetTrack( SourceMediaStream::ADDTRACK_QUEUED); LOG("Stream %p registered for microphone capture", aStream.get()); - return NS_OK; } class StartStopMessage : public ControlMessage { @@ -1160,13 +1159,12 @@ nsCString MediaEngineWebRTCAudioCaptureSource::GetUUID() const { return nsCString(Substring(asciiString, 1, NSID_LENGTH - 3)); } -nsresult MediaEngineWebRTCAudioCaptureSource::SetTrack( +void MediaEngineWebRTCAudioCaptureSource::SetTrack( const RefPtr&, const RefPtr& aStream, TrackID aTrackID, const PrincipalHandle& aPrincipalHandle) { AssertIsOnOwningThread(); // Nothing to do here. aStream is a placeholder dummy and not exposed. - return NS_OK; } nsresult MediaEngineWebRTCAudioCaptureSource::Start( diff --git a/dom/media/webrtc/MediaEngineWebRTCAudio.h b/dom/media/webrtc/MediaEngineWebRTCAudio.h index 182a03af0717..ec1a70209346 100644 --- a/dom/media/webrtc/MediaEngineWebRTCAudio.h +++ b/dom/media/webrtc/MediaEngineWebRTCAudio.h @@ -43,9 +43,9 @@ class MediaEngineWebRTCMicrophoneSource : public MediaEngineSource { AllocationHandle** aOutHandle, const char** aOutBadConstraint) override; nsresult Deallocate(const RefPtr& aHandle) override; - nsresult SetTrack(const RefPtr& aHandle, - const RefPtr& aStream, TrackID aTrackID, - const PrincipalHandle& aPrincipal) override; + void SetTrack(const RefPtr& aHandle, + const RefPtr& aStream, TrackID aTrackID, + const PrincipalHandle& aPrincipal) override; nsresult Start(const RefPtr& aHandle) override; nsresult Stop(const RefPtr& aHandle) override; nsresult Reconfigure(const RefPtr& aHandle, @@ -269,9 +269,9 @@ class MediaEngineWebRTCAudioCaptureSource : public MediaEngineSource { MOZ_ASSERT(!aHandle); return NS_OK; } - nsresult SetTrack(const RefPtr& aHandle, - const RefPtr& aStream, TrackID aTrackID, - const PrincipalHandle& aPrincipal) override; + void SetTrack(const RefPtr& aHandle, + const RefPtr& aStream, TrackID aTrackID, + const PrincipalHandle& aPrincipal) override; nsresult Start(const RefPtr& aHandle) override; nsresult Stop(const RefPtr& aHandle) override; nsresult Reconfigure(const RefPtr& aHandle,