Bug 1191667 - Part 1. Add onVolumeChanged method to nsISpeechTaskCallback. r=eitan
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Tue, 01 Sep 2015 17:50:51 +0900
changeset 260290 cf29589b47c8194ccd7b1e4a911e08a4bd5a84af
parent 260265 dffea8ce8b6073c522d7ea128ad0aee2efdfe66d
child 260291 c55b38a5ee0965c80570dbce9ec8c3da6529a29c
push id29307
push userryanvm@gmail.com
push dateWed, 02 Sep 2015 01:01:53 +0000
treeherdermozilla-central@e2eb0442ece9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerseitan
bugs1191667
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 1191667 - Part 1. Add onVolumeChanged method to nsISpeechTaskCallback. r=eitan
dom/media/webspeech/synth/nsISpeechService.idl
dom/media/webspeech/synth/pico/nsPicoService.cpp
dom/media/webspeech/synth/test/nsFakeSynthServices.cpp
dom/media/webspeech/synth/windows/SapiService.cpp
--- a/dom/media/webspeech/synth/nsISpeechService.idl
+++ b/dom/media/webspeech/synth/nsISpeechService.idl
@@ -7,33 +7,39 @@
 
 typedef unsigned short SpeechServiceType;
 
 /**
  * A callback is implemented by the service. For direct audio services, it is
  * required to implement these, although it could be helpful to use the
  * cancel method for shutting down the speech resources.
  */
-[scriptable, uuid(408251b0-1d7b-4876-888f-718859ce8c9d)]
+[scriptable, uuid(c576de0c-8a3d-4570-be7e-9876d3e5bed2)]
 interface nsISpeechTaskCallback : nsISupports
 {
   /**
    * The user or application has paused the speech.
    */
   void onPause();
 
   /**
    * The user or application has resumed the speech.
    */
   void onResume();
 
   /**
    * The user or application has canceled the speech.
    */
   void onCancel();
+
+  /**
+   * The user or application has changed the volume of this speech.
+   * This is only used on indirect audio service type.
+   */
+  void onVolumeChanged(in float aVolume);
 };
 
 
 /**
  * A task is associated with a single utterance. It is provided by the browser
  * to the service in the speak() method.
  */
 [scriptable, builtinclass, uuid(ad59949c-2437-4b35-8eeb-d760caab75c5)]
--- a/dom/media/webspeech/synth/pico/nsPicoService.cpp
+++ b/dom/media/webspeech/synth/pico/nsPicoService.cpp
@@ -404,16 +404,22 @@ PicoCallbackRunnable::OnResume()
 
 NS_IMETHODIMP
 PicoCallbackRunnable::OnCancel()
 {
   mService->mCurrentTask = nullptr;
   return NS_OK;
 }
 
+NS_IMETHODIMP
+PicoCallbackRunnable::OnVolumeChanged(float aVolume)
+{
+  return NS_OK;
+}
+
 NS_INTERFACE_MAP_BEGIN(nsPicoService)
   NS_INTERFACE_MAP_ENTRY(nsISpeechService)
   NS_INTERFACE_MAP_ENTRY(nsIObserver)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIObserver)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_ADDREF(nsPicoService)
 NS_IMPL_RELEASE(nsPicoService)
--- a/dom/media/webspeech/synth/test/nsFakeSynthServices.cpp
+++ b/dom/media/webspeech/synth/test/nsFakeSynthServices.cpp
@@ -86,16 +86,21 @@ public:
   {
     if (mTask) {
       mTask->DispatchEnd(1.5, 1);
     }
 
     return NS_OK;
   }
 
+  NS_IMETHOD OnVolumeChanged(float aVolume) override
+  {
+    return NS_OK;
+  }
+
 private:
   virtual ~FakeSynthCallback() { }
 
   nsCOMPtr<nsISpeechTask> mTask;
 };
 
 NS_IMPL_CYCLE_COLLECTION(FakeSynthCallback, mTask);
 
--- a/dom/media/webspeech/synth/windows/SapiService.cpp
+++ b/dom/media/webspeech/synth/windows/SapiService.cpp
@@ -98,16 +98,23 @@ SapiCallback::OnCancel()
   mSpeakTextLen = 0;
   // Purge all the previous utterances and speak an empty string
   if (FAILED(mSapiClient->Speak(nullptr, SPF_PURGEBEFORESPEAK, nullptr))) {
     return NS_ERROR_FAILURE;
   }
   return NS_OK;
 }
 
+NS_IMETHODIMP
+SapiCallback::OnVolumeChanged(float aVolume)
+{
+  mSapiClient->SetVolume(static_cast<USHORT>(aVolume * 100));
+  return NS_OK;
+}
+
 void
 SapiCallback::OnSpeechEvent(const SPEVENT& speechEvent)
 {
   switch (speechEvent.eEventId) {
   case SPEI_START_INPUT_STREAM:
     mTask->DispatchStart();
     break;
   case SPEI_END_INPUT_STREAM: