blackjack / webcam

Golang webcam library for Linux
MIT License
411 stars 90 forks source link

Revert to read-write perms #69

Closed seanavery closed 4 months ago

seanavery commented 4 months ago

Description

Noticed that mmap calls are failing for standard UVC V4L2 drivers (basic USB webcams) with the latest webcam commit.

This PR reverts changes from commit back to using O_RDWR flag for file open, and PROT_READ | PROT_WRITE flags for mmap calls.

This will allow the library to safely handle all standard v4l2 linux drivers. Even though we are not "writing", the v4l dev docs provide a warning about the requirement for read-write when streaming.

@bpstark Could you provide more details about locking out other processes? It is my understanding that unix.O_RDWR|unix.O_NONBLOCK file flags do not attach a file lock. We would need to explicitly call unix.Flock for that.

Testing

seanavery commented 4 months ago

cc @edaniels