arturoc / gstreamer1.0-rs

Idiomatic bindings for Gstreamer on Rust.
MIT License
36 stars 14 forks source link

The argument to bus::Bus::add_watch should by Sync and Send #11

Closed Blei closed 8 years ago

Blei commented 8 years ago

If I understand correctly, the callback added by gst_bus_add_watch will be executed on the main loop, which might be in a different thread. If I understand Rust's type system correctly, this should mean that the trait objects that gets attached to that callback should by Sync and Send. If not, then it should at least by enveloped by a Arc<Mutex<>> instead of an Rc<RefCell<>>.

Blei commented 8 years ago

Also, but this is more of a feature request than a bug report :), the API if add_watch is slightly weird: I had no idea that I had to keep the watcher around because the Rc is internally converted to a weak pointer. Please document this :) or even better, don't make it a requirement and keep the pointer alive for the lifetime of the Bus.

arturoc commented 8 years ago

just fixed this, the bus is now taking the ownership of the watch instead of having shared ownership and there's now a remove_watch method to remove the watch. also the watch trait now has to be send so it can be sent across threads in case the gstreamer loop is being run on a different thread than the main one