1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

refine log and thread function name

This commit is contained in:
winlin 2014-04-04 12:18:05 +08:00
parent 1117f78587
commit 6d32ad1828
8 changed files with 19 additions and 17 deletions

View file

@ -686,13 +686,15 @@ int SrsConfig::parse_file(const char* filename)
// check log // check log
std::string log_filename = this->get_srs_log_file(); std::string log_filename = this->get_srs_log_file();
if (this->get_srs_log_tank_file() && log_filename.empty()) { if (get_srs_log_tank_file() && log_filename.empty()) {
ret = ERROR_SYSTEM_CONFIG_INVALID; ret = ERROR_SYSTEM_CONFIG_INVALID;
srs_error("must specifies the file to write log to. ret=%d", ret); srs_error("must specifies the file to write log to. ret=%d", ret);
return ret; return ret;
} }
if (!log_filename.empty()) { if (get_srs_log_tank_file()) {
srs_trace("log file is %s", log_filename.c_str()); srs_trace("log file is %s", log_filename.c_str());
} else {
srs_trace("write log to console");
} }
return ret; return ret;

View file

@ -569,7 +569,7 @@ int SrsEncoder::cycle()
return ret; return ret;
} }
void SrsEncoder::on_leave_loop() void SrsEncoder::on_thread_stop()
{ {
// kill ffmpeg when finished and it alive // kill ffmpeg when finished and it alive
std::vector<SrsFFMPEG*>::iterator it; std::vector<SrsFFMPEG*>::iterator it;

View file

@ -101,7 +101,7 @@ public:
// interface ISrsThreadHandler. // interface ISrsThreadHandler.
public: public:
virtual int cycle(); virtual int cycle();
virtual void on_leave_loop(); virtual void on_thread_stop();
private: private:
virtual void clear_engines(); virtual void clear_engines();
virtual SrsFFMPEG* at(int index); virtual SrsFFMPEG* at(int index);

View file

@ -126,7 +126,7 @@ int SrsListener::listen(int _port)
return ret; return ret;
} }
void SrsListener::on_enter_loop() void SrsListener::on_thread_start()
{ {
srs_trace("listen cycle start, port=%d, type=%d, fd=%d", port, type, fd); srs_trace("listen cycle start, port=%d, type=%d, fd=%d", port, type, fd);
} }

View file

@ -69,7 +69,7 @@ public:
virtual int listen(int port); virtual int listen(int port);
// interface ISrsThreadHandler. // interface ISrsThreadHandler.
public: public:
virtual void on_enter_loop(); virtual void on_thread_start();
virtual int cycle(); virtual int cycle();
}; };

View file

@ -34,7 +34,7 @@ ISrsThreadHandler::~ISrsThreadHandler()
{ {
} }
void ISrsThreadHandler::on_enter_loop() void ISrsThreadHandler::on_thread_start()
{ {
} }
@ -50,7 +50,7 @@ int ISrsThreadHandler::on_end_cycle()
return ret; return ret;
} }
void ISrsThreadHandler::on_leave_loop() void ISrsThreadHandler::on_thread_stop()
{ {
} }
@ -114,9 +114,9 @@ void SrsThread::thread_cycle()
srs_assert(handler); srs_assert(handler);
_srs_context->generate_id(); _srs_context->generate_id();
srs_trace("thread cycle start"); srs_info("thread cycle start");
handler->on_end_cycle(); handler->on_thread_start();
loop = true; loop = true;
while (loop) { while (loop) {
@ -146,7 +146,7 @@ failed:
st_usleep(cycle_interval_us); st_usleep(cycle_interval_us);
} }
handler->on_leave_loop(); handler->on_thread_stop();
srs_trace("thread cycle finished"); srs_trace("thread cycle finished");
} }

View file

@ -34,14 +34,14 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/** /**
* the handler for the thread, callback interface. * the handler for the thread, callback interface.
* the thread model defines as: * the thread model defines as:
* handler->on_enter_loop() * handler->on_thread_start()
* while loop: * while loop:
* handler->on_before_cycle() * handler->on_before_cycle()
* handler->cycle() * handler->cycle()
* handler->on_end_cycle() * handler->on_end_cycle()
* if !loop then break for user stop thread. * if !loop then break for user stop thread.
* sleep(CycleIntervalMilliseconds) * sleep(CycleIntervalMilliseconds)
* handler->on_leave_loop() * handler->on_thread_stop()
* when stop, the thread will interrupt the st_thread, * when stop, the thread will interrupt the st_thread,
* which will cause the socket to return error and * which will cause the socket to return error and
* terminate the cycle thread. * terminate the cycle thread.
@ -69,11 +69,11 @@ public:
ISrsThreadHandler(); ISrsThreadHandler();
virtual ~ISrsThreadHandler(); virtual ~ISrsThreadHandler();
public: public:
virtual void on_enter_loop(); virtual void on_thread_start();
virtual int on_before_cycle(); virtual int on_before_cycle();
virtual int cycle() = 0; virtual int cycle() = 0;
virtual int on_end_cycle(); virtual int on_end_cycle();
virtual void on_leave_loop(); virtual void on_thread_stop();
}; };
/** /**

View file

@ -166,8 +166,8 @@ string srs_client_type_string(SrsRtmpConnType type)
{ {
switch (type) { switch (type) {
case SrsRtmpConnPlay: return "Play"; case SrsRtmpConnPlay: return "Play";
case SrsRtmpConnFlashPublish: return "FlashPublish"; case SrsRtmpConnFlashPublish: return "publish(FlashPublish)";
case SrsRtmpConnFMLEPublish: return "FMLEPublish"; case SrsRtmpConnFMLEPublish: return "publish(FMLEPublish)";
default: return "Unknown"; default: return "Unknown";
} }
return "Unknown"; return "Unknown";