diff --git a/app/src/aoa_hid.c b/app/src/aoa_hid.c index a3fc3bd4..abf74cf9 100644 --- a/app/src/aoa_hid.c +++ b/app/src/aoa_hid.c @@ -373,7 +373,7 @@ bool sc_aoa_start(struct sc_aoa *aoa) { 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) { LOGC("Could not start AOA thread"); return false; diff --git a/app/src/controller.c b/app/src/controller.c index 6cf3d20e..10eceaf2 100644 --- a/app/src/controller.c +++ b/app/src/controller.c @@ -110,7 +110,7 @@ controller_start(struct controller *controller) { LOGD("Starting controller thread"); bool ok = sc_thread_create(&controller->thread, run_controller, - "controller", controller); + "scrcpy-ctl", controller); if (!ok) { LOGC("Could not start controller thread"); return false; diff --git a/app/src/file_handler.c b/app/src/file_handler.c index addbb9a5..95d230ae 100644 --- a/app/src/file_handler.c +++ b/app/src/file_handler.c @@ -154,7 +154,7 @@ file_handler_start(struct file_handler *file_handler) { LOGD("Starting file_handler thread"); bool ok = sc_thread_create(&file_handler->thread, run_file_handler, - "file_handler", file_handler); + "scrcpy-file", file_handler); if (!ok) { LOGC("Could not start file_handler thread"); return false; diff --git a/app/src/fps_counter.c b/app/src/fps_counter.c index c92d4140..25ee00eb 100644 --- a/app/src/fps_counter.c +++ b/app/src/fps_counter.c @@ -108,7 +108,7 @@ fps_counter_start(struct fps_counter *counter) { // same thread, no need to lock if (!counter->thread_started) { bool ok = sc_thread_create(&counter->thread, run_fps_counter, - "fps counter", counter); + "scrcpy-fps", counter); if (!ok) { LOGE("Could not start FPS counter thread"); return false; diff --git a/app/src/receiver.c b/app/src/receiver.c index eeb206f1..1e25536e 100644 --- a/app/src/receiver.c +++ b/app/src/receiver.c @@ -111,8 +111,8 @@ bool receiver_start(struct receiver *receiver) { LOGD("Starting receiver thread"); - bool ok = sc_thread_create(&receiver->thread, run_receiver, "receiver", - receiver); + bool ok = sc_thread_create(&receiver->thread, run_receiver, + "scrcpy-receiver", receiver); if (!ok) { LOGC("Could not start receiver thread"); return false; diff --git a/app/src/recorder.c b/app/src/recorder.c index 4364b9a5..74cfce07 100644 --- a/app/src/recorder.c +++ b/app/src/recorder.c @@ -287,8 +287,8 @@ recorder_open(struct recorder *recorder, const AVCodec *input_codec) { } LOGD("Starting recorder thread"); - ok = sc_thread_create(&recorder->thread, run_recorder, "recorder", - recorder); + ok = sc_thread_create(&recorder->thread, run_recorder, "scrcpy-recorder", + recorder); if (!ok) { LOGC("Could not start recorder thread"); goto error_avio_close; diff --git a/app/src/server.c b/app/src/server.c index e89a6f10..3b7a0fcc 100644 --- a/app/src/server.c +++ b/app/src/server.c @@ -804,7 +804,8 @@ error_connection_failed: bool 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) { LOGE("Could not create server thread"); return false; diff --git a/app/src/stream.c b/app/src/stream.c index 3ac0f5e1..f8d73a27 100644 --- a/app/src/stream.c +++ b/app/src/stream.c @@ -284,7 +284,8 @@ bool stream_start(struct stream *stream) { 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) { LOGC("Could not start stream thread"); return false; diff --git a/app/src/util/process.c b/app/src/util/process.c index ad1af0a9..9c4dcd9f 100644 --- a/app/src/util/process.c +++ b/app/src/util/process.c @@ -64,7 +64,7 @@ sc_process_observer_init(struct sc_process_observer *observer, sc_pid pid, observer->listener_userdata = listener_userdata; observer->terminated = false; - ok = sc_thread_create(&observer->thread, run_observer, "process_observer", + ok = sc_thread_create(&observer->thread, run_observer, "scrcpy-proc", observer); if (!ok) { sc_cond_destroy(&observer->cond_terminated); diff --git a/app/src/util/thread.c b/app/src/util/thread.c index 23eddf1d..c6e6b81e 100644 --- a/app/src/util/thread.c +++ b/app/src/util/thread.c @@ -8,6 +8,10 @@ bool sc_thread_create(sc_thread *thread, sc_thread_fn fn, const char *name, 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); if (!sdl_thread) { LOG_OOM(); diff --git a/app/src/v4l2_sink.c b/app/src/v4l2_sink.c index dce11ce1..7675fd92 100644 --- a/app/src/v4l2_sink.c +++ b/app/src/v4l2_sink.c @@ -272,7 +272,7 @@ sc_v4l2_sink_open(struct sc_v4l2_sink *vs) { vs->stopped = false; 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) { LOGC("Could not start v4l2 thread"); goto error_av_packet_free; diff --git a/app/src/video_buffer.c b/app/src/video_buffer.c index 12e66cf1..11f76479 100644 --- a/app/src/video_buffer.c +++ b/app/src/video_buffer.c @@ -170,7 +170,7 @@ bool sc_video_buffer_start(struct sc_video_buffer *vb) { if (vb->buffering_time) { 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) { LOGE("Could not start buffering thread"); return false;