ref: 41720f8df5812634c500a9c5a45ed99bd88f2986
parent: 195d13612ce421c0263416e52299464b4c048cc4
author: Sijia Chen <[email protected]>
date: Thu Oct 23 12:38:05 EDT 2014
add a thread name for easier profiling
--- a/codec/common/inc/WelsThreadLib.h
+++ b/codec/common/inc/WelsThreadLib.h
@@ -117,6 +117,8 @@
WELS_THREAD_ERROR_CODE WelsThreadCreate (WELS_THREAD_HANDLE* thread, LPWELS_THREAD_ROUTINE routine,
void* arg, WELS_THREAD_ATTR attr);
+WELS_THREAD_ERROR_CODE WelsThreadSetName (const char* thread_name);
+
WELS_THREAD_ERROR_CODE WelsThreadJoin (WELS_THREAD_HANDLE thread);
WELS_THREAD_HANDLE WelsThreadSelf();
--- a/codec/common/src/WelsThreadLib.cpp
+++ b/codec/common/src/WelsThreadLib.cpp
@@ -195,6 +195,12 @@
return WELS_THREAD_ERROR_OK;
}
+WELS_THREAD_ERROR_CODE WelsThreadSetName (const char* thread_name) {
+ // do nothing
+ return WELS_THREAD_ERROR_OK;
+}
+
+
WELS_THREAD_ERROR_CODE WelsThreadJoin (WELS_THREAD_HANDLE thread) {
WaitForSingleObject (thread, INFINITE);
CloseHandle (thread);
@@ -240,6 +246,17 @@
pthread_attr_destroy (&at);
return err;
+}
+
+WELS_THREAD_ERROR_CODE WelsThreadSetName (const char* thread_name) {
+#ifdef APPLE_IOS
+ pthread_setname_np(thread_name);
+#endif
+#ifdef __ANDROID__
+ pthread_setname_np(pthread_self(), thread_name);
+#endif
+ // do nothing
+ return WELS_THREAD_ERROR_OK;
}
WELS_THREAD_ERROR_CODE WelsThreadJoin (WELS_THREAD_HANDLE thread) {
--- a/codec/encoder/core/src/slice_multi_threading.cpp
+++ b/codec/encoder/core/src/slice_multi_threading.cpp
@@ -705,6 +705,8 @@
pEventsList[iEventCount++] = pEncPEncCtx->pSliceThreading->pExitEncodeEvent[iEventIdx];
pEventsList[iEventCount++] = pEncPEncCtx->pSliceThreading->pUpdateMbListEvent[iEventIdx];
+ WelsThreadSetName ("OpenH264Enc_CodingSliceThreadProc");
+
do {
MT_TRACE_LOG (pEncPEncCtx, WELS_LOG_INFO,
"[MT] CodingSliceThreadProc(), try to call WelsMultipleEventsWaitSingleBlocking(pEventsList= %p %p %p), pEncPEncCtx= %p!",