Fix Svace issues by removing unused codes 32/289732/1
authorsooyeon <sooyeon.kim@samsung.com>
Tue, 14 Mar 2023 05:50:47 +0000 (14:50 +0900)
committerTizen AI <ai.tzn.sec@samsung.com>
Tue, 14 Mar 2023 06:08:01 +0000 (15:08 +0900)
Change-Id: I4b6d194faacd074305ab7a6968c715e94d0994ba
Signed-off-by: sooyeon <sooyeon.kim@samsung.com>
client/CMakeLists.txt
client/vc_mgr.c
client/vc_mgr_player.c [deleted file]
client/vc_mgr_player.h [deleted file]

index 6c62f69..0195eb3 100644 (file)
@@ -56,7 +56,6 @@ SET(MANAGER_SRCS
        vc_mgr_core.c
        vc_mgr_client.c
        vc_mgr_data.cpp
-       vc_mgr_player.c
        vc_mgr_tidl.c
        vc_mgr_proxy.c
        vc_mgr_stub.c
index 72f264b..2fc2d44 100644 (file)
@@ -32,7 +32,6 @@
 #include "vc_mgr_client.h"
 #include "vc_mgr_tidl.h"
 #include "vc_mgr_data.h"
-#include "vc_mgr_player.h"
 #include "vc_mgr_ducking.h"
 #include "voice_control_command.h"
 #include "voice_control_command_expand.h"
@@ -293,13 +292,6 @@ int vc_mgr_initialize(void)
                return ret;
        }
 
-       /* for TTS feedback */
-/*     ret = vc_mgr_player_init();
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to initialize VC mgr player : %d", ret);
-       }
-*/
-
        ret = vc_mgr_ducking_create();
        if (VC_ERROR_NONE != ret) {
                SLOG(LOG_INFO, TAG_VCM, "[INFO] Fail to ducking create : %d", ret);
@@ -382,13 +374,6 @@ int vc_mgr_deinitialize(void)
                SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to finalize DB, ret(%d)", ret);
        }
 
-       /* for TTS feedback */
-/*     ret = vc_mgr_player_release();
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to release VC mgr player(%d)", ret);
-       }
-*/
-
        ret = vc_mgr_ducking_destroy();
        if (VC_ERROR_NONE != ret) {
                SLOG(LOG_INFO, TAG_VCM, "[INFO] Fail to ducking destroy : %d", ret);
@@ -2750,20 +2735,12 @@ int vc_mgr_start_feedback(void)
        /* check state */
        RETVM_IF(VC_STATE_READY != state, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Start feedback : Current state is not 'Ready' (%d)", state);
 
-#if 1
        bool is_exist = ecore_thread_check(g_feedback_thread);
        if (NULL == g_feedback_thread || TRUE == is_exist) {
                SLOG(LOG_INFO, TAG_VCM, "[INFO] ecore thread run : __tts_feedback_thread");
                g_feedback_thread = ecore_thread_run(__tts_feedback_thread, __end_tts_feedback_thread, __cancel_tts_feedback_thread, NULL);
        }
-#else
-       /* start playing TTS feedback */
-       int ret = -1;
-       ret = vc_mgr_player_play();
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to player play, ret(%d)", ret);
-       }
-#endif
+
        return VC_ERROR_NONE;
 }
 
@@ -2787,7 +2764,6 @@ int vc_mgr_stop_feedback(void)
        /* check state */
        RETVM_IF(VC_STATE_READY != state, VC_ERROR_INVALID_STATE, TAG_VCM, "[ERROR] Stop feedback : Current state is not 'Ready' (%d)", state);
 
-#if 1
        if (g_feedback_thread) {
                ecore_thread_cancel(g_feedback_thread);
                g_feedback_thread = NULL;
@@ -2810,14 +2786,7 @@ int vc_mgr_stop_feedback(void)
                        break;
                }
        }
-#else
-       /* request to stop playing TTS feedback */
-       int ret = -1;
-       ret = vc_mgr_player_stop();
-       if (0 != ret) {
-               SLOG(LOG_ERROR, TAG_VCM, "[ERROR] Fail to player stop, ret(%d)", ret);
-       }
-#endif
+
        return ret;
 }
 
