CatxFish / obs-v4l2sink

obs studio output plugin for Video4Linux2 device
GNU General Public License v2.0
930 stars 99 forks source link

adjust v4l2device_close to void #21

Closed treister closed 3 years ago

treister commented 4 years ago

Minor defect when compiling.

obs-v4l2sink/src/v4l2sink.cpp: In function ‘bool v4l2device_close(void*)’:
obs-v4l2sink/src/v4l2sink.cpp:217:1: warning: no return statement in function returning non-void [-Wreturn-type]
  217 | }
      | ^

make --version

cmake version 3.13.4

g++ -v

++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.2.1-9ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 9.2.1 20191008 (Ubuntu 9.2.1-9ubuntu2) 
fenugrec commented 4 years ago

Turns out this is more than a "minor defect". That missing return is actually undefined behaviour, and is caussing issue #10 !

And, this is the correct fix since the proper function signature is indeed void (*stop)(void *data, uint64_t ts); : see

https://github.com/obsproject/obs-studio/blob/f2f78b98ef848430868290bcf2d9a317cc77da7f/libobs/obs-output.h#L46

I'm not sure why we didn't get warnings from output_info.stop = v4l2sink_stop; when clearly the function definition didn't match ?

xrayn commented 4 years ago

Tried this fix on Arch. Works perfectly for me. No more segfaults when stopping capturing. (Although, on Arch, the "Aur" package has to be build manually and against obs-studio-25.0.3, so the Aur package has to be fixed. But this is not related to obs-v4l2-sink)

BrownBearSec commented 3 years ago

I am getting this same issue, after building with the seemingly correct code, I get the same error, and when I try to start the virtual webcam in obs, with the setting "YUV420" it gives me a segfault. what is the solution, thanks