Rename scrcpy threads

Prefix the name of threads by "scrcpy-". This improves readability in
the output of `top -H` for example.

Limit the thread names to 16 bytes, because it is limited on some
platforms.
windows_icon
Romain Vimont 3 years ago
parent 09c55b0f93
commit 3ada5c51bc

@ -373,7 +373,7 @@ bool
sc_aoa_start(struct sc_aoa *aoa) { sc_aoa_start(struct sc_aoa *aoa) {
LOGD("Starting AOA thread"); LOGD("Starting AOA thread");
bool ok = sc_thread_create(&aoa->thread, run_aoa_thread, "aoa_thread", aoa); bool ok = sc_thread_create(&aoa->thread, run_aoa_thread, "scrcpy-aoa", aoa);
if (!ok) { if (!ok) {
LOGC("Could not start AOA thread"); LOGC("Could not start AOA thread");
return false; return false;

@ -110,7 +110,7 @@ controller_start(struct controller *controller) {
LOGD("Starting controller thread"); LOGD("Starting controller thread");
bool ok = sc_thread_create(&controller->thread, run_controller, bool ok = sc_thread_create(&controller->thread, run_controller,
"controller", controller); "scrcpy-ctl", controller);
if (!ok) { if (!ok) {
LOGC("Could not start controller thread"); LOGC("Could not start controller thread");
return false; return false;

@ -154,7 +154,7 @@ file_handler_start(struct file_handler *file_handler) {
LOGD("Starting file_handler thread"); LOGD("Starting file_handler thread");
bool ok = sc_thread_create(&file_handler->thread, run_file_handler, bool ok = sc_thread_create(&file_handler->thread, run_file_handler,
"file_handler", file_handler); "scrcpy-file", file_handler);
if (!ok) { if (!ok) {
LOGC("Could not start file_handler thread"); LOGC("Could not start file_handler thread");
return false; return false;

@ -108,7 +108,7 @@ fps_counter_start(struct fps_counter *counter) {
// same thread, no need to lock // same thread, no need to lock
if (!counter->thread_started) { if (!counter->thread_started) {
bool ok = sc_thread_create(&counter->thread, run_fps_counter, bool ok = sc_thread_create(&counter->thread, run_fps_counter,
"fps counter", counter); "scrcpy-fps", counter);
if (!ok) { if (!ok) {
LOGE("Could not start FPS counter thread"); LOGE("Could not start FPS counter thread");
return false; return false;

@ -111,8 +111,8 @@ bool
receiver_start(struct receiver *receiver) { receiver_start(struct receiver *receiver) {
LOGD("Starting receiver thread"); LOGD("Starting receiver thread");
bool ok = sc_thread_create(&receiver->thread, run_receiver, "receiver", bool ok = sc_thread_create(&receiver->thread, run_receiver,
receiver); "scrcpy-receiver", receiver);
if (!ok) { if (!ok) {
LOGC("Could not start receiver thread"); LOGC("Could not start receiver thread");
return false; return false;

@ -287,8 +287,8 @@ recorder_open(struct recorder *recorder, const AVCodec *input_codec) {
} }
LOGD("Starting recorder thread"); LOGD("Starting recorder thread");
ok = sc_thread_create(&recorder->thread, run_recorder, "recorder", ok = sc_thread_create(&recorder->thread, run_recorder, "scrcpy-recorder",
recorder); recorder);
if (!ok) { if (!ok) {
LOGC("Could not start recorder thread"); LOGC("Could not start recorder thread");
goto error_avio_close; goto error_avio_close;

@ -804,7 +804,8 @@ error_connection_failed:
bool bool
sc_server_start(struct sc_server *server) { sc_server_start(struct sc_server *server) {
bool ok = sc_thread_create(&server->thread, run_server, "server", server); bool ok =
sc_thread_create(&server->thread, run_server, "scrcpy-server", server);
if (!ok) { if (!ok) {
LOGE("Could not create server thread"); LOGE("Could not create server thread");
return false; return false;

@ -284,7 +284,8 @@ bool
stream_start(struct stream *stream) { stream_start(struct stream *stream) {
LOGD("Starting stream thread"); LOGD("Starting stream thread");
bool ok = sc_thread_create(&stream->thread, run_stream, "stream", stream); bool ok =
sc_thread_create(&stream->thread, run_stream, "scrcpy-stream", stream);
if (!ok) { if (!ok) {
LOGC("Could not start stream thread"); LOGC("Could not start stream thread");
return false; return false;

@ -64,7 +64,7 @@ sc_process_observer_init(struct sc_process_observer *observer, sc_pid pid,
observer->listener_userdata = listener_userdata; observer->listener_userdata = listener_userdata;
observer->terminated = false; observer->terminated = false;
ok = sc_thread_create(&observer->thread, run_observer, "process_observer", ok = sc_thread_create(&observer->thread, run_observer, "scrcpy-proc",
observer); observer);
if (!ok) { if (!ok) {
sc_cond_destroy(&observer->cond_terminated); sc_cond_destroy(&observer->cond_terminated);

@ -8,6 +8,10 @@
bool bool
sc_thread_create(sc_thread *thread, sc_thread_fn fn, const char *name, sc_thread_create(sc_thread *thread, sc_thread_fn fn, const char *name,
void *userdata) { void *userdata) {
// The thread name length is limited on some systems. Never use a name
// longer than 16 bytes (including the final '\0')
assert(strlen(name) <= 15);
SDL_Thread *sdl_thread = SDL_CreateThread(fn, name, userdata); SDL_Thread *sdl_thread = SDL_CreateThread(fn, name, userdata);
if (!sdl_thread) { if (!sdl_thread) {
LOG_OOM(); LOG_OOM();

@ -272,7 +272,7 @@ sc_v4l2_sink_open(struct sc_v4l2_sink *vs) {
vs->stopped = false; vs->stopped = false;
LOGD("Starting v4l2 thread"); LOGD("Starting v4l2 thread");
ok = sc_thread_create(&vs->thread, run_v4l2_sink, "v4l2", vs); ok = sc_thread_create(&vs->thread, run_v4l2_sink, "scrcpy-v4l2", vs);
if (!ok) { if (!ok) {
LOGC("Could not start v4l2 thread"); LOGC("Could not start v4l2 thread");
goto error_av_packet_free; goto error_av_packet_free;

@ -170,7 +170,7 @@ bool
sc_video_buffer_start(struct sc_video_buffer *vb) { sc_video_buffer_start(struct sc_video_buffer *vb) {
if (vb->buffering_time) { if (vb->buffering_time) {
bool ok = bool ok =
sc_thread_create(&vb->b.thread, run_buffering, "buffering", vb); sc_thread_create(&vb->b.thread, run_buffering, "scrcpy-vbuf", vb);
if (!ok) { if (!ok) {
LOGE("Could not start buffering thread"); LOGE("Could not start buffering thread");
return false; return false;

Loading…
Cancel
Save