Bug 1661668 - Rename CrossGraphManager to CrossGraphPort. r=padenot
"Manager" is vague, and it seems to mostly keep some members around rather than managing them. Port is analogue to MediaInputPort in that it acts as a link between two tracks. Neither type of port does very much heavy lifting -- they are similarly dumb. Differential Revision: https://phabricator.services.mozilla.com/D88812
This commit is contained in:
@@ -13,7 +13,7 @@
|
|||||||
#include "AudioStreamTrack.h"
|
#include "AudioStreamTrack.h"
|
||||||
#include "AutoplayPolicy.h"
|
#include "AutoplayPolicy.h"
|
||||||
#include "ChannelMediaDecoder.h"
|
#include "ChannelMediaDecoder.h"
|
||||||
#include "CrossGraphTrack.h"
|
#include "CrossGraphPort.h"
|
||||||
#include "DOMMediaStream.h"
|
#include "DOMMediaStream.h"
|
||||||
#include "DecoderDoctorDiagnostics.h"
|
#include "DecoderDoctorDiagnostics.h"
|
||||||
#include "DecoderDoctorLogger.h"
|
#include "DecoderDoctorLogger.h"
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ void AudioStreamTrack::AddAudioOutput(void* aKey) {
|
|||||||
if (Ended()) {
|
if (Ended()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (UniquePtr<CrossGraphManager>* cgm = mCrossGraphs.Get(aKey)) {
|
if (UniquePtr<CrossGraphPort>* cgm = mCrossGraphs.Get(aKey)) {
|
||||||
(*cgm)->AddAudioOutput(aKey);
|
(*cgm)->AddAudioOutput(aKey);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -26,7 +26,7 @@ void AudioStreamTrack::RemoveAudioOutput(void* aKey) {
|
|||||||
if (Ended()) {
|
if (Ended()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (UniquePtr<CrossGraphManager>* cgm = mCrossGraphs.Get(aKey)) {
|
if (UniquePtr<CrossGraphPort>* cgm = mCrossGraphs.Get(aKey)) {
|
||||||
(*cgm)->RemoveAudioOutput(aKey);
|
(*cgm)->RemoveAudioOutput(aKey);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -37,7 +37,7 @@ void AudioStreamTrack::SetAudioOutputVolume(void* aKey, float aVolume) {
|
|||||||
if (Ended()) {
|
if (Ended()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (UniquePtr<CrossGraphManager>* cgm = mCrossGraphs.Get(aKey)) {
|
if (UniquePtr<CrossGraphPort>* cgm = mCrossGraphs.Get(aKey)) {
|
||||||
(*cgm)->SetAudioOutputVolume(aKey, aVolume);
|
(*cgm)->SetAudioOutputVolume(aKey, aVolume);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -76,7 +76,7 @@ RefPtr<GenericPromise> AudioStreamTrack::SetAudioOutputDevice(
|
|||||||
if (Ended()) {
|
if (Ended()) {
|
||||||
return GenericPromise::CreateAndResolve(true, __func__);
|
return GenericPromise::CreateAndResolve(true, __func__);
|
||||||
}
|
}
|
||||||
CrossGraphManager* manager = CrossGraphManager::Connect(this, aSink, mWindow);
|
CrossGraphPort* manager = CrossGraphPort::Connect(this, aSink, mWindow);
|
||||||
if (!manager) {
|
if (!manager) {
|
||||||
auto entry = mCrossGraphs.Lookup(key);
|
auto entry = mCrossGraphs.Lookup(key);
|
||||||
MOZ_ASSERT(entry);
|
MOZ_ASSERT(entry);
|
||||||
@@ -84,7 +84,7 @@ RefPtr<GenericPromise> AudioStreamTrack::SetAudioOutputDevice(
|
|||||||
entry.Remove();
|
entry.Remove();
|
||||||
return GenericPromise::CreateAndResolve(true, __func__);
|
return GenericPromise::CreateAndResolve(true, __func__);
|
||||||
}
|
}
|
||||||
UniquePtr<CrossGraphManager>* crossGraphPtr = mCrossGraphs.LookupOrAdd(key);
|
UniquePtr<CrossGraphPort>* crossGraphPtr = mCrossGraphs.LookupOrAdd(key);
|
||||||
if (*crossGraphPtr) {
|
if (*crossGraphPtr) {
|
||||||
(*crossGraphPtr)->Destroy();
|
(*crossGraphPtr)->Destroy();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
#include "MediaStreamTrack.h"
|
#include "MediaStreamTrack.h"
|
||||||
#include "DOMMediaStream.h"
|
#include "DOMMediaStream.h"
|
||||||
#include "CrossGraphTrack.h"
|
#include "CrossGraphPort.h"
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace dom {
|
namespace dom {
|
||||||
@@ -43,11 +43,10 @@ class AudioStreamTrack : public MediaStreamTrack {
|
|||||||
void SetReadyState(MediaStreamTrackState aState) override;
|
void SetReadyState(MediaStreamTrackState aState) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Track CrossGraphManager per AudioOutput key. This is required in order to
|
// Track CrossGraphPort per AudioOutput key. This is required in order to
|
||||||
// redirect all AudioOutput requests (add, remove, set volume) to the
|
// redirect all AudioOutput requests (add, remove, set volume) to the
|
||||||
// receiver track which, belonging to the remote graph. MainThread only.
|
// receiver track which, belonging to the remote graph. MainThread only.
|
||||||
nsClassHashtable<nsPtrHashKey<void>, UniquePtr<CrossGraphManager>>
|
nsClassHashtable<nsPtrHashKey<void>, UniquePtr<CrossGraphPort>> mCrossGraphs;
|
||||||
mCrossGraphs;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace dom
|
} // namespace dom
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
#include "CrossGraphTrack.h"
|
#include "CrossGraphPort.h"
|
||||||
|
|
||||||
#include "AudioDeviceInfo.h"
|
#include "AudioDeviceInfo.h"
|
||||||
#include "AudioStreamTrack.h"
|
#include "AudioStreamTrack.h"
|
||||||
@@ -22,7 +22,7 @@ extern LazyLogModule gForwardedInputTrackLog;
|
|||||||
#define LOG(type, msg) MOZ_LOG(gForwardedInputTrackLog, type, msg)
|
#define LOG(type, msg) MOZ_LOG(gForwardedInputTrackLog, type, msg)
|
||||||
#define LOG_TEST(type) MOZ_LOG_TEST(gForwardedInputTrackLog, type)
|
#define LOG_TEST(type) MOZ_LOG_TEST(gForwardedInputTrackLog, type)
|
||||||
|
|
||||||
CrossGraphManager* CrossGraphManager::Connect(
|
CrossGraphPort* CrossGraphPort::Connect(
|
||||||
const RefPtr<dom::AudioStreamTrack>& aStreamTrack, AudioDeviceInfo* aSink,
|
const RefPtr<dom::AudioStreamTrack>& aStreamTrack, AudioDeviceInfo* aSink,
|
||||||
nsPIDOMWindowInner* aWindow) {
|
nsPIDOMWindowInner* aWindow) {
|
||||||
MOZ_ASSERT(aSink);
|
MOZ_ASSERT(aSink);
|
||||||
@@ -30,7 +30,7 @@ CrossGraphManager* CrossGraphManager::Connect(
|
|||||||
uint32_t defaultRate;
|
uint32_t defaultRate;
|
||||||
aSink->GetDefaultRate(&defaultRate);
|
aSink->GetDefaultRate(&defaultRate);
|
||||||
LOG(LogLevel::Debug,
|
LOG(LogLevel::Debug,
|
||||||
("CrossGraphManager::Connect: sink id: %p at rate %u, primary rate %d",
|
("CrossGraphPort::Connect: sink id: %p at rate %u, primary rate %d",
|
||||||
aSink->DeviceID(), defaultRate, aStreamTrack->Graph()->GraphRate()));
|
aSink->DeviceID(), defaultRate, aStreamTrack->Graph()->GraphRate()));
|
||||||
|
|
||||||
if (!aSink->DeviceID()) {
|
if (!aSink->DeviceID()) {
|
||||||
@@ -41,10 +41,10 @@ CrossGraphManager* CrossGraphManager::Connect(
|
|||||||
MediaTrackGraph::GetInstance(MediaTrackGraph::AUDIO_THREAD_DRIVER,
|
MediaTrackGraph::GetInstance(MediaTrackGraph::AUDIO_THREAD_DRIVER,
|
||||||
aWindow, defaultRate, aSink->DeviceID());
|
aWindow, defaultRate, aSink->DeviceID());
|
||||||
|
|
||||||
return CrossGraphManager::Connect(aStreamTrack, newGraph);
|
return CrossGraphPort::Connect(aStreamTrack, newGraph);
|
||||||
}
|
}
|
||||||
|
|
||||||
CrossGraphManager* CrossGraphManager::Connect(
|
CrossGraphPort* CrossGraphPort::Connect(
|
||||||
const RefPtr<dom::AudioStreamTrack>& aStreamTrack,
|
const RefPtr<dom::AudioStreamTrack>& aStreamTrack,
|
||||||
MediaTrackGraph* aPartnerGraph) {
|
MediaTrackGraph* aPartnerGraph) {
|
||||||
MOZ_ASSERT(aStreamTrack);
|
MOZ_ASSERT(aStreamTrack);
|
||||||
@@ -64,40 +64,40 @@ CrossGraphManager* CrossGraphManager::Connect(
|
|||||||
RefPtr<MediaInputPort> port =
|
RefPtr<MediaInputPort> port =
|
||||||
aStreamTrack->ForwardTrackContentsTo(transmitter);
|
aStreamTrack->ForwardTrackContentsTo(transmitter);
|
||||||
|
|
||||||
return new CrossGraphManager(port);
|
return new CrossGraphPort(port);
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<CrossGraphTransmitter> CrossGraphManager::GetTransmitter() {
|
RefPtr<CrossGraphTransmitter> CrossGraphPort::GetTransmitter() {
|
||||||
return mTransmitter;
|
return mTransmitter;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<CrossGraphReceiver> CrossGraphManager::GetReceiver() {
|
RefPtr<CrossGraphReceiver> CrossGraphPort::GetReceiver() {
|
||||||
return GetTransmitter()->mReceiver;
|
return GetTransmitter()->mReceiver;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CrossGraphManager::AddAudioOutput(void* aKey) {
|
void CrossGraphPort::AddAudioOutput(void* aKey) {
|
||||||
MOZ_ASSERT(GetTransmitter());
|
MOZ_ASSERT(GetTransmitter());
|
||||||
GetReceiver()->AddAudioOutput(aKey);
|
GetReceiver()->AddAudioOutput(aKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CrossGraphManager::RemoveAudioOutput(void* aKey) {
|
void CrossGraphPort::RemoveAudioOutput(void* aKey) {
|
||||||
MOZ_ASSERT(GetTransmitter());
|
MOZ_ASSERT(GetTransmitter());
|
||||||
GetReceiver()->RemoveAudioOutput(aKey);
|
GetReceiver()->RemoveAudioOutput(aKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CrossGraphManager::SetAudioOutputVolume(void* aKey, float aVolume) {
|
void CrossGraphPort::SetAudioOutputVolume(void* aKey, float aVolume) {
|
||||||
MOZ_ASSERT(GetTransmitter());
|
MOZ_ASSERT(GetTransmitter());
|
||||||
GetReceiver()->SetAudioOutputVolume(aKey, aVolume);
|
GetReceiver()->SetAudioOutputVolume(aKey, aVolume);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CrossGraphManager::Destroy() {
|
void CrossGraphPort::Destroy() {
|
||||||
MOZ_ASSERT(GetTransmitter());
|
MOZ_ASSERT(GetTransmitter());
|
||||||
GetTransmitter()->Destroy();
|
GetTransmitter()->Destroy();
|
||||||
mSourcePort->Destroy();
|
mSourcePort->Destroy();
|
||||||
mSourcePort = nullptr;
|
mSourcePort = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
RefPtr<GenericPromise> CrossGraphManager::EnsureConnected() {
|
RefPtr<GenericPromise> CrossGraphPort::EnsureConnected() {
|
||||||
// The primary graph is already working check the partner (receiver's) graph.
|
// The primary graph is already working check the partner (receiver's) graph.
|
||||||
return GetReceiver()->Graph()->NotifyWhenDeviceStarted(GetReceiver().get());
|
return GetReceiver()->Graph()->NotifyWhenDeviceStarted(GetReceiver().get());
|
||||||
}
|
}
|
||||||
@@ -25,7 +25,7 @@ namespace mozilla {
|
|||||||
* See MediaTrackGraph::CreateCrossGraphTransmitter()
|
* See MediaTrackGraph::CreateCrossGraphTransmitter()
|
||||||
*/
|
*/
|
||||||
class CrossGraphTransmitter : public ForwardedInputTrack {
|
class CrossGraphTransmitter : public ForwardedInputTrack {
|
||||||
friend class CrossGraphManager;
|
friend class CrossGraphPort;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CrossGraphTransmitter(TrackRate aSampleRate, CrossGraphReceiver* aReceiver);
|
CrossGraphTransmitter(TrackRate aSampleRate, CrossGraphReceiver* aReceiver);
|
||||||
@@ -65,15 +65,15 @@ class CrossGraphReceiver : public ProcessedMediaTrack {
|
|||||||
AudioDriftCorrection mDriftCorrection;
|
AudioDriftCorrection mDriftCorrection;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CrossGraphManager final {
|
class CrossGraphPort final {
|
||||||
public:
|
public:
|
||||||
static CrossGraphManager* Connect(
|
static CrossGraphPort* Connect(
|
||||||
const RefPtr<dom::AudioStreamTrack>& aStreamTrack,
|
const RefPtr<dom::AudioStreamTrack>& aStreamTrack,
|
||||||
MediaTrackGraph* aPartnerGraph);
|
MediaTrackGraph* aPartnerGraph);
|
||||||
static CrossGraphManager* Connect(
|
static CrossGraphPort* Connect(
|
||||||
const RefPtr<dom::AudioStreamTrack>& aStreamTrack, AudioDeviceInfo* aSink,
|
const RefPtr<dom::AudioStreamTrack>& aStreamTrack, AudioDeviceInfo* aSink,
|
||||||
nsPIDOMWindowInner* aWindow);
|
nsPIDOMWindowInner* aWindow);
|
||||||
~CrossGraphManager() = default;
|
~CrossGraphPort() = default;
|
||||||
|
|
||||||
void AddAudioOutput(void* aKey);
|
void AddAudioOutput(void* aKey);
|
||||||
void RemoveAudioOutput(void* aKey);
|
void RemoveAudioOutput(void* aKey);
|
||||||
@@ -83,7 +83,7 @@ class CrossGraphManager final {
|
|||||||
RefPtr<GenericPromise> EnsureConnected();
|
RefPtr<GenericPromise> EnsureConnected();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit CrossGraphManager(const RefPtr<MediaInputPort>& aPort)
|
explicit CrossGraphPort(const RefPtr<MediaInputPort>& aPort)
|
||||||
: mSourcePort(aPort),
|
: mSourcePort(aPort),
|
||||||
mTransmitter(mSourcePort->GetDestination()->AsCrossGraphTransmitter()) {
|
mTransmitter(mSourcePort->GetDestination()->AsCrossGraphTransmitter()) {
|
||||||
}
|
}
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
#include "mozilla/Unused.h"
|
#include "mozilla/Unused.h"
|
||||||
|
|
||||||
#include "AudioSegment.h"
|
#include "AudioSegment.h"
|
||||||
#include "CrossGraphTrack.h"
|
#include "CrossGraphPort.h"
|
||||||
#include "VideoSegment.h"
|
#include "VideoSegment.h"
|
||||||
#include "nsContentUtils.h"
|
#include "nsContentUtils.h"
|
||||||
#include "nsPrintfCString.h"
|
#include "nsPrintfCString.h"
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ EXPORTS += [
|
|||||||
'BufferReader.h',
|
'BufferReader.h',
|
||||||
'ByteWriter.h',
|
'ByteWriter.h',
|
||||||
'ChannelMediaDecoder.h',
|
'ChannelMediaDecoder.h',
|
||||||
'CrossGraphTrack.h',
|
'CrossGraphPort.h',
|
||||||
'CubebUtils.h',
|
'CubebUtils.h',
|
||||||
'DecoderTraits.h',
|
'DecoderTraits.h',
|
||||||
'DOMMediaStream.h',
|
'DOMMediaStream.h',
|
||||||
@@ -254,7 +254,7 @@ UNIFIED_SOURCES += [
|
|||||||
'ChannelMediaDecoder.cpp',
|
'ChannelMediaDecoder.cpp',
|
||||||
'ChannelMediaResource.cpp',
|
'ChannelMediaResource.cpp',
|
||||||
'CloneableWithRangeMediaResource.cpp',
|
'CloneableWithRangeMediaResource.cpp',
|
||||||
'CrossGraphTrack.cpp',
|
'CrossGraphPort.cpp',
|
||||||
'DOMMediaStream.cpp',
|
'DOMMediaStream.cpp',
|
||||||
'DynamicResampler.cpp',
|
'DynamicResampler.cpp',
|
||||||
'FileBlockCache.cpp',
|
'FileBlockCache.cpp',
|
||||||
|
|||||||
Reference in New Issue
Block a user