*/
#include "ttsd_main.h"
-#include "ttsd_player.h"
+#include "ttsd_server.h"
#include "ttsd_data.h"
-#include "ttsd_dbus.h"
#include "ttsd_ipc.h"
+#include "ttsd_player.h"
#include "BackgroundVolume.h"
#include "AudioStream.h"
#include "PlayerThread.h"
-#include "tts_internal.h"
-#include "ttsd_server.h"
-
#define SOUND_BUFFER_LENGTH 2048
+/* CAUTION!
+If you change this constant value. Please check the function '__set_timer_for_delay_recover()'.
+If you choose too big value, it may cause integer overflow issue.
+*/
+static const int SND_MGR_DUCKING_DURATION = 500;
static const intptr_t CHECK_TIMER_DELETE = 1;
static const int EXTRA_INFO_LENGTH = 20;
/** player init info */
static bool g_player_init = false;
-static bool g_is_set_policy;
-
-/* CAUTION!
-If you change this constant value. Please check the function '__set_timer_for_delay_recover()'.
-If you choose too big value, it may cause integer overflow issue.
-*/
-#define SND_MGR_DUCKING_DURATION 500
-
+static volatile bool g_is_set_policy = false;
static BackgroundVolume* g_background_volume = nullptr;
static AudioStream* g_audio_stream = nullptr;
static void __set_policy_for_playing(void)
{
- const char* extra_info = NULL;
+ const char* extra_info = nullptr;
if (TTSD_MODE_INTERRUPT == ttsd_get_mode()) {
extra_info = "TTSD_MODE_INTERRUPT";
}
g_is_set_policy = true;
SLOG(LOG_ERROR, tts_tag(), "[BG] g_is_set_policy(%d)", g_is_set_policy);
SLOG(LOG_DEBUG, tts_tag(), "[Player DEBUG] set policy for playing");
-
- return;
}
static void __unset_policy_for_playing()
g_is_set_policy = false;
SLOG(LOG_ERROR, tts_tag(), "[BG] g_is_set_policy(%d)", g_is_set_policy);
SLOG(LOG_DEBUG, tts_tag(), "[Player DEBUG] unset policy for playing");
-
- return;
}
static bool __does_interrupt_have_focus(sound_stream_focus_change_reason_e reason, int sound_behavior, char *extra_info)
return false;
}
- if (NULL == extra_info || 0 >= strlen(extra_info) || 0 != strncmp(extra_info, "TTSD_MODE_INTERRUPT", EXTRA_INFO_LENGTH)) {
+ if (nullptr == extra_info || 0 >= strlen(extra_info) || 0 != strncmp(extra_info, "TTSD_MODE_INTERRUPT", EXTRA_INFO_LENGTH)) {
return false;
}
{
sound_stream_focus_change_reason_e reason;
int sound_behavior = 0;
- char *extra_info = NULL;
+ char *extra_info = nullptr;
if (SOUND_MANAGER_ERROR_NONE != sound_manager_get_current_playback_focus(&reason, &sound_behavior, &extra_info)) {
SLOG(LOG_ERROR, tts_tag(), "[Player ERROR] Fail to get focus information");
return false;
SLOG(LOG_INFO, tts_tag(), "[Player] Sound info : id(%d) data(%p) size(%d) audiotype(%d) rate(%d) event(%d)",
sound_data->utt_id, sound_data->data, sound_data->data_size, sound_data->audio_type, sound_data->rate, sound_data->event);
- } else { // NO player->is_paused_data
+ } else {
if (nullptr == sound_data) {
SLOG(LOG_ERROR, tts_tag(), "[Player] No sound data. Waiting mode");
SLOG(LOG_INFO, tts_tag(), "[Player] Finish to wait for new audio data come");
continue;
- } // NULL == sound_data
+ }
/* If wdata's event is 'start', current wdata is first data of engine for synthesis.
* If wdata's event is 'finish', player should check previous event to know whether this wdata is first or not.
if (TTSD_ERROR_INVALID_PARAMETER == ret) {
break;
}
- } // (TTSE_RESULT_EVENT_START == sound_data->event || (TTSE_RESULT_EVENT_FINISH == player->event && TTSE_RESULT_EVENT_FINISH == sound_data->event))
+ }
/* Save last event to check utterance start */
ttsd_data_set_last_sound_result_event(uid, sound_data->event);
}
continue;
- } // (NULL == sound_data->data || 0 >= sound_data->data_size)
- } // NO player->is_paused_data
+ }
+ }
int ret = __play_sound_data(player, uid, sound_data);
if (TTSD_ERROR_INVALID_STATE == ret) {
if (TTSD_ERROR_NONE != __notify_utterance_completed_event(uid, utt_id)) {
break;
}
- } // (TTSE_RESULT_EVENT_FINISH == event)
+ }
app_tts_state_e state = ttsd_data_get_client_state(uid);
if (APP_STATE_READY == state) {
/* player_stop */
SLOG(LOG_DEBUG, tts_tag(), "[Player] Stop player thread");
break;
- } // (NULL == g_playing_info && APP_STATE_READY == player->state)
+ }
}
g_audio_stream->unprepareAudioOut();
#endif
__set_playing_status(false);
- SLOG(LOG_DEBUG, tts_tag(), "[Player SUCCESS] Pause player : uid(%u)", uid);
+ SLOG(LOG_INFO, tts_tag(), "[Player SUCCESS] Pause player : uid(%u)", uid);
return 0;
}
return TTSD_ERROR_OPERATION_FAILED;
}
- if (NULL == ratio) {
+ if (nullptr == ratio) {
return TTSD_ERROR_INVALID_PARAMETER;
}