techyian / MMALSharp

C# wrapper to Broadcom's MMAL with an API to the Raspberry Pi camera.
MIT License
195 stars 33 forks source link

Notes for v0.5 #70

Closed techyian closed 5 years ago

techyian commented 6 years ago

Removing Nito.AsyncEx dependency

For some time I've been battling with a blocking issue which was intermittent and struggled to pinpoint what the cause was. I have since found this is happening when the thread running ProcessAsync reaches the port disable method while a native background thread is still in operation in one of the buffer callbacks; this in turn was causing MMAL to block indefinitely, essentially causing a deadlock.

To remedy this I have removed the AsyncCountdownEvent functionality the library relied on to release await calls whilst MMAL was processing data for us and have replaced it with a manual implementation which periodically checks whether a port has finished processing, and if so, the await completes. For some reason, AsyncCountdownEvent was allowing the thread handling ProcessAsync to continue at a higher priority than the background thread, whereas the manual implementation does successfully complete the background thread before reaching port disable code.

Due to not needing AsyncCountdownEvent anymore, and recent efforts to better understand the importance of ConfigureAwait(false) on awaits in the library, it's no longer necessary to keep Nito.AsyncEx as a dependency in MMALSharp. I will of course be updating the Wiki and any other documentation which references code from that library.

techyian commented 5 years ago

Capture handlers moved to ports

Makes more sense for the capture handlers to be at a port level rather than a component level. This means if you're using the splitter component for example, you can potentially use 4 different capture handlers for each output port if you wish.

techyian commented 5 years ago

Width/height properties moved to ports

Makes more sense for the resolution to be queried and assigned at a port level. This also means that components connected to the splitter component can have their own respective resolutions.

techyian commented 5 years ago

Breaking change: Added MMALPortConfig class

This has been added to simplify the port configuration process. Too many overloads were confusing the MMALDownstreamComponent class, so these have been removed in favour of a single parameter. All previous configuration properties can be assigned via this new class.

techyian commented 5 years ago

Breaking change: Moved Video encoder/decoder timeout parameter to MMALPortConfig class.

This can now be assigned via the MMALPortConfig class.