Minor Rusty blockage

Sebastian Dröge sebastian at centricular.com
Fri Mar 2 14:21:38 UTC 2018


Hi Russel,

On Fri, 2018-03-02 at 12:33 +0000, Russel Winder wrote:
> On Thu, 2018-03-01 at 22:48 +0100, Mathieu Duponchelle wrote:
> > That is surprising, this exact snippet of code should work, is it 
> > possible that you don't
> > 
> > actually use the latest version of gstreamer-rs? This function was
> > added 
> > in July 2017, so
> > 
> > quite some time ago, but worth making sure.
> 
> I tend to use "*" as the version number and update frequently so I
> should always be on the latest version. Cargo.lock currently reports
> gstreamer at version 0.10.2, which seems about as up-to-date as it is
> possible to get using crates.io. I guess I could use the Git
> repository to be really up to date. :-)

Not the worst idea if you're prepared to keep up with API changes :)

It might make sense (for applications!) to have the Cargo.lock in GIT
and you update that manually whenever there are known-good versions.

> > It would also make sense to share the entire source code if that is 
> > possible, to
> > 
> > make it easier to reproduce and spot the problem :)
> > 
> 
> The source code is at  https://github.com/Me-TV/Me-TV_Rust
> 
> Comment out the bus.add_watch call completely everything build fine.
> Comment out just the 
> 
> gst::MessageView::Error(err) => {
>> },
> 
> and the errors are all about thread safety, which is a bit
> irritating, but somewhat comprehensible. Uncomment the above and back
> to the original incomprehensible fail. :-(

Here is the solution for the thread-safety issue:
https://github.com/sdroege/gstreamer-rs/blob/e6265341d56eeeda2f987a29c741f51ba5fb55d1/examples/src/bin/gtksink.rs#L71-L91

Problem is that GApplication is not thread-safe but the bus watch is
going to be triggered from whatever thread the mainloop runs on. Which
might in theory not be the same one where the GApplication was created.
The compiler can't statically prove that. It would be unsafe to use a
GApplication in another thread than the one where it was created.

However in your application both are guaranteed to be the same. With
SendCell you can move the thread-safety checks to runtime instead of
compile-time. Similar to how RefCell does it with borrowing.


For the other problem: you're using gstreamer-rs 0.10 but copied the
message handler from GIT master. The API slightly changed for
simplification. For 0.10 you need to do the following:
  https://github.com/sdroege/gstreamer-rs/blob/c7f5b541cc0923a71ccc89bf54954e3a03328994/examples/src/bin/gtksink.rs#L89-L95

That is, in 0.10 you have to get the source from the message itself
while in GIT master (0.11+) you can also use all the message API from
the different message views.

-- 
Sebastian Dröge, Centricular Ltd · https://www.centricular.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 963 bytes
Desc: This is a digitally signed message part
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20180302/bc6ea1b6/attachment-0001.sig>


More information about the gstreamer-devel mailing list