Bug 1425150 - Register AudioCallbackDriver to the Gecko Profiler. r=jya

MozReview-Commit-ID: 3rJbF8Kq0zx

--HG--
extra : rebase_source : 49719ea92da9c1c556b1c3d10a06d3f2cdc3b08f
This commit is contained in:
Paul Adenot 2017-12-13 17:10:14 -06:00
Родитель 5993dad148
Коммит 17ca0b45f8
2 изменённых файлов: 17 добавлений и 0 удалений

Просмотреть файл

@ -539,6 +539,7 @@ AudioCallbackDriver::AudioCallbackDriver(MediaStreamGraphImpl* aGraphImpl)
, mMicrophoneActive(false)
, mShouldFallbackIfError(false)
, mFromFallback(false)
, mProfilerRegistered(false)
{
LOG(LogLevel::Debug, ("AudioCallbackDriver ctor for graph %p", aGraphImpl));
#if defined(XP_WIN)
@ -897,6 +898,11 @@ AudioCallbackDriver::DataCallback(const AudioDataValue* aInputBuffer,
AutoInCallback aic(this);
#endif
if (!mProfilerRegistered) {
mProfilerRegistered = true;
PROFILER_REGISTER_THREAD("AudioCallback");
}
GraphTime stateComputedTime = StateComputedTime();
if (stateComputedTime == 0) {
MonitorAutoLock mon(mGraphImpl->GetMonitor());
@ -1002,6 +1008,8 @@ AudioCallbackDriver::DataCallback(const AudioDataValue* aInputBuffer,
// Enter shutdown mode. The stable-state handler will detect this
// and complete shutdown if the graph does not get restarted.
mGraphImpl->SignalMainThreadCleanup();
PROFILER_UNREGISTER_THREAD();
return aFrames - 1;
}
@ -1024,6 +1032,7 @@ AudioCallbackDriver::DataCallback(const AudioDataValue* aInputBuffer,
NextDriver()->SetGraphTime(this, mIterationStart, mIterationEnd);
mGraphImpl->SetCurrentDriver(NextDriver());
NextDriver()->Start();
PROFILER_UNREGISTER_THREAD();
// Returning less than aFrames starts the draining and eventually stops the
// audio thread. This function will never get called again.
return aFrames - 1;
@ -1115,6 +1124,8 @@ AudioCallbackDriver::DeviceChangedCallback() {
#ifdef XP_MACOSX
PanOutputIfNeeded(mMicrophoneActive);
#endif
mProfilerRegistered = false;
}
void

Просмотреть файл

@ -566,6 +566,12 @@ private:
/* True if this driver was created from a driver created because of a previous
* AudioCallbackDriver failure. */
bool mFromFallback;
/* Whether or not the Gecko profiler has been registered for this thread.
* We reset this on device change, because the underlying thread is going to
* change.
* We de-register on the last iteration, and re-register on the first
* iteration of a new driver. */
Atomic<bool> mProfilerRegistered;
};
class AsyncCubebTask : public Runnable