Merge "Finer synchronization for nuplayer stats"

gugelfrei
Ray Essick 5 years ago committed by Android (Google) Code Review
commit c4871a8abe

@ -106,16 +106,17 @@ NuPlayer::Decoder::~Decoder() {
releaseAndResetMediaBuffers();
}
sp<AMessage> NuPlayer::Decoder::getStats() const {
sp<AMessage> NuPlayer::Decoder::getStats() {
Mutex::Autolock autolock(mStatsLock);
mStats->setInt64("frames-total", mNumFramesTotal);
mStats->setInt64("frames-dropped-input", mNumInputFramesDropped);
mStats->setInt64("frames-dropped-output", mNumOutputFramesDropped);
mStats->setFloat("frame-rate-total", mFrameRateTotal);
// i'm mutexed right now.
// make our own copy, so we aren't victim to any later changes.
sp<AMessage> copiedStats = mStats->dup();
return copiedStats;
}
@ -362,13 +363,17 @@ void NuPlayer::Decoder::onConfigure(const sp<AMessage> &format) {
CHECK_EQ((status_t)OK, mCodec->getOutputFormat(&mOutputFormat));
CHECK_EQ((status_t)OK, mCodec->getInputFormat(&mInputFormat));
mStats->setString("mime", mime.c_str());
mStats->setString("component-name", mComponentName.c_str());
{
Mutex::Autolock autolock(mStatsLock);
mStats->setString("mime", mime.c_str());
mStats->setString("component-name", mComponentName.c_str());
}
if (!mIsAudio) {
int32_t width, height;
if (mOutputFormat->findInt32("width", &width)
&& mOutputFormat->findInt32("height", &height)) {
Mutex::Autolock autolock(mStatsLock);
mStats->setInt32("width", width);
mStats->setInt32("height", height);
}
@ -799,6 +804,7 @@ void NuPlayer::Decoder::handleOutputFormatChange(const sp<AMessage> &format) {
int32_t width, height;
if (format->findInt32("width", &width)
&& format->findInt32("height", &height)) {
Mutex::Autolock autolock(mStatsLock);
mStats->setInt32("width", width);
mStats->setInt32("height", height);
}

@ -34,7 +34,7 @@ struct NuPlayer::Decoder : public DecoderBase {
const sp<Surface> &surface = NULL,
const sp<CCDecoder> &ccDecoder = NULL);
virtual sp<AMessage> getStats() const;
virtual sp<AMessage> getStats();
// sets the output surface of video decoders.
virtual status_t setVideoSurface(const sp<Surface> &surface);

@ -47,7 +47,7 @@ struct NuPlayer::DecoderBase : public AHandler {
void signalResume(bool notifyComplete);
void initiateShutdown();
virtual sp<AMessage> getStats() const {
virtual sp<AMessage> getStats() {
return mStats;
}
@ -88,6 +88,7 @@ protected:
int32_t mBufferGeneration;
bool mPaused;
sp<AMessage> mStats;
Mutex mStatsLock;
private:
enum {

Loading…
Cancel
Save