Changeset 1:f3a10e54a1df in rrlib_speech_synthesis


Ignore:
Timestamp:
07.08.2013 13:43:21 (7 years ago)
Author:
Tobias Föhst <foehst@…>
Branch:
default
Phase:
public
Message:

Replaced rrlib_logging macros by local variants to make use of this library from within rrlib_logging

Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • base/tVoice.cpp

    r0 r1  
    3434// External includes (system with <>, local with "") 
    3535//---------------------------------------------------------------------- 
    36 #include "rrlib/logging/messages.h" 
    3736 
    3837//---------------------------------------------------------------------- 
    3938// Internal includes with "" 
    4039//---------------------------------------------------------------------- 
     40#include "rrlib/speech_synthesis/base/log_messages.h" 
    4141 
    4242//---------------------------------------------------------------------- 
     
    9595  processing_thread(ProcessMessages, this) 
    9696{ 
    97   RRLIB_LOG_PRINT(DEBUG, "Started thread"); 
     97  LOG_PRINT(DEBUG, "Started thread"); 
    9898} 
    9999 
     
    103103tVoice::tMessageProcessorImplementation::~tMessageProcessorImplementation() 
    104104{ 
    105   RRLIB_LOG_PRINT(DEBUG, "Stopping thread"); 
    106   this->run_processing_thread = false; 
    107   this->message_buffer_empty.notify_all(); 
     105  LOG_PRINT(DEBUG, "Stopping thread"); 
     106  { 
     107    LOG_PRINT(DEBUG_VERBOSE_3, "Trying to acquiring lock"); 
     108    std::unique_lock<std::mutex> message_buffer_lock(this->message_buffer_mutex); 
     109    LOG_PRINT(DEBUG_VERBOSE_3, "Acquired lock"); 
     110    this->run_processing_thread = false; 
     111    this->message_buffer_empty.notify_all(); 
     112  } 
    108113  this->processing_thread.join(); 
    109114} 
     
    114119void tVoice::tMessageProcessorImplementation::AddMessage(tVoice *voice, const std::string &text) 
    115120{ 
    116   RRLIB_LOG_PRINT(DEBUG_VERBOSE_3, "Trying to acquiring lock"); 
     121  if (text.empty()) 
     122  { 
     123    return; 
     124  } 
     125 
     126  LOG_PRINT(DEBUG_VERBOSE_3, "Trying to acquiring lock"); 
    117127  std::unique_lock<std::mutex> message_buffer_lock(this->message_buffer_mutex); 
    118   RRLIB_LOG_PRINT(DEBUG_VERBOSE_3, "Acquired lock"); 
    119  
    120   tMessage message{voice, text}; 
     128  LOG_PRINT(DEBUG_VERBOSE_3, "Acquired lock"); 
     129 
     130  tMessage message {voice, text}; 
    121131  if (this->message_buffer_overrun_on_next_write) 
    122132  { 
     
    124134  } 
    125135 
    126   RRLIB_LOG_PRINT(DEBUG_VERBOSE_1, "Adding '", text, "' to message buffer"); 
     136  LOG_PRINT(DEBUG_VERBOSE_1, "Adding '", text, "' to message buffer"); 
    127137  *this->writer = message; 
    128138  std::advance(this->writer, 1); 
     
    136146  } 
    137147 
    138   RRLIB_LOG_PRINT(DEBUG_VERBOSE_2, "Notifying processing thread"); 
     148  LOG_PRINT(DEBUG_VERBOSE_2, "Notifying processing thread"); 
    139149  this->message_buffer_empty.notify_all(); 
    140150 
    141   RRLIB_LOG_PRINT(DEBUG_VERBOSE_3, "Yielding"); 
     151  LOG_PRINT(DEBUG_VERBOSE_3, "Yielding"); 
    142152  std::this_thread::yield(); 
    143153} 
     
    153163 
    154164    { 
    155       RRLIB_LOG_PRINT(DEBUG_VERBOSE_3, "Trying to acquiring lock"); 
     165      LOG_PRINT(DEBUG_VERBOSE_3, "Trying to acquiring lock"); 
    156166      std::unique_lock<std::mutex> message_buffer_lock(processor->message_buffer_mutex); 
    157       RRLIB_LOG_PRINT(DEBUG_VERBOSE_3, "Acquired lock"); 
     167      LOG_PRINT(DEBUG_VERBOSE_3, "Acquired lock"); 
    158168      while (processor->run_processing_thread && processor->reader == processor->writer) 
    159169      { 
    160         RRLIB_LOG_PRINT(DEBUG_VERBOSE_2, "Buffer empty -> going to sleep"); 
     170        LOG_PRINT(DEBUG_VERBOSE_2, "Buffer empty -> going to sleep"); 
    161171        processor->message_buffer_empty.wait(message_buffer_lock); 
    162         RRLIB_LOG_PRINT(DEBUG_VERBOSE_2, "Waking up"); 
     172        LOG_PRINT(DEBUG_VERBOSE_2, "Waking up"); 
    163173      } 
    164174 
     
    168178      } 
    169179 
    170       RRLIB_LOG_PRINT(DEBUG_VERBOSE_2, "Found message"); 
     180      LOG_PRINT(DEBUG_VERBOSE_2, "Found message"); 
    171181      message = *processor->reader; 
    172182      std::advance(processor->reader, 1); 
     
    177187      processor->message_buffer_overrun_on_next_write = false; 
    178188 
    179       RRLIB_LOG_PRINT(DEBUG_VERBOSE_3, "Releasing lock"); 
     189      LOG_PRINT(DEBUG_VERBOSE_3, "Releasing lock"); 
    180190    } 
    181191 
    182     RRLIB_LOG_PRINT(DEBUG_VERBOSE_1, "Saying '", message.text, "'"); 
     192    LOG_PRINT(DEBUG_VERBOSE_1, "Saying '", message.text, "'"); 
    183193    message.voice->OutputText(message.text); 
    184194 
    185     RRLIB_LOG_PRINT(DEBUG_VERBOSE_3, "Yielding"); 
     195    LOG_PRINT(DEBUG_VERBOSE_3, "Yielding"); 
    186196    std::this_thread::yield(); 
    187197  } 
  • espeak/tESpeak.cpp

    r0 r1  
    4040#include <speak_lib.h> 
    4141 
    42 #include "rrlib/logging/messages.h" 
    43  
    4442//---------------------------------------------------------------------- 
    4543// Internal includes with "" 
    4644//---------------------------------------------------------------------- 
     45#include "rrlib/speech_synthesis/base/log_messages.h" 
    4746 
    4847//---------------------------------------------------------------------- 
     
    9291  } 
    9392 
    94   RRLIB_LOG_PRINT(DEBUG, "Initializing espeak"); 
     93  LOG_PRINT(DEBUG, "Initializing espeak"); 
    9594 
    9695  int result = espeak_Initialize(AUDIO_OUTPUT_SYNCH_PLAYBACK, cBUFFER_LENGTH, NULL, 0); 
     
    101100  } 
    102101 
    103   RRLIB_LOG_PRINT(DEBUG, "Initialized espeak with sample rate: ", result, " Hz"); 
     102  LOG_PRINT(DEBUG, "Initialized espeak with sample rate: ", result, " Hz"); 
    104103  initialized = true; 
    105104} 
     
    128127  switch (error) 
    129128  { 
    130     case EE_OK: 
    131       break; 
    132     case EE_INTERNAL_ERROR: 
    133       RRLIB_LOG_PRINT(ERROR, "Speech synthesis failed: internal error"); 
    134       break; 
    135     case EE_BUFFER_FULL: 
    136       RRLIB_LOG_PRINT(ERROR, "Speech synthesis failed: buffer full"); 
    137       break; 
    138     case EE_NOT_FOUND: 
    139       RRLIB_LOG_PRINT(ERROR, "Speech synthesis failed: not found"); 
    140       break; 
     129  case EE_OK: 
     130    break; 
     131  case EE_INTERNAL_ERROR: 
     132    LOG_PRINT(ERROR, "Speech synthesis failed: internal error"); 
     133    break; 
     134  case EE_BUFFER_FULL: 
     135    LOG_PRINT(ERROR, "Speech synthesis failed: buffer full"); 
     136    break; 
     137  case EE_NOT_FOUND: 
     138    LOG_PRINT(ERROR, "Speech synthesis failed: not found"); 
     139    break; 
    141140  } 
    142141} 
  • festival/tFestival.cpp

    r0 r1  
    3939#include <festival.h> 
    4040 
    41 #include "rrlib/logging/messages.h" 
    42  
    4341//---------------------------------------------------------------------- 
    4442// Internal includes with "" 
    4543//---------------------------------------------------------------------- 
    46 #include "rrlib/speech_synthesis/base/tVoiceFactory.h" 
     44#include "rrlib/speech_synthesis/base/log_messages.h" 
    4745 
    4846//---------------------------------------------------------------------- 
     
    9290  } 
    9391 
    94   RRLIB_LOG_PRINT(DEBUG, "Initializing festival"); 
     92  LOG_PRINT(DEBUG, "Initializing festival"); 
    9593 
    9694  festival_initialize(1, cHEAP_SIZE); 
     
    115113  if (!festival_eval_command(this->voice_command.c_str())) 
    116114  { 
    117     RRLIB_LOG_PRINT(ERROR, "Could not evaluate voice command '", voice_command, "'"); 
     115    LOG_PRINT(ERROR, "Could not evaluate voice command '", voice_command, "'"); 
    118116    return; 
    119117  } 
    120118  if (!festival_say_text(text.c_str())) 
    121119  { 
    122     RRLIB_LOG_PRINT(ERROR, "Speech synthesis failed."); 
     120    LOG_PRINT(ERROR, "Speech synthesis failed."); 
    123121  } 
    124122} 
Note: See TracChangeset for help on using the changeset viewer.