-
-
Notifications
You must be signed in to change notification settings - Fork 7.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix building OBS Studio on FreeBSD #6026
Conversation
I don't think we will want to include an implementation of versionsort from glibc just for freebsd. Is there an alternative function that can be used on freebsd? |
Yeah, it's not ideal indeed, but again, to my knowledge and after a good look, I don't think there is. Also,
I guess I could implement a bit of a simpler sorting function without considering the fractional part for both Linux & FreeBSD? |
It seems a decent solution to enable building on freebsd without introducing a large amount of platform specific code. You could consider leaving the results unsorted on freebsd as well perhaps the devices will simply be in the proper order for most users. |
From CI:
|
Can confirm this is not the case, unfortunately :( Something like this could always be used: static int devsort(const struct dirent **_a, const struct dirent **_b) {
int a = atoi((*_a)->d_name + 5);
int b = atoi((*_b)->d_name + 5);
return a - b;
} This would eliminate the need for any platform specific code whatsoever, as it works both on Linux & FreeBSD. (Strings aren't sorted if not numeric.)
That's my bad, still figuring out how to use this |
After feedback from obsproject#6026, replace implementation of versionsort on FreeBSD by scansort on both Linux & FreeBSD. This sorts /dev/video* devices by their numeric part.
Implemented that function I mentioned in my previous comment. Is it better like that or should I just choose between |
I would prefer a function that wont do bad things in case it gets odd input, and it seems the only one available for BSD users with libc is alphasort. Though I suspect no one will sort before filtering in their scandir implementation but if they did, us reading invalid memory is not a good idea. |
Sure, I was operating under that assumption initially, and from that point of view I don't think anything bad could happen. Regardless, I'll replace it with a simple |
Done |
Please squash away the obsoleted commits, after that it seems good to merge. |
Yup, of course |
1d39a71
to
d671c49
Compare
There we go! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You squashed the to_string fix into the v4l2 fix if you could split that back out or make note in the commit desc.
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
There we go. |
Description
Fix building OBS Studio on FreeBSD:
libobs/graphics/graphics.h
: Thegs_texture_create_from_dmabuf
&gs_query_dmabuf_*
functions were marked as Linux-only as of f7a55f4.plugins/linux-v4l2/v4l2-output.c
:versionsort
(and by extension,__strverscmp
) are not available on FreeBSD, as they are GNU extensions (versionsort
is used byvirtualcam_start
to read/dev/video*
devices in the right order), so implemented them.UI/platform-x11.cpp
: Was callingto_string
on FreeBSD when notusing namespace std;
, so callingstd::to_string
instead.Motivation and Context
Fixes building on FreeBSD.
How Has This Been Tested?
Tested on FreeBSD 13.0-RELEASE-p4 and FreeBSD-CURRENT, hardware is non-applicable.
Compiled with clang version 11.0.1 & 13.0.1.
Types of changes
Checklist:
Perhaps this is usererror, but
git-clang-format
doesn't seem to work?So I attempted to format things myself.
Hope that's alright :)