Bug 1006641: add telemetry for AudioStream open times r=jib

This commit is contained in:
Randell Jesup 2014-06-04 14:52:32 -04:00
Родитель a02f87eea0
Коммит 7683f60604
3 изменённых файлов: 38 добавлений и 0 удалений

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

@ -13,6 +13,7 @@
#include "mozilla/Mutex.h"
#include <algorithm>
#include "mozilla/Preferences.h"
#include "mozilla/Telemetry.h"
#include "soundtouch/SoundTouch.h"
#include "Latency.h"
@ -72,6 +73,16 @@ bool AudioStream::sCubebLatencyPrefSet;
}
}
/*static*/ bool AudioStream::GetFirstStream()
{
static bool sFirstStream = true;
StaticMutexAutoLock lock(sMutex);
bool result = sFirstStream;
sFirstStream = false;
return result;
}
/*static*/ double AudioStream::GetVolumeScale()
{
StaticMutexAutoLock lock(sMutex);
@ -384,6 +395,9 @@ AudioStream::Init(int32_t aNumChannels, int32_t aRate,
const dom::AudioChannel aAudioChannel,
LatencyRequest aLatencyRequest)
{
mStartTime = TimeStamp::Now();
mIsFirst = GetFirstStream();
if (!GetCubebContext() || aNumChannels < 0 || aRate < 0) {
return NS_ERROR_FAILURE;
}
@ -494,6 +508,14 @@ AudioStream::OpenCubeb(cubeb_stream_params &aParams,
}
}
if (!mStartTime.IsNull()) {
TimeDuration timeDelta = TimeStamp::Now() - mStartTime;
LOG(("AudioStream creation time %sfirst: %u ms", mIsFirst ? "" : "not ",
(uint32_t) timeDelta.ToMilliseconds()));
Telemetry::Accumulate(mIsFirst ? Telemetry::AUDIOSTREAM_FIRST_OPEN_MS :
Telemetry::AUDIOSTREAM_LATER_OPEN_MS, timeDelta.ToMilliseconds());
}
return NS_OK;
}

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

@ -307,6 +307,7 @@ private:
static void PrefChanged(const char* aPref, void* aClosure);
static double GetVolumeScale();
static bool GetFirstStream();
static cubeb* GetCubebContext();
static cubeb* GetCubebContextUnlocked();
static uint32_t GetCubebLatency();
@ -423,6 +424,7 @@ private:
StreamState mState;
bool mNeedsStart; // needed in case Start() is called before cubeb is open
bool mIsFirst;
// This mutex protects the static members below.
static StaticMutex sMutex;

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

@ -50,6 +50,20 @@
"kind": "boolean",
"description": "Application reputation query count (both local and remote)"
},
"AUDIOSTREAM_FIRST_OPEN_MS": {
"expires_in_version": "never",
"kind": "exponential",
"high": "10000",
"n_buckets": "50",
"description": "The length of time (in milliseconds) for the first open of AudioStream."
},
"AUDIOSTREAM_LATER_OPEN_MS": {
"expires_in_version": "never",
"kind": "exponential",
"high": "10000",
"n_buckets": "50",
"description": "The length of time (in milliseconds) for the subsequent opens of AudioStream."
},
"BACKGROUNDFILESAVER_THREAD_COUNT": {
"expires_in_version": "never",
"kind": "enumerated",