Skip to content

Commit 7e0912f

Browse files
committed
add --disable-vsync option
1 parent f16a99b commit 7e0912f

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

src/main.cpp

+30-1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ int video_zpos = 1;
8484

8585
bool mavlink_dvr_on_arm = false;
8686
bool osd_custom_message = false;
87+
bool disable_vsync = false;
8788

8889
VideoCodec codec = VideoCodec::H265;
8990
Dvr *dvr = NULL;
@@ -294,7 +295,7 @@ void *__DISPLAY_THREAD__(void *param)
294295
// show DRM FB in plane
295296
uint32_t flags = DRM_MODE_ATOMIC_NONBLOCK;
296297
if (fb_id != 0) {
297-
flags = DRM_MODE_ATOMIC_ALLOW_MODESET;
298+
flags = disable_vsync ? DRM_MODE_ATOMIC_NONBLOCK : DRM_MODE_ATOMIC_ALLOW_MODESET;
298299
ret = set_drm_object_property(output_list->video_request, &output_list->video_plane, "FB_ID", fb_id);
299300
assert(ret>0);
300301
}
@@ -376,6 +377,24 @@ void sigusr1_handler(int signum) {
376377
}
377378
}
378379

380+
void sigusr2_handler(int signum) {
381+
// Toggle the disable_vsync flag
382+
disable_vsync = disable_vsync ^ 1;
383+
384+
// Open the file for writing
385+
std::ofstream outFile("/run/pixelpilot.msg");
386+
if (!outFile.is_open()) {
387+
spdlog::error("Error opening file!");
388+
return; // Exit the function if the file cannot be opened
389+
}
390+
391+
// Write the formatted text to the file
392+
outFile << "disable_vsync: " << std::boolalpha << disable_vsync << std::endl;
393+
outFile.close();
394+
395+
// Log the new state of disable_vsync
396+
spdlog::info("disable_vsync: {}", disable_vsync);
397+
}
379398

380399
int decoder_stalled_count=0;
381400
bool feed_packet_to_decoder(MppPacket *packet,void* data_p,int data_len){
@@ -532,6 +551,8 @@ void printHelp() {
532551
"\n"
533552
" --screen-mode <mode> - Override default screen mode. <width>x<heigth>@<fps> ex: 1920x1080@120\n"
534553
"\n"
554+
" --disable-vsync - Disable VSYNC commits\n"
555+
"\n"
535556
" --screen-mode-list - Print the list of supported screen modes and exit.\n"
536557
"\n"
537558
" --version - Show program version\n"
@@ -709,6 +730,11 @@ int main(int argc, char **argv)
709730
continue;
710731
}
711732

733+
__OnArgument("--disable-vsync") {
734+
disable_vsync = true;
735+
continue;
736+
}
737+
712738
__OnArgument("--screen-mode-list") {
713739
print_modelist = 1;
714740
continue;
@@ -730,6 +756,8 @@ int main(int argc, char **argv)
730756

731757
printf("PixelPilot Rockchip %d.%d\n", APP_VERSION_MAJOR, APP_VERSION_MINOR);
732758

759+
spdlog::info("disable_vsync: {}", disable_vsync);
760+
733761
if (enable_osd == 0 ) {
734762
video_zpos = 4;
735763
}
@@ -788,6 +816,7 @@ int main(int argc, char **argv)
788816
if (dvr_template) {
789817
signal(SIGUSR1, sigusr1_handler);
790818
}
819+
signal(SIGUSR2, sigusr2_handler);
791820
//////////////////// THREADS SETUP
792821

793822
ret = pthread_mutex_init(&video_mutex, NULL);

0 commit comments

Comments
 (0)