Bug 1316205: P3. Remove WaveDecoder::IsEnable(). r?gerald draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Thu, 10 Nov 2016 11:53:07 +1100
changeset 436898 32e5628e4ccc97c71277f323f5be84dd1380ad18
parent 435722 04974697f144352f7b65d05759bb4295351c0075
child 536476 3de682549bc0a3b5e5003febbde158833e10cf85
push id35236
push userbmo:jyavenard@mozilla.com
push dateThu, 10 Nov 2016 01:08:34 +0000
reviewersgerald
bugs1316205
milestone52.0a1
Bug 1316205: P3. Remove WaveDecoder::IsEnable(). r?gerald It would always return true, and there's already a MediaDecoder::IsWaveEnabled() MozReview-Commit-ID: 6FXgMRMnVb9
dom/media/wave/WaveDecoder.cpp
dom/media/wave/WaveDecoder.h
--- a/dom/media/wave/WaveDecoder.cpp
+++ b/dom/media/wave/WaveDecoder.cpp
@@ -22,33 +22,24 @@ MediaDecoderStateMachine*
 WaveDecoder::CreateStateMachine()
 {
   return new MediaDecoderStateMachine(
     this, new MediaFormatReader(this, new WAVDemuxer(GetResource())));
 }
 
 /* static */
 bool
-WaveDecoder::IsEnabled()
-{
-  MOZ_ASSERT(NS_IsMainThread());
-  RefPtr<PDMFactory> platform = new PDMFactory();
-  return platform->SupportsMimeType(NS_LITERAL_CSTRING("audio/x-wav"),
-                                    /* DecoderDoctorDiagnostics* */ nullptr);
-}
-
-/* static */
-bool
 WaveDecoder::CanHandleMediaType(const nsACString& aType,
                                 const nsAString& aCodecs)
 {
+  if (!IsWaveEnabled()) {
+    return false;
+  }
   if (aType.EqualsASCII("audio/wave") || aType.EqualsASCII("audio/x-wav") ||
       aType.EqualsASCII("audio/wav")  || aType.EqualsASCII("audio/x-pn-wav")) {
-    return IsEnabled() && (aCodecs.IsEmpty() ||
-                           aCodecs.EqualsASCII("1") ||
-                           aCodecs.EqualsASCII("6") ||
-                           aCodecs.EqualsASCII("7"));
+    return (aCodecs.IsEmpty() || aCodecs.EqualsASCII("1") ||
+            aCodecs.EqualsASCII("6") || aCodecs.EqualsASCII("7"));
   }
 
   return false;
 }
 
 } // namespace mozilla
--- a/dom/media/wave/WaveDecoder.h
+++ b/dom/media/wave/WaveDecoder.h
@@ -12,18 +12,15 @@ namespace mozilla {
 
 class WaveDecoder : public MediaDecoder {
 public:
   // MediaDecoder interface.
   explicit WaveDecoder(MediaDecoderOwner* aOwner) : MediaDecoder(aOwner) {}
   MediaDecoder* Clone(MediaDecoderOwner* aOwner) override;
   MediaDecoderStateMachine* CreateStateMachine() override;
 
-  // Returns true if the WAV backend is pref'ed on, and we're running on a
-  // platform that is likely to have decoders for the format.
-  static bool IsEnabled();
   static bool CanHandleMediaType(const nsACString& aType,
                                  const nsAString& aCodecs);
 };
 
 } // namespace mozilla
 
 #endif