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
Родитель e078579f28
Коммит ed0d72a181
3 изменённых файлов: 31 добавлений и 0 удалений

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

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

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

@ -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]) {

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

@ -50,6 +50,7 @@
#include "mozilla/UniquePtr.h"
#include "mozilla/UniquePtrExtensions.h"
#include "mozilla/Sprintf.h"
#include "mozilla/SizePrintfMacros.h"
#include "webrtc/common_types.h"
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
@ -72,6 +73,7 @@ using namespace mozilla::layers;
MOZ_MTLOG_MODULE("mediapipeline")
namespace mozilla {
extern mozilla::LogModule* AudioLogModule();
class VideoConverterListener
{
@ -1839,6 +1841,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 +1891,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 +2018,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