mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-13 21:35:39 +00:00
Bug 848954 - Part 9 - Allow to pass in hints when getting a reference to a MediaStreamGraph to get the right driver started as soon as possible. r=roc
This is useful because some platform have rather slow audio stream initialization time, especially the first time an audio stream is created for the process. We put in telemetry probes to measure that: First stream opened for the process: http://telemetry.mozilla.org/#filter=nightly%2F33%2FAUDIOSTREAM_FIRST_OPEN_MS&aggregates=multiselect-all!Submissions!Mean!5th%20percentile!25th%20percentile!median!75th%20percentile!95th%20percentile&evoOver=Builds&locked=true&sanitize=true&renderhistogram=Graph Subsequent streams: http://telemetry.mozilla.org/#filter=nightly%2F33%2FAUDIOSTREAM_LATER_OPEN_MS&aggregates=multiselect-all!Submissions!Mean!5th%20percentile!25th%20percentile!median!75th%20percentile!95th%20percentile&evoOver=Builds&locked=true&sanitize=true&renderhistogram=Graph
This commit is contained in:
parent
499c632d13
commit
64e239b778
@ -32,6 +32,11 @@
|
||||
#undef None
|
||||
#endif
|
||||
|
||||
// X.h on Linux #defines CurrentTime as 0L, so we have to #undef it here.
|
||||
#ifdef CurrentTime
|
||||
#undef CurrentTime
|
||||
#endif
|
||||
|
||||
#include "mozilla/dom/HTMLMediaElementBinding.h"
|
||||
|
||||
// Define to output information on decoding and painting framerate
|
||||
|
@ -219,7 +219,7 @@ DOMMediaStream::InitSourceStream(nsIDOMWindow* aWindow, TrackTypeHints aHintCont
|
||||
{
|
||||
mWindow = aWindow;
|
||||
SetHintContents(aHintContents);
|
||||
MediaStreamGraph* gm = MediaStreamGraph::GetInstance();
|
||||
MediaStreamGraph* gm = MediaStreamGraph::GetInstance(aHintContents);
|
||||
InitStreamCommon(gm->CreateSourceStream(this));
|
||||
}
|
||||
|
||||
@ -228,7 +228,7 @@ DOMMediaStream::InitTrackUnionStream(nsIDOMWindow* aWindow, TrackTypeHints aHint
|
||||
{
|
||||
mWindow = aWindow;
|
||||
SetHintContents(aHintContents);
|
||||
MediaStreamGraph* gm = MediaStreamGraph::GetInstance();
|
||||
MediaStreamGraph* gm = MediaStreamGraph::GetInstance(aHintContents);
|
||||
InitStreamCommon(gm->CreateTrackUnionStream(this));
|
||||
}
|
||||
|
||||
|
@ -159,7 +159,8 @@ public:
|
||||
// Indicate what track types we eventually expect to add to this stream
|
||||
enum {
|
||||
HINT_CONTENTS_AUDIO = 1 << 0,
|
||||
HINT_CONTENTS_VIDEO = 1 << 1
|
||||
HINT_CONTENTS_VIDEO = 1 << 1,
|
||||
HINT_CONTENTS_UNKNOWN = 1 << 2
|
||||
};
|
||||
TrackTypeHints GetHintContents() const { return mHintContents; }
|
||||
void SetHintContents(TrackTypeHints aHintContents) { mHintContents = aHintContents; }
|
||||
|
@ -2640,7 +2640,9 @@ ProcessedMediaStream::DestroyImpl()
|
||||
// SetStreamOrderDirty(), for other reasons.
|
||||
}
|
||||
|
||||
MediaStreamGraphImpl::MediaStreamGraphImpl(bool aRealtime, TrackRate aSampleRate)
|
||||
MediaStreamGraphImpl::MediaStreamGraphImpl(bool aRealtime,
|
||||
TrackRate aSampleRate,
|
||||
DOMMediaStream::TrackTypeHints aHint= DOMMediaStream::HINT_CONTENTS_UNKNOWN)
|
||||
: mDriverHolder(MOZ_THIS_IN_INITIALIZER_LIST())
|
||||
, mProcessingGraphUpdateIndex(0)
|
||||
, mPortCount(0)
|
||||
@ -2672,10 +2674,10 @@ MediaStreamGraphImpl::MediaStreamGraphImpl(bool aRealtime, TrackRate aSampleRate
|
||||
#endif
|
||||
|
||||
if (mRealtime) {
|
||||
// Always start with a system clock driver when creating a realtime graph: we
|
||||
// don't know if this graph will ever be used for audio.
|
||||
printf("New Graph, using a SystemClockDriver %p\n", this);
|
||||
mDriverHolder.Switch(new SystemClockDriver(this));
|
||||
} else {
|
||||
printf("New Graph, using a OfflineClockDriver %p\n", this);
|
||||
mDriverHolder.Switch(new OfflineClockDriver(this, MEDIA_GRAPH_TARGET_PERIOD_MS));
|
||||
}
|
||||
|
||||
@ -2716,7 +2718,7 @@ MediaStreamGraphShutdownObserver::Observe(nsISupports *aSubject,
|
||||
}
|
||||
|
||||
MediaStreamGraph*
|
||||
MediaStreamGraph::GetInstance()
|
||||
MediaStreamGraph::GetInstance(DOMMediaStream::TrackTypeHints aHint)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Main thread only");
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "GraphDriver.h"
|
||||
#include <speex/speex_resampler.h>
|
||||
#include "mozilla/dom/AudioChannelBinding.h"
|
||||
#include "DOMMediaStream.h"
|
||||
|
||||
class nsIRunnable;
|
||||
|
||||
@ -32,8 +33,6 @@ class nsAutoRefTraits<SpeexResamplerState> : public nsPointerRefTraits<SpeexResa
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class DOMMediaStream;
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
extern PRLogModuleInfo* gMediaStreamGraphLog;
|
||||
#endif
|
||||
@ -1127,9 +1126,10 @@ public:
|
||||
// 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.
|
||||
//
|
||||
|
||||
// Main thread only
|
||||
static MediaStreamGraph* GetInstance();
|
||||
static MediaStreamGraph* GetInstance(DOMMediaStream::TrackTypeHints aHint = DOMMediaStream::HINT_CONTENTS_UNKNOWN);
|
||||
static MediaStreamGraph* CreateNonRealtimeInstance(TrackRate aSampleRate);
|
||||
// Idempotent
|
||||
static void DestroyNonRealtimeInstance(MediaStreamGraph* aGraph);
|
||||
|
@ -128,7 +128,7 @@ public:
|
||||
* output. Those objects currently only support audio, and are used to
|
||||
* implement OfflineAudioContext. They do not support MediaStream inputs.
|
||||
*/
|
||||
explicit MediaStreamGraphImpl(bool aRealtime, TrackRate aSampleRate);
|
||||
explicit MediaStreamGraphImpl(bool aRealtime, TrackRate aSampleRate, DOMMediaStream::TrackTypeHints aHint);
|
||||
|
||||
/**
|
||||
* Unregisters memory reporting and deletes this instance. This should be
|
||||
|
@ -322,7 +322,7 @@ AudioDestinationNode::AudioDestinationNode(AudioContext* aContext,
|
||||
{
|
||||
MediaStreamGraph* graph = aIsOffline ?
|
||||
MediaStreamGraph::CreateNonRealtimeInstance(aSampleRate) :
|
||||
MediaStreamGraph::GetInstance();
|
||||
MediaStreamGraph::GetInstance(DOMMediaStream::HINT_CONTENTS_AUDIO);
|
||||
AudioNodeEngine* engine = aIsOffline ?
|
||||
new OfflineDestinationNodeEngine(this, aNumberOfChannels,
|
||||
aLength, aSampleRate) :
|
||||
|
Loading…
Reference in New Issue
Block a user