garkimasera / vlc-rs

Rust bindings for libVLC media framework.
MIT License
66 stars 18 forks source link

Implement Send for Media,Player,Instance to allow for shared state #3

Closed 0xpr03 closed 6 years ago

0xpr03 commented 6 years ago

This allows to wrap it inside a RwLock for example, so you can put a player inside a Arc<Mutex<>>

0xpr03 commented 6 years ago

It's kinda sad that I can't find any source about how thread safe libVLC is.. The things I can find are tending towards "non thread safe, but could be at some points", which makes this unusable for multi threaded systems, as you have to put everything behind a mutex.

garkimasera commented 6 years ago

I cannot judge Send implementation safety because I don't have any knowledge about libVLC thread safety. But Media and other objects may implement Send if they can be called with lock and prohibit pointer cloning over threads.

One temporary solution is providing optional feature to implement Send. Another solution is unsafe wrappers that implement Send for these objects.

0xpr03 commented 6 years ago

According to what I've found and talked people with, send is possible, but not sync. To be honest I've given up on libvlc as it's not even thread safe to read the current volume and wrapping 3 LibVLC objects (player,instance,media) in a Mutex is just not something you want to do in a multi threaded environment. Possibly also leading to deadlocks. I'm going to use the gstreamer lib as it's thread safe by design.