Add API to get the current state of TTS player 50/41350/3
authorRichard Huang <r.huang@samsung.com>
Fri, 12 Jun 2015 15:16:23 +0000 (16:16 +0100)
committerRichard Huang <r.huang@samsung.com>
Mon, 15 Jun 2015 11:02:49 +0000 (12:02 +0100)
Change-Id: Idce0225976a6b2cf791761755cd0831e3d1ba054

adaptors/public-api/adaptor-framework/tts-player.cpp
adaptors/public-api/adaptor-framework/tts-player.h
adaptors/tizen/tts-player-impl-tizen.cpp
adaptors/tizen/tts-player-impl.h
adaptors/ubuntu/tts-player-impl-ubuntu.cpp
adaptors/ubuntu/tts-player-impl.h
automated-tests/src/dali-adaptor/utc-Dali-TtsPlayer.cpp

index 83292dc..6e20aa3 100644 (file)
@@ -58,7 +58,7 @@ TtsPlayer& TtsPlayer::operator=(const TtsPlayer& rhs)
 
 void TtsPlayer::Play(const std::string& text)
 {
-  return GetImplementation(*this).Play(text);
+  GetImplementation(*this).Play(text);
 }
 
 void TtsPlayer::Stop()
@@ -76,6 +76,11 @@ void TtsPlayer::Resume()
   GetImplementation(*this).Resume();
 }
 
+TtsPlayer::State TtsPlayer::GetState()
+{
+  return GetImplementation(*this).GetState();
+}
+
 TtsPlayer::TtsPlayer( Internal::Adaptor::TtsPlayer* player )
 : BaseHandle( player )
 {
index bb79902..deaf1b3 100644 (file)
@@ -50,6 +50,17 @@ public: // ENUMs
     MODE_NUM
   };
 
+  /**
+   * @brief Enumeration of TTS state.
+   */
+  enum State
+  {
+    UNAVAILABLE = 0,    ///< Player is not available
+    READY,              ///< Player is ready to play
+    PLAYING,            ///< Player is playing
+    PAUSED              ///< Player is paused
+  };
+
 public: // API
 
   /**
@@ -115,6 +126,12 @@ public: // API
    */
   void Resume();
 
+  /**
+   * @brief Gets the current state of the player.
+   * @pre The TtsPlayer needs to be initialized.
+   */
+  State GetState();
+
 public: // Not intended for application developers
 
   /**
index 70f5b9c..e2d7de3 100644 (file)
@@ -233,6 +233,28 @@ void TtsPlayer::Resume()
   }
 }
 
+Dali::TtsPlayer::State TtsPlayer::GetState()
+{
+  Dali::TtsPlayer::State ttsState = Dali::TtsPlayer::UNAVAILABLE;
+
+  if(mInitialized)
+  {
+    // Check the current TTS state
+    tts_state_e state;
+    int retVal = tts_get_state(mTtsHandle, &state);
+    if(retVal != TTS_ERROR_NONE)
+    {
+      LogErrorCode(static_cast<tts_error_e>(retVal));
+    }
+    else
+    {
+      ttsState = static_cast<Dali::TtsPlayer::State>(state);
+    }
+  }
+
+  return ttsState;
+}
+
 void TtsPlayer::StateChangedCallback(tts_h tts, tts_state_e previous, tts_state_e current, void *userData)
 {
   TtsPlayer* obj = static_cast<TtsPlayer*>(userData);
index 9ee5921..f1b261e 100644 (file)
@@ -73,6 +73,11 @@ public:
    */
   void Resume();
 
+  /**
+   * @copydoc TtsPlayer::GetState()
+   */
+  Dali::TtsPlayer::State GetState();
+
 private:
 
   /**
index fcce032..8e6b579 100644 (file)
@@ -78,6 +78,12 @@ void TtsPlayer::Resume()
 {
 }
 
+Dali::TtsPlayer::State TtsPlayer::GetState()
+{
+  return Dali::TtsPlayer::UNAVAILABLE;
+}
+
+
 } // namespace Adaptor
 
 } // namespace Internal
index 8c51629..0b33a08 100644 (file)
@@ -73,6 +73,11 @@ public:
    */
   void Resume();
 
+  /**
+   * @copydoc TtsPlayer::GetState()
+   */
+  Dali::TtsPlayer::State GetState();
+
 private:
 
   /**
index 60f531d..9269756 100644 (file)
@@ -155,3 +155,20 @@ int UtcDaliTtsPlayerResumeN(void)
   END_TEST;
 }
 
+int UtcDaliTtsPlayerGetStateN(void)
+{
+  Dali::TtsPlayer player = Dali::TtsPlayer::Get();
+
+  try
+  {
+    Dali::TtsPlayer::State state = player.GetState();
+    DALI_TEST_CHECK( false ); // Should not reach here!
+  }
+  catch( ... )
+  {
+    DALI_TEST_CHECK( true );
+  }
+
+  END_TEST;
+}
+