Skip to content

Conversation

@UlmerMan
Copy link

@UlmerMan UlmerMan commented Feb 14, 2025

I added derive(Clone) to some structs, as i need this for my current project. Because I need to have the raw data and not a reference, as i want to pass it on to a different thread.

@chemicstry
Copy link
Contributor

Adding clone on MemoryMappedFrameBuffer might be okay, but I need to verify this. Cloning FrameBuffer on the other hand, is not sound, because that would allow simultaneously passing the same buffer to capture pipeline and obtaining &[u8], so data in an immutable slice would be overwrittten.

@fishrockz
Copy link
Collaborator

So i have typically had one thread to handle the libcamera interaction and then other threads for other things, this can work ok https://gitlab.com/pointswaves/e-camera/-/blob/willsalmon/pi/hmi-app/src/main.rs?ref_type=heads https://gitlab.com/gorse/pi-camera/-/tree/trying?ref_type=heads both use this and while there very messy they do work.

Its not to say that its the only way to go tho.

Clone is typically a bit of a issue because it allow you to have 2 versions of the same thing, and if libcamera has one pointer and we have two things doing different things to it then we can have issues.

That said we might be able to send structs between threads, I think that is the functionally you really want. Send is a bit trick too but it might be a better way to go but making sure that it is also sound is also a bit tricky.

@UlmerMan
Copy link
Author

UlmerMan commented Jun 1, 2025

@fishrockz this is the thing I need but I am not a that good of a rust developer to implement that the best why so I just used clone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants