Allow passing custom user data to callbacks
Related to #18 .
A common idiom in Pipewire, show e.g. in the tutorial, is to instantiate a user data struct containing information about the video format; pipewire then passes this struct to the param_changed
callback (that sets it), and to the process
callback (that reads it).
At the moment, we cannot do this in pipewire-rs, because the binding is co-opting the user_data field to use it for its own bookkeeping structure. As a consequence, I think a user would have to wrap their data in something like Arc<Mutex>, which is really not efficient (especially for audio processing).
I believe the ListenerLocalCallback
structure should be augmented to allow a user to provide their own user-data struct, which then should be passed as an &mut
to all callback methods. I will open a MR to do just that. My changes were more invasive than I was expecting, and provide subpar ergonomics, so I'm very keen on getting your feedback.