--- /dev/null
+/*
+* Copyright (c) 2022 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 "ActivatedModes.h"
+
+ActivatedModes::ActivatedModes()
+{
+ for (int i = 0; i < __numOfModes; i++) {
+ __modeCounts[i] = 0;
+ }
+
+ __modeFlags[0] = TTSE_MODE_MASK_DEFAULT;
+ __modeFlags[1] = TTSE_MODE_MASK_NOTIFICATION;
+ __modeFlags[2] = TTSE_MODE_MASK_SCREEN_READER;
+ __modeFlags[3] = TTSE_MODE_MASK_INTERRUPT;
+}
+
+ActivatedModes::~ActivatedModes()
+{
+}
+
+void ActivatedModes::addMode(ttsd_mode_e mode)
+{
+ int index = getIndex(mode);
+ __modeCounts[index]++;
+}
+
+void ActivatedModes::removeMode(ttsd_mode_e mode)
+{
+ int index = getIndex(mode);
+ __modeCounts[index]--;
+}
+
+int ActivatedModes::getModes()
+{
+ int result = 0;
+ for (int i = 0; i < __numOfModes; i++) {
+ if (__modeCounts[i] > 0) {
+ result |= __modeFlags[i];
+ }
+ }
+
+ return result;
+}
+
+int ActivatedModes::getIndex(ttsd_mode_e mode)
+{
+ int index = static_cast<int>(mode);
+
+ if (index < static_cast<int>(TTSD_MODE_DEFAULT) || index > static_cast<int>(TTSD_MODE_INTERRUPT)) {
+ SLOG(LOG_WARN, tts_tag(), "[ActivatedModes] mode is invalid (%d). Handle as default.", index);
+ index = 0;
+ }
+
+ return index;
+}
--- /dev/null
+/*
+* Copyright (c) 2022 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.
+*/
+
+
+#ifndef __TTSD_ACTIVATED_MODES_H_
+#define __TTSD_ACTIVATED_MODES_H_
+
+#include "ttsd_main.h"
+
+class ActivatedModes {
+public:
+ ActivatedModes();
+ ~ActivatedModes();
+
+ void addMode(ttsd_mode_e mode);
+ void removeMode(ttsd_mode_e mode);
+ int getModes();
+
+private:
+ int getIndex(ttsd_mode_e mode);
+
+private:
+ static const int __numOfModes = 4;
+ ttse_mode_mask_e __modeFlags[__numOfModes];
+
+ int __modeCounts[__numOfModes];
+};
+
+
+#endif /* __TTSD_ACTIVATED_MODES_H_ */
BackgroundVolume.cpp
AudioStream.cpp
PlayerThread.cpp
+ ActivatedModes.cpp
ttsd_server.c
../common/tts_config_mgr.c
../common/tts_config_parser.c
#include <vector>
#include <atomic>
+#include "ActivatedModes.h"
+
#include "ttsd_data.h"
using namespace std;
/* If engine is running */
static atomic<ttsd_synthesis_control_e> g_synth_control;
+static ActivatedModes g_activated_modes;
+
#ifdef DATA_DEBUG
static void __data_show_list()
{
app.paused_data_existing = false;
g_app_list.push_back(app);
+ g_activated_modes.addMode(mode);
#ifdef DATA_DEBUG
__data_show_list();
__clean_data(g_app_list[index]);
+ ttsd_mode_e mode = g_app_list[index].mode;
g_app_list.erase(g_app_list.begin() + index);
+ g_activated_modes.removeMode(mode);
#ifdef DATA_DEBUG
__data_show_list();
return number;
}
+int ttsd_data_get_activated_mode()
+{
+ return g_activated_modes.getModes();
+}
+
int ttsd_data_save_error_log(unsigned int uid, FILE* fp)
{
lock_guard<mutex> lock(g_app_data_mutex);
int ttsd_data_get_same_pid_client_count(int pid);
+int ttsd_data_get_activated_mode();
+
/* For error handing */
int ttsd_data_save_error_log(unsigned int uid, FILE* fp);