vladimirvivien / go4vl

A Go library for working with the Video for Linux API (V4L2).
MIT License
245 stars 45 forks source link

Capture errors when webcam is removed #41

Open kkettinger opened 1 year ago

kkettinger commented 1 year ago

Is there any way to catch errors when the user removes the webcam while in usage? In the simplecam example, this panic comes up when i remove the webcam while in use:

2023/03/03 23:24:50 Serving images: [:9090/stream]
panic: device: stream loop dequeue: buffer dequeue: system error

goroutine 18 [running]:
github.com/vladimirvivien/go4vl/device.(*Device).startStreamLoop.func1()
        /home/kk/go/pkg/mod/github.com/vladimirvivien/go4vl@v0.0.5/device/device.go:409 +0x4ac
created by github.com/vladimirvivien/go4vl/device.(*Device).startStreamLoop
        /home/kk/go/pkg/mod/github.com/vladimirvivien/go4vl@v0.0.5/device/device.go:392 +0x1ec
exit status 2
vladimirvivien commented 1 year ago

There is probably a way to watch for system events and react gracefully, however, right now that capability is not built in the API. I will mark this as a feature request/enhancement. Thank you for your feedback.

kkettinger commented 1 year ago

Great, thank you.

StarWitch commented 11 months ago

I'm also running into this issue in an app I've written, where any interruption in communication leads to a crash. I'd love to help with making this better.