Bug 1346005: add audio samples-inserted logging using AudioLatency:4 r=padenot

MozReview-Commit-ID: JZukIfjapuy
This commit is contained in:
Randell Jesup 2017-03-10 15:22:42 -05:00
parent 1f276e17d9
commit 269eb591be
3 changed files with 30 additions and 0 deletions

View File

@ -573,6 +573,8 @@ private:
nsCString mDeviceUUID;
int32_t mSampleFrequency;
uint64_t mTotalFrames;
uint64_t mLastLogFrames;
int32_t mPlayoutDelay;
NullTransport *mNullTransport;

View File

@ -40,6 +40,11 @@ extern LogModule* GetMediaManagerLog();
#define LOG(msg) MOZ_LOG(GetMediaManagerLog(), mozilla::LogLevel::Debug, msg)
#define LOG_FRAMES(msg) MOZ_LOG(GetMediaManagerLog(), mozilla::LogLevel::Verbose, msg)
LogModule* AudioLogModule() {
static mozilla::LazyLogModule log("AudioLatency");
return static_cast<LogModule*>(log);
}
/**
* Webrtc microphone source source.
*/
@ -198,6 +203,8 @@ MediaEngineWebRTCMicrophoneSource::MediaEngineWebRTCMicrophoneSource(
, mTrackID(TRACK_NONE)
, mStarted(false)
, mSampleFrequency(MediaEngine::DEFAULT_SAMPLE_RATE)
, mTotalFrames(0)
, mLastLogFrames(0)
, mPlayoutDelay(0)
, mNullTransport(nullptr)
, mSkipProcessing(false)
@ -578,6 +585,16 @@ MediaEngineWebRTCMicrophoneSource::InsertInGraph(const T* aBuffer,
return;
}
if (MOZ_LOG_TEST(AudioLogModule(), LogLevel::Debug)) {
mTotalFrames += aFrames;
if (mTotalFrames > mLastLogFrames + mSampleFrequency) { // ~ 1 second
MOZ_LOG(AudioLogModule(), LogLevel::Debug,
("%p: Inserting %" PRIuSIZE " samples into graph, total frames = %" PRIu64,
(void*)this, aFrames, mTotalFrames));
mLastLogFrames = mTotalFrames;
}
}
size_t len = mSources.Length();
for (size_t i = 0; i < len; i++) {
if (!mSources[i]) {

View File

@ -72,6 +72,7 @@ using namespace mozilla::layers;
MOZ_MTLOG_MODULE("mediapipeline")
namespace mozilla {
extern mozilla::LogModule* AudioLogModule();
class VideoConverterListener
{
@ -1839,6 +1840,7 @@ class GenericReceiveListener : public MediaStreamListener
: source_(source),
track_id_(track_id),
played_ticks_(0),
last_log_(0),
principal_handle_(PRINCIPAL_HANDLE_NONE) {}
virtual ~GenericReceiveListener() {}
@ -1888,6 +1890,7 @@ class GenericReceiveListener : public MediaStreamListener
SourceMediaStream *source_;
const TrackID track_id_;
TrackTicks played_ticks_;
TrackTicks last_log_; // played_ticks_ when we last logged
PrincipalHandle principal_handle_;
};
@ -2014,6 +2017,14 @@ public:
// Handle track not actually added yet or removed/finished
if (source_->AppendToTrack(track_id_, &segment)) {
played_ticks_ += frames;
if (MOZ_LOG_TEST(AudioLogModule(), LogLevel::Debug)) {
if (played_ticks_ > last_log_ + WEBRTC_DEFAULT_SAMPLE_RATE) { // ~ 1 second
MOZ_LOG(AudioLogModule(), LogLevel::Debug,
("%p: Inserting %" PRIuSIZE " samples into track %d, total = %" PRIu64,
(void*) this, frames, track_id_, played_ticks_));
last_log_ = played_ticks_;
}
}
} else {
MOZ_MTLOG(ML_ERROR, "AppendToTrack failed");
// we can't un-read the data, but that's ok since we don't want to