Bug 1402206 - print error name for MediaFormatReader::OnSeekFailed(). r=jya
authorAlastor Wu <alwu@mozilla.com>
Fri, 22 Sep 2017 16:23:08 +0800
changeset 669068 0916366739b8bec395ded258ec7e4fe0a9e54b81
parent 669067 d2a032f9e2561bfd3baaac404a9eb4c124051266
child 669069 824ab640450f90672bddbfc80b7f4984b975a1a2
push id81210
push userkgupta@mozilla.com
push dateFri, 22 Sep 2017 14:09:59 +0000
reviewersjya
bugs1402206
milestone58.0a1
Bug 1402206 - print error name for MediaFormatReader::OnSeekFailed(). r=jya Print error code couldn't effectively help people understand the reason of error, we should print its name. MozReview-Commit-ID: KaBTi8zpq91
dom/media/MediaFormatReader.cpp
dom/media/MediaResult.h
--- a/dom/media/MediaFormatReader.cpp
+++ b/dom/media/MediaFormatReader.cpp
@@ -2818,17 +2818,17 @@ MediaFormatReader::AttemptSeek()
     MOZ_CRASH();
   }
 }
 
 void
 MediaFormatReader::OnSeekFailed(TrackType aTrack, const MediaResult& aError)
 {
   MOZ_ASSERT(OnTaskQueue());
-  LOGV("%s failure:%" PRIu32, TrackTypeToStr(aTrack), static_cast<uint32_t>(aError.Code()));
+  LOGV("%s failure:%s" PRIu32, TrackTypeToStr(aTrack), aError.ErrorName().get());
   if (aTrack == TrackType::kVideoTrack) {
     mVideo.mSeekRequest.Complete();
   } else {
     mAudio.mSeekRequest.Complete();
   }
 
   if (aError == NS_ERROR_DOM_MEDIA_WAITING_FOR_DATA) {
     if (HasVideo() &&
--- a/dom/media/MediaResult.h
+++ b/dom/media/MediaResult.h
@@ -37,30 +37,37 @@ public:
   {
   }
   MediaResult(const MediaResult& aOther) = default;
   MediaResult(MediaResult&& aOther) = default;
   MediaResult& operator=(const MediaResult& aOther) = default;
   MediaResult& operator=(MediaResult&& aOther) = default;
 
   nsresult Code() const { return mCode; }
+  nsCString ErrorName() const
+  {
+    nsCString name;
+    GetErrorName(mCode, name);
+    return name;
+  }
+
   const nsCString& Message() const { return mMessage; }
 
   // Interoperations with nsresult.
   bool operator==(nsresult aResult) const { return aResult == mCode; }
   bool operator!=(nsresult aResult) const { return aResult != mCode; }
   operator nsresult () const { return mCode; }
 
   nsCString Description() const
   {
     if (NS_SUCCEEDED(mCode)) {
       return nsCString();
     }
     nsCString name;
-    GetErrorName(mCode, static_cast<nsACString&>(name));
+    GetErrorName(mCode, name);
     return nsPrintfCString("%s (0x%08" PRIx32 ")%s%s",
                            name.get(),
                            static_cast<uint32_t>(mCode),
                            mMessage.IsEmpty() ? "" : " - ",
                            mMessage.get());
   }
 
   void SetGPUCrashTimeStamp(const TimeStamp& aTime) { mGPUCrashTimeStamp = aTime; }