diff --git a/client/vc_mgr_player.c b/client/vc_mgr_player.c
deleted file mode 100644 (file)
index 5bfd5be..0000000
+++ /dev/null
@@ -1,413 +0,0 @@
-/*
-* Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
-*
-* Licensed under the Apache License, Version 2.0 (the License);
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an AS IS BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-
-#include <audio_io.h>
-#include <Ecore.h>
-#include <dlog.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include "vc_main.h"
-#include "vc_mgr_player.h"
-#include "vc_mgr_data.h"
-
-typedef enum {
-       AUDIO_STATE_NONE = 0,
-       AUDIO_STATE_READY,
-       AUDIO_STATE_PLAY
-} audio_state_e;
-
-typedef struct {
-       vc_feedback_state_e state;
-
-       vc_feedback_event_e event;
-       int idx;
-} player_s;
-
-#define SOUND_BUFFER_LENGTH 2048
-
-static bool g_player_init = false;
-
-static player_s* g_playing_info;
-
-static audio_state_e g_audio_state;
-
-static vc_audio_type_e g_audio_type;
-
-static vc_audio_channel_e g_audio_channel;
-
-static int g_sampling_rate;
-
-static audio_out_h g_audio_h;
-
-
-static int __create_audio_out(int rate, vc_audio_channel_e channel, vc_audio_type_e audio_type)
-{
-       int ret = -1;
-       audio_channel_e sample_channel = 0;
-       audio_sample_type_e sample_type = 0;
-
-       if (VC_AUDIO_CHANNEL_MONO == channel) {
-               sample_channel = AUDIO_CHANNEL_MONO;
-       } else if (VC_AUDIO_CHANNEL_STEREO == channel) {
-               sample_channel = AUDIO_CHANNEL_STEREO;
-       }
-
-       if (VC_AUDIO_TYPE_PCM_S16_LE == audio_type) {
-               sample_type = AUDIO_SAMPLE_TYPE_S16_LE;
-       } else {
-               sample_type = AUDIO_SAMPLE_TYPE_U8;
-       }
-
-       /* create audio_out new */
-       ret = audio_out_create_new(rate, sample_channel, sample_type, &g_audio_h);
-       if (AUDIO_IO_ERROR_NONE != ret) {
-               g_audio_state = AUDIO_STATE_NONE;
-               g_audio_h = NULL;
-               SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Fail to create audio. ret(%d)", ret);
-               return -1;
-       } else {
-               SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] Create audio");
-       }
-
-       g_audio_channel = channel;
-       g_audio_type = audio_type;
-       g_sampling_rate = rate;
-
-       g_audio_state = AUDIO_STATE_READY;
-
-       return 0;
-}
-
-static int __destroy_audio_out()
-{
-       if (NULL == g_audio_h) {
-               SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Current handle is not valid");
-               return -1;
-       }
-
-       int ret = -1;
-       ret = audio_out_destroy(g_audio_h);
-       if (AUDIO_IO_ERROR_NONE != ret) {
-               SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Fail to destroy audio. ret(%d)", ret);
-               return -1;
-       } else {
-               SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] Destroy audio");
-       }
-
-       g_audio_channel = 0;
-       g_audio_type = 0;
-       g_sampling_rate = 0;
-
-       g_audio_state = AUDIO_STATE_NONE;
-       g_audio_h = NULL;
-
-       return 0;
-}
-
-int vc_mgr_player_init(int rate, vc_audio_channel_e channel, vc_audio_type_e audio_type)
-{
-       g_audio_state = AUDIO_STATE_NONE;
-       g_audio_h = NULL;
-
-       ecore_thread_max_set(1);
-
-       int ret = -1;
-
-
-       ret = __create_audio_out(rate, channel, audio_type);
-       if (0 != ret) {
-               return VC_ERROR_OPERATION_FAILED;
-       }
-
-       g_player_init = true;
-
-       return VC_ERROR_NONE;
-}
-
-int vc_mgr_player_release()
-{
-       if (false == g_player_init) {
-               SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Not initialized");
-               return VC_ERROR_OPERATION_FAILED;
-       }
-
-       int ret = -1;
-
-       int thread_count = ecore_thread_active_get();
-       SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] Active thread count : %d", thread_count);
-       int count = 0;
-       while (0 < thread_count) {
-               usleep(10000);
-
-               count++;
-               if (20 == count) {
-                       SLOG(LOG_WARN, TAG_VCM, "[Player WARN] Thread is blocked. Player release continue");
-                       break;
-               }
-
-               thread_count = ecore_thread_active_get();
-       }
-
-       SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] Thread is release");
-
-       ret = __destroy_audio_out();
-       if (0 != ret) {
-               return VC_ERROR_OPERATION_FAILED;
-       }
-
-       g_player_init = false;
-
-       return VC_ERROR_NONE;
-}
-
-static void __play_feedback_thread(void* data, Ecore_Thread* thread)
-{
-       SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] Start thread");
-
-       if (NULL == g_playing_info) {
-               SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] No current player");
-               return;
-       }
-
-       player_s* player = g_playing_info;
-       vc_feedback_data_s* feedback_data = NULL;
-
-       int ret = -1;
-       int len = SOUND_BUFFER_LENGTH;
-       int idx = 0;
-
-       while (1) {
-               /* get feedback data */
-               ret = vc_mgr_data_get_feedback_data(&feedback_data);
-               if (0 != ret || NULL == feedback_data) {
-                       /* empty queue */
-                       SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] No feedback data. Waiting mode");
-
-                       /* waiting */
-                       while (1) {
-                               usleep(10000);
-                               if (0 < vc_mgr_data_get_feedback_data_size()) {
-                                       SLOG(LOG_INFO, TAG_VCM, "[Player INFO] Resume thread");
-                                       break;
-                               }
-
-                               if (AUDIO_STATE_PLAY == g_audio_state) {
-                                       /* release audio & recover session */
-                                       ret = audio_out_unprepare(g_audio_h);
-                                       if (AUDIO_IO_ERROR_NONE != ret) {
-                                               SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Fail to unprepare audio");
-                                       } else {
-                                               SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] Unprepare audio");
-                                       }
-                                       g_audio_state = AUDIO_STATE_READY;
-                               }
-                       }
-
-                       SLOG(LOG_INFO, TAG_VCM, "[Player INFO] Finish to wait for new feedback data come");
-
-                       /* resume play thread */
-                       player->state = VC_FEEDBACK_STATE_PLAYING;
-                       continue;
-               }
-
-               if (VC_FEEDBACK_EVENT_START == feedback_data->event ||
-                               (VC_FEEDBACK_EVENT_FINISH == player->event && VC_FEEDBACK_EVENT_FINISH == feedback_data->event)) {
-                       int pid = vc_mgr_data_get_pid();
-                       SLOG(LOG_INFO, TAG_VCM, "[Player DEBUG] Start utterance (%d)", pid);
-               }
-
-               player->event = feedback_data->event;
-               idx = 0;
-               /* If no feedback data and EVENT_FINISH */
-               if (NULL == feedback_data->data || 0 >= feedback_data->data_size) {
-                       if (VC_FEEDBACK_EVENT_FINISH == feedback_data->event) {
-                               int pid = vc_mgr_data_get_pid();
-                               if (pid <= 0) {
-                                       return;
-                               }
-                               SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] No sound data");
-                       }
-                       SLOG(LOG_INFO, TAG_VCM, "[Player INFO] Finish utterance");
-                       vc_mgr_data_clear_feedback_data(&feedback_data);
-                       continue;
-               }
-
-               if (g_sampling_rate != feedback_data->rate || g_audio_type != feedback_data->audio_type || g_audio_channel != feedback_data->channel) {
-                       SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] change audio handle");
-                       if (NULL != g_audio_h) {
-                               __destroy_audio_out();
-                       }
-
-                       if (0 > __create_audio_out(feedback_data->rate, feedback_data->channel, feedback_data->audio_type)) {
-                               SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Fail to create audio out");
-                               vc_mgr_data_clear_feedback_data(&feedback_data);
-
-                               return;
-                       }
-               }
-
-               while (VC_FEEDBACK_STATE_PLAYING == player->state) {
-                       if ((unsigned int)idx >= feedback_data->data_size)
-                               break;
-
-                       if ((unsigned int)idx + SOUND_BUFFER_LENGTH > feedback_data->data_size) {
-                               len = feedback_data->data_size - idx;
-                       } else {
-                               len = SOUND_BUFFER_LENGTH;
-                       }
-
-                       if (AUDIO_STATE_READY == g_audio_state) {
-                               /* request prepare */
-                               ret = audio_out_prepare(g_audio_h);
-                               if (AUDIO_IO_ERROR_NONE != ret) {
-                                       SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Fail to prepare audio");
-                                       vc_mgr_data_clear_feedback_data(&feedback_data);
-                                       return;
-                               }
-                               SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] Prepare audio");
-                               g_audio_state = AUDIO_STATE_PLAY;
-                       }
-
-                       char* temp_data = feedback_data->data;
-                       SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] data(%p), idx(%d), len(%d)", temp_data, idx, len);
-
-                       ret = audio_out_write(g_audio_h, &temp_data[idx], len);
-                       if (0 > ret) {
-                               SLOG(LOG_WARN, TAG_VCM, "[Player WARN] Fail to audio write - %d", ret);
-                       } else {
-                               idx += len;
-                       }
-
-                       if (NULL == g_playing_info) {
-                               SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Current player is NULL");
-                               g_audio_state = AUDIO_STATE_READY;
-                               ret = audio_out_unprepare(g_audio_h);
-                               if (AUDIO_IO_ERROR_NONE != ret) {
-                                       SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Fail to unprepare audio");
-                               }
-
-                               vc_mgr_data_clear_feedback_data(&feedback_data);
-
-                               return;
-                       }
-               }
-
-               if (NULL == g_playing_info && VC_FEEDBACK_STATE_READY == player->state) {
-                       /* player stop */
-                       g_audio_state = AUDIO_STATE_READY;
-                       SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] Stop play thread");
-
-                       /* request to unprepare audio */
-                       ret = audio_out_unprepare(g_audio_h);
-                       if (AUDIO_IO_ERROR_NONE != ret) {
-                               SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Fail to unprepare audio");
-                       } else {
-                               SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] Unprepare audio");
-                       }
-
-                       vc_mgr_data_clear_feedback_data(&feedback_data);
-                       return;
-               }
-
-               if ((VC_FEEDBACK_STATE_PLAYING == player->state) && (VC_FEEDBACK_EVENT_FINISH == feedback_data->event)) {
-                       int pid = vc_mgr_data_get_pid();
-                       if (pid <= 0) {
-                               return;
-                       }
-                       SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] Finish utterance");
-               }
-
-               vc_mgr_data_clear_feedback_data(&feedback_data);
-
-               if (NULL == g_playing_info) {
-                       SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Current player is NULL");
-                       g_audio_state = AUDIO_STATE_READY;
-                       ret = audio_out_unprepare(g_audio_h);
-                       if (AUDIO_IO_ERROR_NONE != ret) {
-                               SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Fail to unprepare audio");
-                       }
-
-                       return;
-               }
-
-       }
-
-}
-
-static void __end_play_feedback_thread(void* data, Ecore_Thread* thread)
-{
-       SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] End thread");
-}
-
-int vc_mgr_player_play()
-{
-       if (false == g_player_init) {
-               SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Not initialized");
-               return VC_ERROR_OPERATION_FAILED;
-       }
-
-       if (NULL != g_playing_info) {
-               SLOG(LOG_WARN, TAG_VCM, "[Player WARN] Stop old player");
-               vc_mgr_player_stop();
-       }
-
-       SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] start play");
-
-       /* check sound queue size */
-       int data_size = vc_mgr_data_get_feedback_data_size();
-       if (0 == data_size) {
-               SLOG(LOG_WARN, TAG_VCM, "[Player WARN] A sound queue of current player is empty");
-       } else if (0 < data_size) {
-               SLOG(LOG_INFO, TAG_VCM, "[Player INFO] Run thread");
-               ecore_thread_run(__play_feedback_thread, __end_play_feedback_thread, NULL, NULL);
-       }
-
-       return VC_ERROR_NONE;
-}
-
-int vc_mgr_player_stop()
-{
-       if (false == g_player_init) {
-               SLOG(LOG_ERROR, TAG_VCM, "[Player ERROR] Not initialized");
-               return VC_ERROR_OPERATION_FAILED;
-       }
-
-       if (NULL != g_playing_info) {
-               g_playing_info = NULL;
-               SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] No more current playing");
-       }
-
-       SLOG(LOG_DEBUG, TAG_VCM, "[Player DEBUG] stop play");
-
-       int thread_count = ecore_thread_active_get();
-       int count = 0;
-
-       while (0 < thread_count) {
-               usleep(10000);
-
-               count++;
-               if (30 == count) {
-                       SLOG(LOG_WARN, TAG_VCM, "[Player WARN] Thread is blocked. Player release continue");
-                       break;
-               }
-
-               thread_count = ecore_thread_active_get();
-       }
-
-       return VC_ERROR_NONE;
-}
diff --git a/client/vc_mgr_player.h b/client/vc_mgr_player.h
deleted file mode 100644 (file)
index 6cf550c..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-
-#ifndef __VC_MGR_PLAYER_H__
-#define __VC_MGR_PLAYER_H__
-
-#include <tizen.h>
-#include <voice_control_common.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int vc_mgr_player_init(int rate, vc_audio_channel_e channel, vc_audio_type_e audio_type);
-
-int vc_mgr_player_release();
-
-int vc_mgr_player_play();
-
-int vc_mgr_player_stop();
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __VC_MGR_PLAYER_H__ */