Skip to content

Commit d01af96

Browse files
committed
Minor: assign thread name; fix compilation warnings
* Don't capture static global variables into closures * Keep _GNU_SOURCE in order
1 parent 5f72b95 commit d01af96

File tree

5 files changed

+12
-5
lines changed

5 files changed

+12
-5
lines changed

src/drm.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#ifndef DRM_H
88
#define DRM_H
99

10-
#define _GNU_SOURCE
1110
#include <errno.h>
1211
#include <fcntl.h>
1312
#include <stdbool.h>

src/dvr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#include <pthread.h>
32
#include <stdio.h>
43
#include <stdlib.h>
@@ -90,6 +89,7 @@ void Dvr::enqueue_dvr_command(dvr_rpc rpc) {
9089
}
9190

9291
void *Dvr::__THREAD__(void *param) {
92+
pthread_setname_np(pthread_self(), "__DVR");
9393
((Dvr *)param)->loop();
9494
return nullptr;
9595
}
@@ -225,4 +225,4 @@ extern "C" {
225225
dvr->stop_recording();
226226
}
227227
}
228-
}
228+
}

src/main.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ void *__FRAME_THREAD__(void *param)
183183
int i, ret;
184184
MppFrame frame = NULL;
185185
uint64_t last_frame_time;
186+
pthread_setname_np(pthread_self(), "__FRAME");
186187

187188
while (!frm_eos) {
188189
struct timespec ts, ats;
@@ -249,6 +250,8 @@ void *__DISPLAY_THREAD__(void *param)
249250
float min_latency = 1844674407370955161; // almost MAX_uint64_t
250251
float max_latency = 0;
251252
struct timespec fps_start, fps_end;
253+
254+
pthread_setname_np(pthread_self(), "__DISPLAY");
252255
clock_gettime(CLOCK_MONOTONIC, &fps_start);
253256

254257
while (!frm_eos) {
@@ -379,7 +382,7 @@ void read_gstreamerpipe_stream(MppPacket *packet, int gst_udp_port, const VideoC
379382
GstRtpReceiver receiver(gst_udp_port, codec);
380383
long long bytes_received = 0;
381384
uint64_t period_start=0;
382-
auto cb=[&packet,&decoder_stalled_count, &bytes_received, &period_start](std::shared_ptr<std::vector<uint8_t>> frame){
385+
auto cb=[&packet,/*&decoder_stalled_count,*/ &bytes_received, &period_start](std::shared_ptr<std::vector<uint8_t>> frame){
383386
// Let the gst pull thread run at quite high priority
384387
static bool first= false;
385388
if(first){

src/mavlink.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#define _GNU_SOURCE
12
#include <sys/prctl.h>
23
#include <errno.h>
34
#include <fcntl.h>
@@ -9,6 +10,7 @@
910
#include <sys/stat.h>
1011
#include <sys/types.h>
1112
#include <unistd.h>
13+
#include <pthread.h>
1214

1315
#include <arpa/inet.h>
1416
#include <netinet/in.h>
@@ -83,6 +85,7 @@ int mavlink_port = 14550;
8385
int mavlink_thread_signal = 0;
8486

8587
void* __MAVLINK_THREAD__(void* arg) {
88+
pthread_setname_np(pthread_self(), "__MAVLINK");
8689
printf("Starting mavlink thread...\n");
8790
// Create socket
8891
int fd = socket(AF_INET, SOCK_DGRAM, 0);

src/osd.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
1+
#define _GNU_SOURCE
22
#include "osd.h"
33

44
#include "drm.h"
55
#include <cairo.h>
6+
#include <pthread.h>
67
#include "mavlink.h"
78
#include "icons/icons.h"
89

@@ -303,6 +304,7 @@ cairo_surface_t * surface_from_embedded_png(const unsigned char * png, size_t le
303304

304305
void *__OSD_THREAD__(void *param) {
305306
osd_thread_params *p = param;
307+
pthread_setname_np(pthread_self(), "__OSD");
306308
fps_icon = surface_from_embedded_png(framerate_icon, framerate_icon_length);
307309
lat_icon = surface_from_embedded_png(latency_icon, latency_icon_length);
308310
net_icon = surface_from_embedded_png(bandwidth_icon, bandwidth_icon_length);

0 commit comments

Comments
 (0)