From 93c2e681ca0f548150866bb68947a527a94f7bb8 Mon Sep 17 00:00:00 2001 From: obiwac Date: Sat, 26 Feb 2022 13:50:21 +0100 Subject: [PATCH] linux-v4l2: scandir with alphasort on non-Linux Sort video device entries with `alphasort` on non-Linux platforms, as opposed to `versionsort` on Linux. (`versionsort` is a GNU extension, unavailable on e.g. FreeBSD.) UI: Fix call to `to_string` on FreeBSD --- UI/platform-x11.cpp | 2 +- plugins/linux-v4l2/v4l2-output.c | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/UI/platform-x11.cpp b/UI/platform-x11.cpp index 536b1ea86..d4fc81674 100644 --- a/UI/platform-x11.cpp +++ b/UI/platform-x11.cpp @@ -136,7 +136,7 @@ const char *RunOnce::thr_name = "OBS runonce"; void PIDFileCheck(bool &already_running) { std::string tmpfile_name = - "/tmp/obs-studio.lock." + to_string(geteuid()); + "/tmp/obs-studio.lock." + std::to_string(geteuid()); int fd = open(tmpfile_name.c_str(), O_RDWR | O_CREAT | O_EXLOCK, 0600); if (fd == -1) { already_running = true; diff --git a/plugins/linux-v4l2/v4l2-output.c b/plugins/linux-v4l2/v4l2-output.c index 2c39544ed..5ab423fbb 100644 --- a/plugins/linux-v4l2/v4l2-output.c +++ b/plugins/linux-v4l2/v4l2-output.c @@ -185,7 +185,14 @@ static bool virtualcam_start(void *data) return false; } - n = scandir("/dev", &list, scanfilter, versionsort); + n = scandir("/dev", &list, scanfilter, +#if defined(__linux__) + versionsort +#else + alphasort +#endif + ); + if (n == -1) return false;