linux-v4l2: Improve module detection
Expand PATH for Debian-like systems. Improve detection when the module is already loaded.
This commit is contained in:
parent
d8a253c42f
commit
d8a25ef943
@ -26,18 +26,7 @@ MODULE_EXPORT const char *obs_module_description(void)
|
||||
|
||||
extern struct obs_source_info v4l2_input;
|
||||
extern struct obs_output_info virtualcam_info;
|
||||
|
||||
static bool v4l2loopback_installed()
|
||||
{
|
||||
bool loaded = false;
|
||||
|
||||
int ret = system("modinfo v4l2loopback >/dev/null 2>&1");
|
||||
|
||||
if (ret == 0)
|
||||
loaded = true;
|
||||
|
||||
return loaded;
|
||||
}
|
||||
extern bool loopback_module_available();
|
||||
|
||||
bool obs_module_load(void)
|
||||
{
|
||||
@ -45,7 +34,7 @@ bool obs_module_load(void)
|
||||
|
||||
obs_data_t *obs_settings = obs_data_create();
|
||||
|
||||
if (v4l2loopback_installed()) {
|
||||
if (loopback_module_available()) {
|
||||
obs_register_output(&virtualcam_info);
|
||||
obs_data_set_bool(obs_settings, "vcamEnabled", true);
|
||||
} else {
|
||||
|
@ -50,10 +50,24 @@ static bool loopback_module_loaded()
|
||||
return loaded;
|
||||
}
|
||||
|
||||
bool loopback_module_available()
|
||||
{
|
||||
if (loopback_module_loaded()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (system("PATH=\"$PATH:/sbin\" modinfo v4l2loopback >/dev/null 2>&1") ==
|
||||
0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static int loopback_module_load()
|
||||
{
|
||||
return system(
|
||||
"pkexec modprobe v4l2loopback exclusive_caps=1 card_label='OBS Virtual Camera' && sleep 0.5");
|
||||
"PATH=\"$PATH:/sbin\" pkexec modprobe v4l2loopback exclusive_caps=1 card_label='OBS Virtual Camera' && sleep 0.5");
|
||||
}
|
||||
|
||||
static void *virtualcam_create(obs_data_t *settings, obs_output_t *output)
|
||||
|
Loading…
x
Reference in New Issue
Block a user