Bug 1302027 - enable rust log when MP4Metadata prlog is set. r=kinetik
authorAlfredo.Yang <ayang@mozilla.com>
Thu, 29 Dec 2016 14:56:34 +0800
changeset 377546 d6d0f8b6e78d5913a6414ffd99db30ad4b8cb1e2
parent 377545 f94d77b18a09bd6f9835091280b8acc65a10907d
child 377547 17f52807a3169be83050845352d8b27d9eb693e2
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskinetik
bugs1302027
milestone53.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1302027 - enable rust log when MP4Metadata prlog is set. r=kinetik MozReview-Commit-ID: 7avZ5T4XKDY
media/libstagefright/binding/MP4Metadata.cpp
--- a/media/libstagefright/binding/MP4Metadata.cpp
+++ b/media/libstagefright/binding/MP4Metadata.cpp
@@ -30,16 +30,18 @@
 struct FreeMP4Parser { void operator()(mp4parse_parser* aPtr) { mp4parse_free(aPtr); } };
 #endif
 
 using namespace stagefright;
 
 namespace mp4_demuxer
 {
 
+static LazyLogModule sLog("MP4Metadata");
+
 class DataSourceAdapter : public DataSource
 {
 public:
   explicit DataSourceAdapter(Stream* aSource) : mSource(aSource) {}
 
   ~DataSourceAdapter() {}
 
   virtual status_t initCheck() const { return NO_ERROR; }
@@ -192,18 +194,16 @@ TrackTypeToString(mozilla::TrackInfo::Tr
   default:
     return "unknown";
   }
 }
 
 uint32_t
 MP4Metadata::GetNumberTracks(mozilla::TrackInfo::TrackType aType) const
 {
-  static LazyLogModule sLog("MP4Metadata");
-
   uint32_t numTracks = mStagefright->GetNumberTracks(aType);
 
 #ifdef MOZ_RUST_MP4PARSE
   if (!mRust) {
     return numTracks;
   }
 
   uint32_t numTracksRust = mRust->GetNumberTracks(aType);
@@ -611,17 +611,16 @@ MP4MetadataStagefright::Metadata(Stream*
   return parser->Metadata();
 }
 
 #ifdef MOZ_RUST_MP4PARSE
 bool
 RustStreamAdaptor::Read(uint8_t* buffer, uintptr_t size, size_t* bytes_read)
 {
   if (!mOffset.isValid()) {
-    static LazyLogModule sLog("MP4Metadata");
     MOZ_LOG(sLog, LogLevel::Error, ("Overflow in source stream offset"));
     return false;
   }
   bool rv = mSource->ReadAt(mOffset.value(), buffer, size, bytes_read);
   if (rv) {
     mOffset += *bytes_read;
   }
   return rv;
@@ -633,32 +632,34 @@ read_source(uint8_t* buffer, uintptr_t s
 {
   MOZ_ASSERT(buffer);
   MOZ_ASSERT(userdata);
 
   auto source = reinterpret_cast<RustStreamAdaptor*>(userdata);
   size_t bytes_read = 0;
   bool rv = source->Read(buffer, size, &bytes_read);
   if (!rv) {
-    static LazyLogModule sLog("MP4Metadata");
     MOZ_LOG(sLog, LogLevel::Warning, ("Error reading source data"));
     return -1;
   }
   return bytes_read;
 }
 
 MP4MetadataRust::MP4MetadataRust(Stream* aSource)
   : mSource(aSource)
   , mRustSource(aSource)
 {
   mp4parse_io io = { read_source, &mRustSource };
   mRustParser.reset(mp4parse_new(&io));
   MOZ_ASSERT(mRustParser);
 
-  static LazyLogModule sLog("MP4Metadata");
+  if (MOZ_LOG_TEST(sLog, LogLevel::Debug)) {
+    mp4parse_log(true);
+  }
+
   mp4parse_error rv = mp4parse_read(mRustParser.get());
   MOZ_LOG(sLog, LogLevel::Debug, ("rust parser returned %d\n", rv));
   Telemetry::Accumulate(Telemetry::MEDIA_RUST_MP4PARSE_SUCCESS,
                         rv == MP4PARSE_OK);
   if (rv != MP4PARSE_OK) {
     MOZ_ASSERT(rv > 0);
     Telemetry::Accumulate(Telemetry::MEDIA_RUST_MP4PARSE_ERROR_CODE, rv);
   }
@@ -696,18 +697,16 @@ TrackTypeEqual(TrackInfo::TrackType aLHS
   default:
     return false;
   }
 }
 
 uint32_t
 MP4MetadataRust::GetNumberTracks(mozilla::TrackInfo::TrackType aType) const
 {
-  static LazyLogModule sLog("MP4Metadata");
-
   uint32_t tracks;
   auto rv = mp4parse_get_track_count(mRustParser.get(), &tracks);
   if (rv != MP4PARSE_OK) {
     MOZ_LOG(sLog, LogLevel::Warning,
         ("rust parser error %d counting tracks", rv));
     return 0;
   }
   MOZ_LOG(sLog, LogLevel::Info, ("rust parser found %u tracks", tracks));
@@ -757,18 +756,16 @@ MP4MetadataRust::TrackTypeToGlobalTrackI
 
   return Nothing();
 }
 
 mozilla::UniquePtr<mozilla::TrackInfo>
 MP4MetadataRust::GetTrackInfo(mozilla::TrackInfo::TrackType aType,
                               size_t aTrackNumber) const
 {
-  static LazyLogModule sLog("MP4Metadata");
-
   Maybe<uint32_t> trackIndex = TrackTypeToGlobalTrackIndex(aType, aTrackNumber);
   if (trackIndex.isNothing()) {
     return nullptr;
   }
 
   mp4parse_track_info info;
   auto rv = mp4parse_get_track_info(mRustParser.get(), trackIndex.value(), &info);
   if (rv != MP4PARSE_OK) {