Add a new TTS Interrupt mode
[platform/core/uifw/tts.git] / server / ttsd_server.c
index 143275b..24365e5 100644 (file)
@@ -851,6 +851,19 @@ int ttsd_server_play(int uid, const char* credential)
                }
        }
 
+       /* check the current playback focus */
+       if (TTSD_MODE_INTERRUPT != ttsd_get_mode()) {
+               bool is_current_interrupt = false;
+               if (0 != ttsd_player_check_current_playback_focus(&is_current_interrupt)) {
+                       SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to check the current playback focus");
+               } else {
+                       if (true == is_current_interrupt) {
+                               SLOG(LOG_WARN, tts_tag(), "[Server WARNING] Current playback focus is set on Interrupt mode. Cannot play default, screen reader, and noti modes.");
+                               return TTSD_ERROR_AUDIO_POLICY_BLOCKED;
+                       }
+               }
+       }
+
        int current_uid = ttsd_data_get_current_playing();
        SLOG(LOG_INFO, tts_tag(), "[Server] playing uid (%d)", current_uid);
 
@@ -1155,7 +1168,7 @@ int ttsd_server_play_pcm(int uid)
                        SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to play pcm sound : uid(%d)", uid);
 
                        // Change ready state
-                       ttsd_server_stop(uid);
+                       ttsd_server_stop_pcm(uid);
 
                        int tmp_pid;
                        tmp_pid = ttsd_data_get_pid(uid);
@@ -1176,16 +1189,16 @@ int ttsd_server_stop_pcm(int uid)
 
        SLOG(LOG_INFO, tts_tag(), "[Server] server stop, state(%d)", state);
 
-       if (APP_STATE_PLAYING == state || APP_STATE_PAUSED == state) {
-               if (0 != ttsd_player_clear(uid))
-                       SLOG(LOG_WARN, tts_tag(), "[Server] Fail to ttsd_player_stop()");
-
+       if (APP_STATE_PLAYING == state || APP_STATE_PAUSED == state || APP_STATE_READY == state) {
                ttsd_data_set_client_state(uid, APP_STATE_READY);
        }
 
        /* Reset all data */
        ttsd_data_clear_data(uid);
 
+       ttsd_player_stop(uid);
+
+
        return TTSD_ERROR_NONE;
 }