зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1190676 - Part 3 - Make getting a MediaStreamGraph for a channel more explicit. r=roc
Hopefully this wil also prevent getting the wrong graph. --HG-- extra : rebase_source : 3465c29807798d237c4d289b1a88845684373de5
This commit is contained in:
Родитель
f35ee39298
Коммит
86793c21b6
|
@ -58,7 +58,7 @@ PRLogModuleInfo* gMediaStreamGraphLog;
|
|||
#endif
|
||||
|
||||
/**
|
||||
* The singleton graph instance.
|
||||
* A hash table containing the graph instances, one per AudioChannel.
|
||||
*/
|
||||
static nsDataHashtable<nsUint32HashKey, MediaStreamGraphImpl*> gGraphs;
|
||||
|
||||
|
@ -2865,9 +2865,8 @@ ProcessedMediaStream::DestroyImpl()
|
|||
// SetStreamOrderDirty(), for other reasons.
|
||||
}
|
||||
|
||||
MediaStreamGraphImpl::MediaStreamGraphImpl(bool aRealtime,
|
||||
MediaStreamGraphImpl::MediaStreamGraphImpl(GraphDriverType aDriverRequested,
|
||||
TrackRate aSampleRate,
|
||||
bool aStartWithAudioDriver,
|
||||
dom::AudioChannel aChannel)
|
||||
: MediaStreamGraph(aSampleRate)
|
||||
, mPortCount(0)
|
||||
|
@ -2882,7 +2881,7 @@ MediaStreamGraphImpl::MediaStreamGraphImpl(bool aRealtime,
|
|||
, mFlushSourcesOnNextIteration(false)
|
||||
, mDetectedNotRunning(false)
|
||||
, mPostedRunInStableState(false)
|
||||
, mRealtime(aRealtime)
|
||||
, mRealtime(aDriverRequested != OFFLINE_THREAD_DRIVER)
|
||||
, mNonRealtimeProcessing(false)
|
||||
, mStreamOrderDirty(false)
|
||||
, mLatencyLog(AsyncLatencyLogger::Get())
|
||||
|
@ -2903,7 +2902,7 @@ MediaStreamGraphImpl::MediaStreamGraphImpl(bool aRealtime,
|
|||
}
|
||||
|
||||
if (mRealtime) {
|
||||
if (aStartWithAudioDriver) {
|
||||
if (aDriverRequested == AUDIO_THREAD_DRIVER) {
|
||||
AudioCallbackDriver* driver = new AudioCallbackDriver(this, aChannel);
|
||||
mDriver = driver;
|
||||
mMixer.AddCallback(driver);
|
||||
|
@ -2960,7 +2959,7 @@ MediaStreamGraphShutdownObserver::Observe(nsISupports *aSubject,
|
|||
}
|
||||
|
||||
MediaStreamGraph*
|
||||
MediaStreamGraph::GetInstance(bool aStartWithAudioDriver,
|
||||
MediaStreamGraph::GetInstance(MediaStreamGraph::GraphDriverType aGraphDriverRequested,
|
||||
dom::AudioChannel aChannel)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Main thread only");
|
||||
|
@ -2976,10 +2975,15 @@ MediaStreamGraph::GetInstance(bool aStartWithAudioDriver,
|
|||
|
||||
CubebUtils::InitPreferredSampleRate();
|
||||
|
||||
graph = new MediaStreamGraphImpl(true, CubebUtils::PreferredSampleRate(), aStartWithAudioDriver, aChannel);
|
||||
graph = new MediaStreamGraphImpl(aGraphDriverRequested,
|
||||
CubebUtils::PreferredSampleRate(),
|
||||
aChannel);
|
||||
|
||||
gGraphs.Put(channel, graph);
|
||||
|
||||
STREAM_LOG(LogLevel::Debug, ("Starting up MediaStreamGraph %p", graph));
|
||||
STREAM_LOG(LogLevel::Debug,
|
||||
("Starting up MediaStreamGraph %p for channel %s",
|
||||
graph, AudioChannelValues::strings[channel]));
|
||||
}
|
||||
|
||||
return graph;
|
||||
|
@ -2990,7 +2994,10 @@ MediaStreamGraph::CreateNonRealtimeInstance(TrackRate aSampleRate)
|
|||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Main thread only");
|
||||
|
||||
MediaStreamGraphImpl* graph = new MediaStreamGraphImpl(false, aSampleRate);
|
||||
MediaStreamGraphImpl* graph =
|
||||
new MediaStreamGraphImpl(OFFLINE_THREAD_DRIVER,
|
||||
aSampleRate,
|
||||
AudioChannel::Normal);
|
||||
|
||||
STREAM_LOG(LogLevel::Debug, ("Starting up Offline MediaStreamGraph %p", graph));
|
||||
|
||||
|
|
|
@ -1195,22 +1195,33 @@ protected:
|
|||
};
|
||||
|
||||
/**
|
||||
* Initially, at least, we will have a singleton MediaStreamGraph per
|
||||
* process. Each OfflineAudioContext object creates its own MediaStreamGraph
|
||||
* object too.
|
||||
* There can be multiple MediaStreamGraph per process: one per AudioChannel.
|
||||
* Additionaly, each OfflineAudioContext object creates its own MediaStreamGraph
|
||||
* object too..
|
||||
*/
|
||||
class MediaStreamGraph
|
||||
{
|
||||
public:
|
||||
|
||||
// We ensure that the graph current time advances in multiples of
|
||||
// IdealAudioBlockSize()/AudioStream::PreferredSampleRate(). A stream that
|
||||
// never blocks and has a track with the ideal audio rate will produce audio
|
||||
// in multiples of the block size.
|
||||
//
|
||||
|
||||
// Initializing an graph that outputs audio can be quite long on some
|
||||
// platforms. Code that want to output audio at some point can express the
|
||||
// fact that they will need an audio stream at some point by passing
|
||||
// AUDIO_THREAD_DRIVER when getting an instance of MediaStreamGraph, so that
|
||||
// the graph starts with the right driver.
|
||||
enum GraphDriverType {
|
||||
AUDIO_THREAD_DRIVER,
|
||||
SYSTEM_THREAD_DRIVER,
|
||||
OFFLINE_THREAD_DRIVER
|
||||
};
|
||||
// Main thread only
|
||||
static MediaStreamGraph* GetInstance(bool aStartWithAudioDriver = false,
|
||||
dom::AudioChannel aChannel = dom::AudioChannel::Normal);
|
||||
static MediaStreamGraph* GetInstance(GraphDriverType aGraphDriverRequested,
|
||||
dom::AudioChannel aChannel);
|
||||
static MediaStreamGraph* CreateNonRealtimeInstance(TrackRate aSampleRate);
|
||||
// Idempotent
|
||||
static void DestroyNonRealtimeInstance(MediaStreamGraph* aGraph);
|
||||
|
|
|
@ -93,16 +93,16 @@ public:
|
|||
NS_DECL_NSIMEMORYREPORTER
|
||||
|
||||
/**
|
||||
* Set aRealtime to true in order to create a MediaStreamGraph which provides
|
||||
* support for real-time audio and video. Set it to false in order to create
|
||||
* a non-realtime instance which just churns through its inputs and produces
|
||||
* output. Those objects currently only support audio, and are used to
|
||||
* implement OfflineAudioContext. They do not support MediaStream inputs.
|
||||
* Use aGraphDriverRequested with SYSTEM_THREAD_DRIVER or AUDIO_THREAD_DRIVER
|
||||
* to create a MediaStreamGraph which provides support for real-time audio
|
||||
* and/or video. Set it to false in order to create a non-realtime instance
|
||||
* which just churns through its inputs and produces output. Those objects
|
||||
* currently only support audio, and are used to implement
|
||||
* OfflineAudioContext. They do not support MediaStream inputs.
|
||||
*/
|
||||
explicit MediaStreamGraphImpl(bool aRealtime,
|
||||
explicit MediaStreamGraphImpl(GraphDriverType aGraphDriverRequested,
|
||||
TrackRate aSampleRate,
|
||||
bool aStartWithAudioDriver = false,
|
||||
dom::AudioChannel aChannel = dom::AudioChannel::Normal);
|
||||
dom::AudioChannel aChannel);
|
||||
|
||||
/**
|
||||
* Unregisters memory reporting and deletes this instance. This should be
|
||||
|
|
Загрузка…
Ссылка в новой задаче