Skip to content

Commit

Permalink
Update tidy for all packages
Browse files Browse the repository at this point in the history
Signed-off-by: Boram Bae <boram21.bae@samsung.com>
  • Loading branch information
bbrto21 committed May 12, 2021
1 parent 0e525a6 commit 970a696
Show file tree
Hide file tree
Showing 10 changed files with 663 additions and 650 deletions.
3 changes: 2 additions & 1 deletion packages/audioplayers/tizen/src/audio_player.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ void AudioPlayer::SetDataSource(std::vector<uint8_t> &data) {
}

void AudioPlayer::SetVolume(double volume) {
LOG_INFO("AudioPlayer %s is setting volume %f...", player_id_.c_str(), volume);
LOG_INFO("AudioPlayer %s is setting volume %f...", player_id_.c_str(),
volume);
if (volume_ != volume) {
volume_ = volume;
if (GetPlayerState() != PLAYER_STATE_NONE) {
Expand Down
2 changes: 1 addition & 1 deletion packages/audioplayers/tizen/src/audio_player_error.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ class AudioPlayerError {
std::string message_;
};

#endif // AUDIO_PLAYER_ERROR_H_
#endif // AUDIO_PLAYER_ERROR_H_
2 changes: 1 addition & 1 deletion packages/audioplayers/tizen/src/audio_player_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

enum ReleaseMode { RELEASE, LOOP, STOP };

#endif // AUDIO_PLAYER_OPTIONS_H_
#endif // AUDIO_PLAYER_OPTIONS_H_
7 changes: 4 additions & 3 deletions packages/audioplayers/tizen/src/audioplayers_tizen_plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ class AudioplayersTizenPlugin : public flutter::Plugin {
flutter::EncodableValue &release_mode_value =
encodables[flutter::EncodableValue("releaseMode")];
if (std::holds_alternative<std::string>(release_mode_value)) {
std::string release_mode = std::get<std::string>(release_mode_value);
std::string release_mode =
std::get<std::string>(release_mode_value);
if (release_mode.compare("ReleaseMode.RELEASE") == 0) {
player->SetReleaseMode(RELEASE);
} else if (release_mode.compare("ReleaseMode.LOOP") == 0) {
Expand Down Expand Up @@ -240,8 +241,8 @@ class AudioplayersTizenPlugin : public flutter::Plugin {
};

ErrorListener error_listener = [channel = channel_.get()](
const std::string &player_id,
const std::string &message) {
const std::string &player_id,
const std::string &message) {
flutter::EncodableMap wrapped = {
{flutter::EncodableValue("playerId"),
flutter::EncodableValue(player_id)},
Expand Down
107 changes: 64 additions & 43 deletions packages/flutter_tts/tizen/src/flutter_tts_tizen_plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ static std::string ErrorToString(int error) {
return "TTS - Successful";
case TTS_ERROR_OUT_OF_MEMORY:
return "TTS - Out of Memory";
case TTS_ERROR_IO_ERROR :
case TTS_ERROR_IO_ERROR:
return "TTS - I/O error";
case TTS_ERROR_INVALID_PARAMETER:
return "TTS - Invalid parameter";
Expand Down Expand Up @@ -55,16 +55,20 @@ class FlutterTtsTizenPlugin : public flutter::Plugin {
registrar->AddPlugin(std::move(plugin));
}

FlutterTtsTizenPlugin(flutter::PluginRegistrar *registrar) : m_tts(nullptr),
m_voice_type(TTS_VOICE_TYPE_AUTO), m_speed(TTS_SPEED_AUTO), m_speaking(false),
m_await_speak_completion(false) {
m_channel = std::make_unique<flutter::MethodChannel<flutter::EncodableValue>>(
registrar->messenger(), "flutter_tts", &flutter::StandardMethodCodec::GetInstance());
m_channel->SetMethodCallHandler(
[this](const auto &call, auto result) {
this->HandleMethodCall(call, std::move(result));
});
EnsureTtsHandle();
FlutterTtsTizenPlugin(flutter::PluginRegistrar *registrar)
: m_tts(nullptr),
m_voice_type(TTS_VOICE_TYPE_AUTO),
m_speed(TTS_SPEED_AUTO),
m_speaking(false),
m_await_speak_completion(false) {
m_channel =
std::make_unique<flutter::MethodChannel<flutter::EncodableValue>>(
registrar->messenger(), "flutter_tts",
&flutter::StandardMethodCodec::GetInstance());
m_channel->SetMethodCallHandler([this](const auto &call, auto result) {
this->HandleMethodCall(call, std::move(result));
});
EnsureTtsHandle();
}

virtual ~FlutterTtsTizenPlugin() {
Expand All @@ -75,7 +79,6 @@ class FlutterTtsTizenPlugin : public flutter::Plugin {
}

private:

bool EnsureTtsHandle() {
if (m_tts != nullptr) {
return true;
Expand All @@ -90,26 +93,30 @@ class FlutterTtsTizenPlugin : public flutter::Plugin {

ret = tts_set_state_changed_cb(m_tts, OnStateChanged, (void *)this);
if (ret != TTS_ERROR_NONE) {
LOG_ERROR("[TTS] tts_set_state_changed_cb failed: %s", ErrorToString(ret).c_str());
LOG_ERROR("[TTS] tts_set_state_changed_cb failed: %s",
ErrorToString(ret).c_str());
tts_destroy(m_tts);
m_tts = nullptr;
return false;
}

ret = tts_set_utterance_completed_cb(m_tts, OnUtteranceCompleted, (void *)this);
ret = tts_set_utterance_completed_cb(m_tts, OnUtteranceCompleted,
(void *)this);
if (ret != TTS_ERROR_NONE) {
LOG_ERROR("[TTS] tts_set_utterance_completed_cb failed: %s", ErrorToString(ret).c_str());
LOG_ERROR("[TTS] tts_set_utterance_completed_cb failed: %s",
ErrorToString(ret).c_str());
tts_destroy(m_tts);
m_tts = nullptr;
return false;
}

if (m_language.size() == 0) {
char* language;
char *language;
ret = tts_get_default_voice(m_tts, &language, &m_voice_type);

if (ret != TTS_ERROR_NONE) {
LOG_ERROR("[TTS] tts_get_default_voice failed: %s", ErrorToString(ret).c_str());
LOG_ERROR("[TTS] tts_get_default_voice failed: %s",
ErrorToString(ret).c_str());
tts_destroy(m_tts);
m_tts = nullptr;
return false;
Expand All @@ -120,12 +127,14 @@ class FlutterTtsTizenPlugin : public flutter::Plugin {

ret = tts_foreach_supported_voices(m_tts, OnSupportedVoices, (void *)this);
if (ret != TTS_ERROR_NONE) {
LOG_ERROR("[TTS] tts_foreach_supported_voices failed: %s", ErrorToString(ret).c_str());
LOG_ERROR("[TTS] tts_foreach_supported_voices failed: %s",
ErrorToString(ret).c_str());
tts_destroy(m_tts);
m_tts = nullptr;
return false;
}
m_languages.erase(unique(m_languages.begin(),m_languages.end()),m_languages.end());
m_languages.erase(unique(m_languages.begin(), m_languages.end()),
m_languages.end());

ret = tts_prepare(m_tts);
if (ret != TTS_ERROR_NONE) {
Expand All @@ -139,16 +148,16 @@ class FlutterTtsTizenPlugin : public flutter::Plugin {
}

void HandleMethodCall(
const flutter::MethodCall<flutter::EncodableValue> &method_call,
std::unique_ptr<flutter::MethodResult<flutter::EncodableValue>> result) {
const flutter::MethodCall<flutter::EncodableValue> &method_call,
std::unique_ptr<flutter::MethodResult<flutter::EncodableValue>> result) {
if (!EnsureTtsHandle()) {
LOG_ERROR("[TTS] EnsureTtsHandle() failed: %s", "EnsureTtsHandle failed");
result->Error("Invalid Operation", "Invalid Operation");
return;
}

const auto method_name = method_call.method_name();
const auto& arguments = *method_call.arguments();
const auto &arguments = *method_call.arguments();
LOG_INFO("method : %s", method_name.c_str());
int ret = TTS_ERROR_NONE;

Expand All @@ -157,8 +166,7 @@ class FlutterTtsTizenPlugin : public flutter::Plugin {
m_await_speak_completion = std::get<bool>(arguments);
result->Success();
return;
}
else {
} else {
result->Error("Invalid Arguments", "Invalid Arguments");
return;
}
Expand All @@ -171,18 +179,20 @@ class FlutterTtsTizenPlugin : public flutter::Plugin {
if (std::holds_alternative<std::string>(arguments)) {
std::string text = std::get<std::string>(arguments);
int utt_id;
ret = tts_add_text(m_tts, text.c_str(), m_language.c_str(), m_voice_type, m_speed, &utt_id);
ret = tts_add_text(m_tts, text.c_str(), m_language.c_str(),
m_voice_type, m_speed, &utt_id);
if (ret != TTS_ERROR_NONE) {
LOG_ERROR("[TTS] tts_add_text failed: %s", ErrorToString(ret).c_str());
LOG_ERROR("[TTS] tts_add_text failed: %s",
ErrorToString(ret).c_str());
result->Error(std::to_string(ret), "Failed to speak(tts_add_text).");
return;
}
}
} else {
result->Error("Invalid Arguments", "Invalid Arguments");
return;
}
ret = tts_play(m_tts);
if (ret != TTS_ERROR_NONE) {
if (ret != TTS_ERROR_NONE) {
LOG_ERROR("[TTS] tts_play failed: %s", ErrorToString(ret).c_str());
result->Error(std::to_string(ret), "Failed to speak(tts_play).");
return;
Expand Down Expand Up @@ -214,22 +224,28 @@ class FlutterTtsTizenPlugin : public flutter::Plugin {
return;
} else if (method_name.compare("getSpeechRateValidRange") == 0) {
int min, normal, max;
ret = tts_get_speed_range (m_tts, &min, &normal, &max);
ret = tts_get_speed_range(m_tts, &min, &normal, &max);
if (ret != TTS_ERROR_NONE) {
LOG_ERROR("[TTS] tts_get_speed_range failed: %s", ErrorToString(ret).c_str());
result->Error(std::to_string(ret), "Failed to getSpeechRateValidRange.");
LOG_ERROR("[TTS] tts_get_speed_range failed: %s",
ErrorToString(ret).c_str());
result->Error(std::to_string(ret),
"Failed to getSpeechRateValidRange.");
return;
}
flutter::EncodableMap map;
map.insert(std::pair<flutter::EncodableValue, flutter::EncodableValue>("min", min));
map.insert(std::pair<flutter::EncodableValue, flutter::EncodableValue>("normal", normal));
map.insert(std::pair<flutter::EncodableValue, flutter::EncodableValue>("max", max));
map.insert(std::pair<flutter::EncodableValue, flutter::EncodableValue>("platform", "tizen"));
map.insert(std::pair<flutter::EncodableValue, flutter::EncodableValue>(
"min", min));
map.insert(std::pair<flutter::EncodableValue, flutter::EncodableValue>(
"normal", normal));
map.insert(std::pair<flutter::EncodableValue, flutter::EncodableValue>(
"max", max));
map.insert(std::pair<flutter::EncodableValue, flutter::EncodableValue>(
"platform", "tizen"));
result->Success(flutter::EncodableValue(std::move(map)));
return;
} else if (method_name.compare("setSpeechRate") == 0) {
if (std::holds_alternative<double>(arguments)) {
m_speed = (int) std::get<double>(arguments);
m_speed = (int)std::get<double>(arguments);
result->Success();
return;
} else {
Expand All @@ -245,7 +261,7 @@ class FlutterTtsTizenPlugin : public flutter::Plugin {
result->Error("Invalid Arguments", "Invalid Arguments");
return;
}
} else if (method_name.compare("getLanguages") == 0) {
} else if (method_name.compare("getLanguages") == 0) {
result->Success(flutter::EncodableValue(m_languages));
return;
} else {
Expand All @@ -254,10 +270,12 @@ class FlutterTtsTizenPlugin : public flutter::Plugin {
}
}

static void OnStateChanged(tts_h tts, tts_state_e previous, tts_state_e current, void *user_data) {
static void OnStateChanged(tts_h tts, tts_state_e previous,
tts_state_e current, void *user_data) {
FlutterTtsTizenPlugin *plugin = (FlutterTtsTizenPlugin *)user_data;
LOG_INFO("[TTS] State is changed (%d) to (%d)", previous, current);
std::unique_ptr<flutter::EncodableValue> args = std::make_unique<flutter::EncodableValue>(true);
std::unique_ptr<flutter::EncodableValue> args =
std::make_unique<flutter::EncodableValue>(true);
if (current == TTS_STATE_PLAYING) {
if (previous == TTS_STATE_READY) {
plugin->m_channel->InvokeMethod("speak.onStart", std::move(args));
Expand All @@ -274,24 +292,27 @@ class FlutterTtsTizenPlugin : public flutter::Plugin {
plugin->m_current_state = current;
}

static void OnUtteranceCompleted(tts_h tts, int utt_id, void* user_data) {
static void OnUtteranceCompleted(tts_h tts, int utt_id, void *user_data) {
FlutterTtsTizenPlugin *plugin = (FlutterTtsTizenPlugin *)user_data;
tts_stop(plugin->m_tts);
LOG_INFO("[TTS] Utterance (%d) is completed", true);
if (plugin->m_await_speak_completion) {
plugin->m_speaking = false;
plugin->m_result->Success();
}
std::unique_ptr<flutter::EncodableValue> args = std::make_unique<flutter::EncodableValue>(true);
std::unique_ptr<flutter::EncodableValue> args =
std::make_unique<flutter::EncodableValue>(true);
plugin->m_channel->InvokeMethod("speak.onComplete", std::move(args));
}

static bool OnSupportedVoices(tts_h tts, const char* language, int voice_type, void* user_data) {
static bool OnSupportedVoices(tts_h tts, const char *language, int voice_type,
void *user_data) {
if (nullptr != language) {
FlutterTtsTizenPlugin *plugin = (FlutterTtsTizenPlugin *)user_data;

plugin->m_languages.push_back(flutter::EncodableValue(language));
LOG_INFO("[TTS] Supported Voices - Language(%s), Type(%d)", language, voice_type);
LOG_INFO("[TTS] Supported Voices - Language(%s), Type(%d)", language,
voice_type);
return true;
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ AppSettingsManager::AppSettingsManager() {}
AppSettingsManager::~AppSettingsManager() {}

void AppSettingsManager::OpenAppSettings(OnAppSettingsOpened success_callback,
OnAppSettingsError error_callback)
{
OnAppSettingsError error_callback) {
app_control_h service = nullptr;
int result = app_control_create(&service);
if (result != APP_CONTROL_ERROR_NONE) {
Expand Down
2 changes: 1 addition & 1 deletion packages/video_player/tizen/src/video_player_error.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ class VideoPlayerError {
std::string code_;
};

#endif // VIDEO_PLAYER_ERROR_H_
#endif // VIDEO_PLAYER_ERROR_H_
2 changes: 1 addition & 1 deletion packages/video_player/tizen/src/video_player_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ class VideoPlayerOptions {
bool mixWithOthers_;
};

#endif // VIDEO_PLAYER_OPTIONS_H_
#endif // VIDEO_PLAYER_OPTIONS_H_
Loading

0 comments on commit 970a696

Please sign in to comment.