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
Investigate protection against multi-access lockup #4
Comments
Unfortunately, this requires root access. Moreover, as the follow-on message in the thread indicates, while it would protect against MMAL-based apps simultaneously accessing the camera, it wouldn't protect against OpenMAX-based apps. For now, the best we can reasonably do (without requiring root access, which is excessive for such a minor feature) is simply ensure the class itself isn't accidentally instantiated multiple times. |
Thought I'd clarify: Checking the value of cam_alloc_alloc_count will show if the camera is in use whether it by OpenMAX or MMAL libraries. My followup in the thread was unclear in that sense (and a vain attempt to get some kind of fix put into the firmware that prevents a lockup that requires a reboot). |
Ah, thanks for the clarification! Given that quite a lot of people seem to run python+picamera as root (probably for things like GPIO access), and given the technique would cover MMAL and OpenMAX, I've decided this ought to be reinstated as a goal for 1.0. The root access requirement can be made tentative (much like the led property): if we have access to /dev/vc-mem we can perform the check and bail if it fails, if we don't have access we can fall back to simply guarding against multiple instantiations of the class itself as a best-effort. |
Hah! Just as I was coding up stuff for reading the ref-count from |
Hello Dave, mmal: mmal_vc_component_enable: failed to enable component: ENOSPC Can you help me? Thank you! |
It is possible, but only from within the same process; i.e. if one process (pistreaming or some picamera script) is using the camera, another process (like raspistill or raspivid) can't. However, the camera can produce JPEGs while recording video as shown in this recipe so if you can adjust your script to do both, you should be good to go. |
Thank you Dave. In what file I have to add this code? with picamera.PiCamera() as camera: Thanks! |
Well, it's not quite a matter of just copying and pasting that code somewhere - you need to understand what it does and then use that technique in whatever script you're working with. So, firstly when you say you're using a "livestream" what script is that exactly? |
A thread on the Pi Camera forum indicates it may be possible to guard against lockup of the camera when multiple processes attempt to access it:
This should be added to
PiCamera.__init__
but looks like it'll require a bit more header translation, hence it won't make it into 0.5, but should be added before 1.0.The text was updated successfully, but these errors were encountered: