Bug 1201393. Remove irrelevant ProcessedMediaStream for nsSpeechTask. r=eitan
authorRobert O'Callahan <robert@ocallahan.org>
Tue, 01 Sep 2015 16:49:50 +1200
changeset 261213 fcc8220b9561ae60f38e08f28defc5c0751f9089
parent 261212 0f56b9b904a2ec1356e58ad4b0a1c25b362770cc
child 261214 2d0794169172b3d89e863dddd53054b5f612fa3a
push id64690
push userrocallahan@mozilla.com
push dateTue, 08 Sep 2015 04:29:49 +0000
treeherdermozilla-inbound@321303b7d428 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerseitan
bugs1201393
milestone43.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 1201393. Remove irrelevant ProcessedMediaStream for nsSpeechTask. r=eitan
dom/media/webspeech/synth/nsSpeechTask.cpp
dom/media/webspeech/synth/nsSpeechTask.h
dom/media/webspeech/synth/nsSynthVoiceRegistry.cpp
dom/media/webspeech/synth/nsSynthVoiceRegistry.h
--- a/dom/media/webspeech/synth/nsSpeechTask.cpp
+++ b/dom/media/webspeech/synth/nsSpeechTask.cpp
@@ -135,25 +135,29 @@ nsSpeechTask::~nsSpeechTask()
 
   if (mPort) {
     mPort->Destroy();
     mPort = nullptr;
   }
 }
 
 void
-nsSpeechTask::Init(ProcessedMediaStream* aStream)
+nsSpeechTask::InitDirectAudio()
 {
-  if (aStream) {
-    mStream = aStream->Graph()->CreateSourceStream(nullptr);
-    mPort = aStream->AllocateInputPort(mStream, 0);
-    mIndirectAudio = false;
-  } else {
-    mIndirectAudio = true;
-  }
+  mStream = MediaStreamGraph::GetInstance(MediaStreamGraph::AUDIO_THREAD_DRIVER,
+                                          AudioChannel::Normal)->
+    CreateSourceStream(nullptr);
+  mIndirectAudio = false;
+  mInited = true;
+}
+
+void
+nsSpeechTask::InitIndirectAudio()
+{
+  mIndirectAudio = true;
   mInited = true;
 }
 
 void
 nsSpeechTask::SetChosenVoiceURI(const nsAString& aUri)
 {
   mChosenVoiceURI = aUri;
 }
--- a/dom/media/webspeech/synth/nsSpeechTask.h
+++ b/dom/media/webspeech/synth/nsSpeechTask.h
@@ -43,17 +43,18 @@ public:
   virtual void ForceEnd();
 
   float GetCurrentTime();
 
   uint32_t GetCurrentCharOffset();
 
   void SetSpeechSynthesis(SpeechSynthesis* aSpeechSynthesis);
 
-  void Init(ProcessedMediaStream* aStream);
+  void InitDirectAudio();
+  void InitIndirectAudio();
 
   void SetChosenVoiceURI(const nsAString& aUri);
 
   virtual void SetAudioOutputVolume(float aVolume);
 
   bool IsPreCanceled()
   {
     return mPreCanceled;
--- a/dom/media/webspeech/synth/nsSynthVoiceRegistry.cpp
+++ b/dom/media/webspeech/synth/nsSynthVoiceRegistry.cpp
@@ -172,24 +172,16 @@ nsSynthVoiceRegistry::nsSynthVoiceRegist
 
 nsSynthVoiceRegistry::~nsSynthVoiceRegistry()
 {
   LOG(LogLevel::Debug, ("~nsSynthVoiceRegistry"));
 
   // mSpeechSynthChild's lifecycle is managed by the Content protocol.
   mSpeechSynthChild = nullptr;
 
-  if (mStream) {
-    if (!mStream->IsDestroyed()) {
-      mStream->Destroy();
-    }
-
-    mStream = nullptr;
-  }
-
   mUriVoiceMap.Clear();
 }
 
 nsSynthVoiceRegistry*
 nsSynthVoiceRegistry::GetInstance()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
@@ -770,23 +762,18 @@ nsSynthVoiceRegistry::SpeakImpl(VoiceDat
        aRate, aPitch));
 
   SpeechServiceType serviceType;
 
   DebugOnly<nsresult> rv = aVoice->mService->GetServiceType(&serviceType);
   NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Failed to get speech service type");
 
   if (serviceType == nsISpeechService::SERVICETYPE_INDIRECT_AUDIO) {
-    aTask->Init(nullptr);
+    aTask->InitIndirectAudio();
   } else {
-    if (!mStream) {
-      mStream =
-        MediaStreamGraph::GetInstance(MediaStreamGraph::AUDIO_THREAD_DRIVER,
-                                      AudioChannel::Normal)->CreateTrackUnionStream(nullptr);
-    }
-    aTask->Init(mStream);
+    aTask->InitDirectAudio();
   }
 
   aVoice->mService->Speak(aText, aVoice->mUri, aVolume, aRate, aPitch, aTask);
 }
 
 } // namespace dom
 } // namespace mozilla
--- a/dom/media/webspeech/synth/nsSynthVoiceRegistry.h
+++ b/dom/media/webspeech/synth/nsSynthVoiceRegistry.h
@@ -90,18 +90,16 @@ private:
   nsTArray<nsRefPtr<VoiceData>> mVoices;
 
   nsTArray<nsRefPtr<VoiceData>> mDefaultVoices;
 
   nsRefPtrHashtable<nsStringHashKey, VoiceData> mUriVoiceMap;
 
   SpeechSynthesisChild* mSpeechSynthChild;
 
-  nsRefPtr<ProcessedMediaStream> mStream;
-
   bool mUseGlobalQueue;
 
   nsTArray<nsRefPtr<GlobalQueueItem>> mGlobalQueue;
 
   bool mIsSpeaking;
 };
 
 } // namespace dom