RTC::ReturnCode_t PulseAudioOutput::onFinalize() { RTC_DEBUG(("onFinalize start")); is_active = false; m_mutex.lock(); RTC_DEBUG(("onFinalize:mutex lock")); try { if ( !m_data.empty() ) { RTC_DEBUG(("onFinalize:queue buffer clear start.")); m_data.clear(); //!< queue buffer clear RTC_DEBUG(("onFinalize:queue buffer clear finish.")); } if ( m_simple ) { RTC_DEBUG(("onFinalize:simple connection object free start.")); pa_simple_free( m_simple ); RTC_DEBUG(("onFinalize:simple connection object free finish.")); m_simple = NULL; } } catch (...) { RTC_WARN(("pa_simple_free() failed onDFinalize.")); } m_mutex.unlock(); RTC_DEBUG(("onFinalize:mutex unlock")); RTC_DEBUG(("onFinalize finish")); return RTC::RTC_OK; }
RTC::ReturnCode_t PulseAudioInput::onActivated(RTC::UniqueId ec_id) { RTC_DEBUG(("onActivated start")); try { pa_cvolume cv; // mp_vol = pa_cvolume_reset(&cv, 1); // pa_cvolume_init(mp_vol); m_spec.format = getFormat(m_formatstr); m_spec.channels = (uint8_t)m_channels; m_simple = pa_simple_new( NULL, //!< Server name, or NULL for default "PulseAudioInput", //!< A descriptive name for this client (application name, ...) PA_STREAM_RECORD, //!< Open this stream for recording or playback? NULL, //!< Sink (resp. source) name, or NULL for default "record", //!< A descriptive name for this client (application name, song title, ...) &m_spec, //!< The sample type to use NULL, //!< The channel map to use, or NULL for default NULL, //!< Buffering attributes, or NULL for default &m_err ); //!< A pointer where the error code is stored when the routine returns NULL. It is OK to pass NULL here. if ( m_simple == NULL ) { throw m_err; } } catch (...) { std::string error_str = pa_strerror(m_err); RTC_WARN(("pa_simple_new() failed onActivated:%s", error_str.c_str())); } is_active = true; RTC_DEBUG(("onActivated finish")); return RTC::RTC_OK; }
RTC::ReturnCode_t PortAudioInput::onFinalize() { RTC_DEBUG(("onFinalize start")); is_active = false; m_mutex.lock(); RTC_DEBUG(("onFinalize:mutex lock")); try { m_out_dataOut.deactivateInterfaces(); if ( m_stream ) { if ( !Pa_IsStreamStopped( m_stream ) ) { m_err = Pa_AbortStream( m_stream ); if ( m_err != paNoError ) { throw m_err; } } m_err = Pa_CloseStream( m_stream ); if ( m_err != paNoError ) { throw m_err; } m_stream = NULL; } } catch (...) { std::string error_str = Pa_GetErrorText(m_err); RTC_WARN(("PortAudio Stream close failed onFinalize:%s", error_str.c_str())); return RTC::RTC_ERROR; } m_mutex.unlock(); RTC_DEBUG(("onFinalize:mutex unlock")); RTC_DEBUG(("onFinalize finish")); return RTC::RTC_OK; }
RTC::ReturnCode_t WavPlayer::onActivated(RTC::UniqueId ec_id) { RTC_DEBUG(("onActivated start")); #if defined(__linux) RTC_INFO(("Linux platform is not supported yet.")); #elif defined(_WIN32) sfinfo.samplerate = (int)m_samplerate; sfinfo.channels = m_channels; sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16; try { sfr = sf_open(WaveFileName, SFM_READ, &sfinfo); RTC_INFO(("Wave File Name: %s\n", WaveFileName)); if (sf_format_check(&sfinfo) == 0) { RTC_DEBUG(("invalid format")); RTC_INFO(("Wave file invalid format")); return RTC::RTC_ERROR; } if (sfr == NULL) { //RTC_DEBUG(("unable to open file: %s", m_filename.c_str())); RTC_DEBUG(("unable to open file: %s", WaveFileName)); return RTC::RTC_ERROR; } m_timer = coil::gettimeofday() - 1.0; } catch (...) { RTC_WARN(("%s", "error onActivated.")); return RTC::RTC_ERROR; } #endif RTC_DEBUG(("onActivated finish")); return RTC::RTC_OK; }
RTC::ReturnCode_t PortAudioInput::onExecute(RTC::UniqueId ec_id) { RTC_DEBUG(("onExecute start")); //! The data read from the device is output. m_mutex.lock(); RTC_DEBUG(("onExecute:mutex lock")); if ( Pa_IsStreamActive(m_stream) ) { m_out_data.data.length(m_totalframes); //!< set outport data length m_err = Pa_ReadStream( m_stream, (void *)&(m_out_data.data[0]), FRAMES_PER_BUFFER ); // if( ( m_gain != 0 ) && ( m_gain != 1 ) && ( m_agc != 0 ) ) { // AutoGainControl((void *)&(m_out_data.data[0]), (int)m_totalframes ); // } if ( m_err != paNoError ) { std::string error_str = Pa_GetErrorText(m_err); RTC_WARN(("PortAudio ReadStream failed:%s", error_str.c_str())); } setTimestamp(m_out_data); m_out_dataOut.write(); } m_mutex.unlock(); RTC_DEBUG(("onExecute:mutex unlock")); RTC_DEBUG(("onExecute finish")); return RTC::RTC_OK; }
RTC::ReturnCode_t PulseAudioOutput::onActivated(RTC::UniqueId ec_id) { RTC_DEBUG(("onActivated start")); try { m_spec.format = getFormat(m_formatstr); m_spec.channels = (uint8_t)m_channels; m_spec.rate = (uint32_t)m_samplerate; m_bufferattr.maxlength = m_bufferattr.minreq = (uint32_t)-1; m_bufferattr.tlength = m_bufferattr.prebuf = (uint32_t)(m_bufferlen * m_samplerate * m_channels); m_simple = pa_simple_new(NULL, //!< Server name, or NULL for default "PulseAudioOutput", //!< A descriptive name for this client (application name, ...) PA_STREAM_PLAYBACK, //!< Open this stream for recording or playback? NULL, //!< Sink (resp. source) name, or NULL for default "playback", //!< A descriptive name for this client (application name, song title, ...) &m_spec, //!< The sample type to use NULL, //!< The channel map to use, or NULL for default &m_bufferattr, //!< Buffering attributes, or NULL for default &m_err ); //!< A pointer where the error code is stored when the routine returns NULL. It is OK to pass NULL here. if ( m_simple == NULL ) { throw m_err; } } catch (...) { std::string error_str = pa_strerror(m_err); RTC_WARN(("pa_simple_new() failed onActivated:%s", error_str.c_str())); return RTC::RTC_ERROR; } if (!m_data.empty()) { RTC_DEBUG(("onActivated:queue buffer clear start.")); m_data.clear(); //!< queue buffer clear RTC_DEBUG(("onActivated:queue buffer clear finish.")); } is_active = true; m_writezero = true; RTC_DEBUG(("onActivated finish")); return RTC::RTC_OK; }
RTC::ReturnCode_t PulseAudioInput::onExecute(RTC::UniqueId ec_id) { RTC_DEBUG(("onExecute start")); m_mutex.lock(); RTC_DEBUG(("onExecute:mutex lock")); if( m_simple ) { int r; simple_recast *psimple = (simple_recast *)m_simple; pa_threaded_mainloop_lock( psimple->mainloop ); RTC_DEBUG(("pa_threaded_mainloop_lock()")); while ( !psimple->read_data ) { r = pa_stream_peek( psimple->stream, &psimple->read_data, &psimple->read_length ); if ( !psimple->read_data ) { RTC_DEBUG(("pa_stream_peek():no readable data. wait start.")); pa_threaded_mainloop_wait(psimple->mainloop); } } m_out_data.data.length( psimple->read_length ); //!< set outport data length memcpy((void *)&(m_out_data.data[0]), (const uint8_t*) psimple->read_data, psimple->read_length); r = pa_stream_drop( psimple->stream ); if ( r < 0 ) { RTC_WARN(("pa_stream_drop():capture stream drop failed.")); } psimple->read_data = NULL; psimple->read_length = 0; psimple->read_index = 0; setTimestamp( m_out_data ); m_out_dataOut.write(); RTC_DEBUG(("AudioDataOut port:ON_BUFFER_WRITE")); pa_threaded_mainloop_unlock( psimple->mainloop ); RTC_DEBUG(("pa_threaded_mainloop_unlock()")); } m_mutex.unlock(); RTC_DEBUG(("onExecute:mutex unlock")); RTC_DEBUG(("onExecute finish")); return RTC::RTC_OK; }
RTC::ReturnCode_t PortAudioInput::onDeactivated(RTC::UniqueId ec_id) { RTC_DEBUG(("onDeactivated start")); is_active = false; m_mutex.lock(); RTC_DEBUG(("onDeactivated:mutex lock")); try { if ( m_stream ) { if ( !Pa_IsStreamStopped( m_stream ) ) { m_err = Pa_AbortStream( m_stream ); if ( m_err != paNoError ) { throw m_err; } } #ifdef HAVE_LIBPORTMIXER Px_CloseMixer(m_mixer); #elif defined(__linux) if ( m_fd > 0 ) { close( m_fd ); m_fd = -1; } #endif m_err = Pa_CloseStream( m_stream ); if ( m_err != paNoError ) { throw m_err; } m_stream = NULL; } } catch (...) { std::string error_str = Pa_GetErrorText(m_err); RTC_WARN(("PortAudio Stream close failed onDeactivated:%s", error_str.c_str())); return RTC::RTC_ERROR; } m_mutex.unlock(); RTC_DEBUG(("onDeactivated:mutex unlock")); RTC_DEBUG(("onDeactivated finish")); return RTC::RTC_OK; }
RTC::ReturnCode_t PulseAudioOutput::WriteBuffer(void) { // get writable length from audio library simple_recast *psimple = (simple_recast *)m_simple; pa_threaded_mainloop_lock(psimple->mainloop); RTC_DEBUG(("pa_threaded_mainloop_lock()")); size_t len = pa_stream_writable_size(psimple->stream); if (len == 0) { RTC_DEBUG(("WriteBufer: no writable buffer.")); pa_threaded_mainloop_unlock(psimple->mainloop); RTC_DEBUG(("pa_threaded_mainloop_unlock()")); return RTC::RTC_OK; } // now we copy the data from component buffer to audio device buffer m_mutex.lock(); RTC_DEBUG(("WriteBuffer: mutex lock")); RTC_DEBUG(("WriteBuffer: data buffer size: %i", m_data.size())); RTC_DEBUG(("WriteBuffer: device writable length: %i", len)); size_t nbytes = len; if (nbytes > m_data.size()) nbytes = m_data.size(); if (m_data.size() == 0) { if (len > m_bufferattr.tlength / 2) { RTC_DEBUG(("WriteBuffer: data buffer size is zero and device buffer size is low >> write zeros <<")); m_writezero = true; } if (m_writezero == false) { RTC_DEBUG(("WriteBufer: no writable data.")); pa_threaded_mainloop_unlock(psimple->mainloop); RTC_DEBUG(("pa_threaded_mainloop_unlock()")); m_mutex.unlock(); RTC_DEBUG(("WriteBuffer: mutex unlock")); return RTC::RTC_OK; } } else { m_writezero = false; } if (m_writezero == true) nbytes = len; if (nbytes > len) nbytes = len; // get a data buffer from the audio device void *data; RTC_DEBUG(("WriteBuffer: prepare to write %i bytes", nbytes)); if ( pa_stream_begin_write(psimple->stream, &data, &nbytes) < 0 ) { RTC_WARN(("pa_stream_begin_write() failed.", nbytes)); pa_threaded_mainloop_unlock(psimple->mainloop); RTC_DEBUG(("pa_threaded_mainloop_unlock()")); m_mutex.unlock(); RTC_DEBUG(("WriteBuffer: mutex unlock")); //return RTC::RTC_ERROR; // this sometimes happen (should retry) return RTC::RTC_OK; } // copy the data to the audio buffer RTC_DEBUG(("WriteBuffer: audio buffer dequeue start.")); unsigned char *buff = (unsigned char *)data; if (m_writezero == true) { for (unsigned long i = 0; i < (unsigned long)nbytes; i++) { *buff++ = 0; } } else { for (unsigned long i = 0; i < (unsigned long)nbytes; i++) { *buff++ = m_data.front(); m_data.pop_front(); } } RTC_DEBUG(("WriteBuffer: audio buffer dequeue finish.")); // set the data to the outport m_out_data.data.length(nbytes); //!< set outport data length memcpy((void *)&(m_out_data.data[0]), data, nbytes); RTC_DEBUG(("WriteBuffer: audio buffer copy complete.")); m_mutex.unlock(); RTC_DEBUG(("WriteBuffer: mutex unlock")); // send the data to the audio device if (pa_stream_write( psimple->stream, data, nbytes, NULL, 0, PA_SEEK_RELATIVE) < 0) { RTC_WARN(("pa_stream_write() failed.")); return RTC::RTC_ERROR; } pa_threaded_mainloop_unlock(psimple->mainloop); RTC_DEBUG(("pa_threaded_mainloop_unlock()")); // send the data to the outport setTimestamp( m_out_data ); m_out_dataOut.write(); RTC_DEBUG(("wrote stream data to AudioDataOut port")); return RTC::RTC_OK; }
RTC::ReturnCode_t PortAudioInput::onActivated(RTC::UniqueId ec_id) { RTC_DEBUG(("onActivated start")); PaStreamParameters inputParameters; // PaWasapiStreamInfo wasapiinfo; try { //m_pa_mutex.lock(); //by Irie Seisho m_format = getFormat(m_formatstr); m_totalframes = FRAMES_PER_BUFFER * m_channels; m_err = Pa_GetSampleSize(m_format); if( m_err > 0 ) { m_totalframes *= m_err; } #if 0 /* Find all WASAPI devices */ const PaDeviceInfo *device; for ( int i = 0; i < Pa_GetDeviceCount(); ++i ) { device = Pa_GetDeviceInfo(i); if ( Pa_GetDeviceInfo(i)->hostApi == Pa_HostApiTypeIdToHostApiIndex(paWASAPI) ) { std::cout << "Device Index " << i << " : " << device->name << ", inch " << device->maxInputChannels << ", outch " << device->maxOutputChannels << std::endl; } } //#if 0 PaDeviceIndex dnum = Pa_GetDeviceCount(); for (int i = 0; i < (int)dnum; i++) { std::cout << "Device Index " << i << " : " << Pa_GetDeviceInfo(i)->name << ", inch " << Pa_GetDeviceInfo(i)->maxInputChannels << ", outch " << Pa_GetDeviceInfo(i)->maxOutputChannels << std::endl; } //#endif void *pFormat; unsigned int nFormatSize; PaDeviceIndex nDevice; int r = PaWasapi_GetDeviceDefaultFormat(pFormat, nFormatSize, nDevice); #endif inputParameters.device = Pa_GetDefaultInputDevice(); //!< default input device if ( inputParameters.device < 0 ) { throw (paNotInitialized); } if ( m_channels > Pa_GetDeviceInfo(inputParameters.device)->maxInputChannels ) m_channels = Pa_GetDeviceInfo(inputParameters.device)->maxInputChannels; inputParameters.channelCount = m_channels; inputParameters.sampleFormat = m_format; inputParameters.suggestedLatency = Pa_GetDeviceInfo( inputParameters.device )->defaultLowInputLatency; /* wasapiinfo.size = sizeof(PaWasapiStreamInfo); wasapiinfo.hostApiType = paWASAPI; wasapiinfo.version = 1; wasapiinfo.flags = paWasapiUseChannelSelectors; wasapiinfo.hostProcessorInput wasapiinfo.threadPriority wasapiinfo.channelMask = outputChannelSelectors; inputParameters.hostApiSpecificStreamInfo = wasapiinfo; */ inputParameters.hostApiSpecificStreamInfo = NULL; m_err = Pa_OpenStream( &m_stream, //!< PortAudioStream &inputParameters, //!< InputParameters NULL, //!< outputParameters m_samplerate, //!< sampleRate FRAMES_PER_BUFFER, //!< framesPerBuffer paClipOff, //!< streamFlags:we won't output out of range samples so don't bother clipping // StreamCB, //!< streamCallback // this ); //!< callback userData NULL, //!< streamCallback:no callback, use blocking API NULL ); //!< no callback, so no callback userData if( m_err != paNoError ) { throw m_err; } #ifdef HAVE_LIBPORTMIXER m_mixer = Px_OpenMixer( m_stream, 0 ); m_volume = Px_GetInputVolume( m_mixer ); #else #if defined(_WIN32) if ( InitMixer() == true ) { DWORD vol; GetMicrophoneLevel(&vol); } else { CloseMixer(); } #elif defined(__linux) const char* sound_device_names[] = SOUND_DEVICE_NAMES; m_device = -1; m_fd = -1; for ( int i = 0; i < SOUND_MIXER_NRDEVICES; i ++ ) { std::cout << " device name : " << sound_device_names[i] << std::endl; if ( strcmp( "mic", sound_device_names[i] ) == 0 ) { m_device = i; break; } } if ( ( m_fd = open( "/dev/mixer", O_RDONLY ) ) == -1 ) { perror( "open" ); } #endif #endif m_err = Pa_StartStream( m_stream ); if( m_err != paNoError ) { throw m_err; } //m_pa_mutex.unlock(); //by Irie Seisho } catch (...) { std::string error_str = Pa_GetErrorText(m_err); RTC_WARN(("PortAudio failed onActivated:%s", error_str.c_str())); return RTC::RTC_ERROR; } syncflg = true; is_active = true; RTC_DEBUG(("onActivated finish")); return RTC::RTC_OK; }
/*! * @brief logfile出力のテスト * * - ログレベルを ERROR にした場合のファイル出力が正しく行われるか? */ void test_logfile_ERROR(void) { // std::cout << "test_logfile_ERROR() IN" << std::endl; coil::LogStreamBuffer logger; std::string logfile("rtcERROR.log"); std::filebuf of; of.open(logfile.c_str(), std::ios::out); if (!of.is_open()) { std::cerr << "Error: cannot open logfile: " << logfile << std::endl; } logger.addStream(&of, true); RTC::Logger rtclog(&logger); rtclog.setName("Test"); rtclog.setDateFormat("%b %d %H:%M:%S"); rtclog.setLevel("ERROR"); // 汎用ログ出力マクロ、各種ログ出力マクロで正しくファイル出力されるか? RTC_LOG( ::RTC::Logger::RTL_PARANOID,("RTL_PARANOID tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_PARANOID, "RTL_PARANOID tests str"); RTC_PARANOID( ("Macro RTL_PARANOID tests %s","fmt")); RTC_PARANOID_STR("Macro RTL_PARANOID tests str"); RTC_LOG( ::RTC::Logger::RTL_VERBOSE,("RTL_VERBOSE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_VERBOSE, "RTL_VERBOSE tests str"); RTC_VERBOSE( ("Macro RTL_VERBOSE tests %s","fmt")); RTC_VERBOSE_STR("Macro RTL_VERBOSE tests str"); RTC_LOG( ::RTC::Logger::RTL_TRACE,("RTL_TRACE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_TRACE, "RTL_TRACE tests str"); RTC_TRACE( ("Macro RTL_TRACE tests %s","fmt")); RTC_TRACE_STR("Macro RTL_TRACE tests str"); RTC_LOG( ::RTC::Logger::RTL_DEBUG,("RTL_DEBUG tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_DEBUG, "RTL_DEBUG tests str"); RTC_DEBUG( ("Macro RTL_DEBUG tests %s","fmt")); RTC_DEBUG_STR("Macro RTL_DEBUG tests str"); RTC_LOG( ::RTC::Logger::RTL_INFO,("RTL_INFO tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_INFO, "RTL_INFO tests str"); RTC_INFO( ("Macro RTL_INFO tests %s","fmt")); RTC_INFO_STR("Macro RTL_INFO tests str"); RTC_LOG( ::RTC::Logger::RTL_WARN,("RTL_WARN tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_WARN, "RTL_WARN tests str"); RTC_WARN( ("Macro RTL_WARN tests %s","fmt")); RTC_WARN_STR("Macro RTL_WARN tests str"); RTC_LOG( ::RTC::Logger::RTL_ERROR,("RTL_ERROR tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_ERROR, "RTL_ERROR tests str"); RTC_ERROR( ("Macro RTL_ERROR tests %s","fmt")); RTC_ERROR_STR("Macro RTL_ERROR tests str"); RTC_LOG( ::RTC::Logger::RTL_FATAL,("RTL_FATAL tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_FATAL, "RTL_FATAL tests str"); RTC_FATAL( ("Macro RTL_FATAL tests %s","fmt")); RTC_FATAL_STR("Macro RTL_FATAL tests str"); RTC_LOG( ::RTC::Logger::RTL_SILENT,("RTL_SILENT tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_SILENT, "RTL_SILENT tests str"); of.close(); // ファイル出力があるか? std::string rstr; std::ifstream ifs(logfile.c_str()); ifs >> rstr; CPPUNIT_ASSERT(rstr.size() > 0); ifs >> rstr; ifs >> rstr; ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("ERROR:"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("Test:"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("RTL_ERROR"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("tests"), rstr); ifs >> rstr; CPPUNIT_ASSERT_EQUAL(std::string("fmt"), rstr); // std::cout << "test_logfile_ERROR() OUT" << std::endl; }
/*! * @brief コンストラクタログレベルのテスト * * - コンストラクタ(name)の場合、Managerの設定ログレベル(INFO)で動作するか? */ void test_constract_name(void) { // std::cout << "test_constract_name() IN" << std::endl; RTC::Manager* m_mgr; m_mgr = RTC::Manager::init(0, NULL); CPPUNIT_ASSERT(m_mgr != NULL); RTC::Logger rtclog("TestName"); std::string log_level = m_mgr->getLogLevel(); CPPUNIT_ASSERT_EQUAL(std::string("INFO"), log_level); coil::Properties m_config = m_mgr->getConfig(); std::vector<std::string> logouts = coil::split(m_config["logger.file_name"], ","); // 汎用ログ出力マクロ、各種ログ出力マクロでファイル出力 RTC_LOG( ::RTC::Logger::RTL_PARANOID,("RTL_PARANOID tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_PARANOID, "RTL_PARANOID tests str"); RTC_PARANOID( ("Macro RTL_PARANOID tests %s","fmt")); RTC_PARANOID_STR("Macro RTL_PARANOID tests str"); RTC_LOG( ::RTC::Logger::RTL_VERBOSE,("RTL_VERBOSE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_VERBOSE, "RTL_VERBOSE tests str"); RTC_VERBOSE( ("Macro RTL_VERBOSE tests %s","fmt")); RTC_VERBOSE_STR("Macro RTL_VERBOSE tests str"); RTC_LOG( ::RTC::Logger::RTL_TRACE,("RTL_TRACE tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_TRACE, "RTL_TRACE tests str"); RTC_TRACE( ("Macro RTL_TRACE tests %s","fmt")); RTC_TRACE_STR("Macro RTL_TRACE tests str"); RTC_LOG( ::RTC::Logger::RTL_DEBUG,("RTL_DEBUG tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_DEBUG, "RTL_DEBUG tests str"); RTC_DEBUG( ("Macro RTL_DEBUG tests %s","fmt")); RTC_DEBUG_STR("Macro RTL_DEBUG tests str"); RTC_LOG( ::RTC::Logger::RTL_INFO,("RTL_INFO tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_INFO, "RTL_INFO tests str"); RTC_INFO( ("Macro RTL_INFO tests %s","fmt")); RTC_INFO_STR("Macro RTL_INFO tests str"); RTC_LOG( ::RTC::Logger::RTL_WARN,("RTL_WARN tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_WARN, "RTL_WARN tests str"); RTC_WARN( ("Macro RTL_WARN tests %s","fmt")); RTC_WARN_STR("Macro RTL_WARN tests str"); RTC_LOG( ::RTC::Logger::RTL_ERROR,("RTL_ERROR tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_ERROR, "RTL_ERROR tests str"); RTC_ERROR( ("Macro RTL_ERROR tests %s","fmt")); RTC_ERROR_STR("Macro RTL_ERROR tests str"); RTC_LOG( ::RTC::Logger::RTL_FATAL,("RTL_FATAL tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_FATAL, "RTL_FATAL tests str"); RTC_FATAL( ("Macro RTL_FATAL tests %s","fmt")); RTC_FATAL_STR("Macro RTL_FATAL tests str"); RTC_LOG( ::RTC::Logger::RTL_SILENT,("RTL_SILENT tests %s","fmt")); RTC_LOG_STR(::RTC::Logger::RTL_SILENT, "RTL_SILENT tests str"); m_mgr->terminate(); // rtc*.log ファイルが作成され、4列目のログレベルが INFO以下か? // INFO WARNING ERROR FATAL SILENT だけが記録されているか? // Aug 03 14:03:09 INFO: manager: OpenRTM-aist-1.0.0 // [0] 1 2 3 4 5 std::string rstr; std::vector<std::string> vstr; bool bret; std::ifstream ifs(logouts[0].c_str()); while(getline(ifs, rstr)) { if(rstr.size() == 0) break; vstr = coil::split(rstr, " "); // ログレベル判定 bret = false; if( (vstr[3] == "INFO:") || (vstr[3] == "WARNING:") || (vstr[3] == "ERROR:") || (vstr[3] == "FATAL:") || (vstr[3] == "SILENT:") ) bret = true; CPPUNIT_ASSERT(bret); // name判定 bret = false; if( (vstr[4] == "manager:") || (vstr[4] == "TestName:") || (vstr[4] == "NamingOnCorba:") || (vstr[4] == "NamingManager:") || (vstr[4] == "ManagerServant:") ) bret = true; CPPUNIT_ASSERT(bret); } // std::cout << "test_constract_name() OUT" << std::endl; }