Skip to content
Snippets Groups Projects
Commit 2b2665d8 authored by Stuart Mark James's avatar Stuart Mark James
Browse files

Clean result queue, some logging upped to Info level

parent b109f109
No related branches found
No related tags found
No related merge requests found
......@@ -167,7 +167,10 @@ void TextToSpeech::delete_device()
// join the debug thread
if(debug_and_states_handler.joinable())
{
result_queue.clear();
debug_and_states_handler.join();
}
CORBA::string_free(*attr_text_to_talk_read);
......@@ -939,6 +942,7 @@ void TextToSpeech::dev_clear()
// clear the queue then stop the current playback
tts_runner.clearAllRequests();
tts_runner.stopPlayback();
result_queue.clear();
}
catch(const exception &e)
{
......
......@@ -50,7 +50,7 @@ TTSRunner::~TTSRunner()
void TTSRunner::initialise()
{
TRACE_LOGGER;
LOG(Debug) << "Initialising the TTS Runner and its worker thread" << endl;
LOG(Info) << "Initialising the TTS Runner and its worker thread" << endl;
// allocate all the various sub systems and bring them up
_polly_driver = new PollyTTSDriver();
......@@ -91,7 +91,7 @@ void TTSRunner::initialise()
void TTSRunner::initialiseCache(const std::string &cache_location)
{
TRACE_LOGGER;
LOG(Debug) << "Initialising the caching system" << endl;
LOG(Info) << "Initialising the caching system" << endl;
checkInitState();
lock_guard<mutex> lock(_access_mutex);
_audio_cache = new FileTTSCache(cache_location, true);
......@@ -102,7 +102,7 @@ void TTSRunner::initialiseCache(const std::string &cache_location)
void TTSRunner::initialiseJingle(const std::string &jingle_location)
{
TRACE_LOGGER;
LOG(Debug) << "Initialising the jingle system" << endl;
LOG(Info) << "Initialising the jingle system" << endl;
checkInitState();
lock_guard<mutex> lock(_access_mutex);
_jingle_mgr = new JingleMgr(jingle_location);
......@@ -113,7 +113,7 @@ void TTSRunner::initialiseJingle(const std::string &jingle_location)
void TTSRunner::destroy()
{
TRACE_LOGGER;
LOG(Debug) << "Destroying the TTS Runner and joining its worker thread" << endl;
LOG(Info) << "Destroying the TTS Runner and joining its worker thread" << endl;
if (_worker_thread.joinable())
{
......@@ -156,7 +156,7 @@ void TTSRunner::destroy()
future<bool> TTSRunner::addRequest(const TTSRequest &request)
{
TRACE_LOGGER;
LOG(Debug) << "Pushing request to speak text: " << request._text << ", voice: " << request._voice << endl;
LOG(Info) << "Pushing request to speak text: " << request._text << ", voice: " << request._voice << endl;
checkInitState();
// wrap the request inside an internal structure for conviences
......@@ -177,7 +177,7 @@ future<bool> TTSRunner::addRequest(const TTSRequest &request)
void TTSRunner::stopPlayback()
{
TRACE_LOGGER;
LOG(Debug) << "Requesting any current audio message playback is stopped" << endl;
LOG(Info) << "Requesting any current audio message playback is stopped" << endl;
checkInitState();
// we do not need to lock these calls, since pulse audio has its own locking
......@@ -195,7 +195,7 @@ void TTSRunner::stopPlayback()
void TTSRunner::clearAllRequests()
{
TRACE_LOGGER;
LOG(Debug) << "Clearing any queued message requests" << endl;
LOG(Info) << "Clearing any queued message requests" << endl;
checkInitState();
_request_queue.clear();
}
......@@ -344,7 +344,7 @@ void TTSRunner::checkInitState() const
void TTSRunner::mainLoop()
{
TRACE_LOGGER;
LOG(Debug) << "Starting main worker loop" << endl;
LOG(Info) << "Starting mainloop worker thread" << endl;
try
{
......@@ -412,18 +412,21 @@ void TTSRunner::mainLoop()
buffer = _polly_driver->getSpeechBuffer(text, voice);
_audio_cache->cache(text, buffer, voice);
_polly_requests++;
LOG(Info) << "Looked up <" << text << "> speech buffer from polly due to cache failure" << endl;
}
else
{
// valid cache hit, increment the stats
_cache_hits++;
LOG(Info) << "Using cached <" << text << "> speech buffer" << endl;
}
}
else
{
// no caching, always try to get it from amazon
buffer = _polly_driver->getSpeechBuffer(text, voice);
_polly_requests++;
_polly_requests++;
LOG(Info) << "Looked up <" << text << "> speech buffer from polly" << endl;
}
return buffer;
......@@ -457,6 +460,7 @@ void TTSRunner::mainLoop()
// something went wrong, or the playback was aborted, skip
// the rest of this tts
lock.unlock();
LOG(Info) << "Speech request broken (possible exit request)" << endl;
req._result.set_value(false);
continue;
}
......@@ -474,6 +478,7 @@ void TTSRunner::mainLoop()
// check no exit request before blocking on speech
if (_exit_thread)
{
LOG(Info) << "Speech request broken (exit request)" << endl;
req._result.set_value(false);
continue;
}
......@@ -483,6 +488,7 @@ void TTSRunner::mainLoop()
// if we reached this far, chances are the audio was played, so
// trigger the future with an indication of success
LOG(Info) << "Speech request successful" << endl;
req._result.set_value(true);
}
catch (const exception &e)
......@@ -509,5 +515,7 @@ void TTSRunner::mainLoop()
// then pick them up and report them up to the user
ExceptionQueue.push(current_exception());
}
LOG(Info) << "Exciting mainloop worker thread" << endl;
}
} // TTSLibrary
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment