Coder Social home page Coder Social logo

Comments (4)

Sinono3 avatar Sinono3 commented on August 20, 2024

Okay. I think this is because we use a MPSC channel internally (std::sync::mpsc) and we check for these messages using if let instead of while let. This causes us to only get one message every 500 ms which is very bad. We can fix this in two ways:

  1. The quick way is changing that if let for a while let, which I think should work. If it blocks the thread for too long we might have to find a way to make it non-blocking.
  2. Switching our thread-shared state management to use Arc<Mutex<T>> or Arc<RwLock<T>>. The switch shouldn't be difficult.

Can you try doing one of this fixes on a local copy of souvlaki and see if it works?

from souvlaki.

Beinsezii avatar Beinsezii commented on August 20, 2024

Why is conn.process() set to 1000ms by default? In fact why does it even need a duration?

Setting conn.process(Duration::from_millis(0))?; lets me read playback position in real-time like on zbus and so far there's no adverse side effects.

from souvlaki.

Beinsezii avatar Beinsezii commented on August 20, 2024

I also don't get the whole loop{if let} vs while let thing. Shouldn't they be functionally equivalent? Where's the 500ms come from?

from souvlaki.

Beinsezii avatar Beinsezii commented on August 20, 2024

Okay I see what you meant with while let.

diff --git a/src/platform/mpris/dbus/controls.rs b/src/platform/mpris/dbus/controls.rs
index 6aa5123..a59e228 100644
--- a/src/platform/mpris/dbus/controls.rs
+++ b/src/platform/mpris/dbus/controls.rs
@@ -242,10 +242,10 @@ where
         }),
     );
 
-    loop {
-        if let Ok(event) = event_channel.recv_timeout(Duration::from_millis(10)) {
+    'outer: loop {
+        while let Ok(event) = event_channel.recv_timeout(Duration::from_millis(10)) {
             if event == InternalEvent::Kill {
-                break;
+                break 'outer;
             }
 
             let mut changed_properties = HashMap::new();

To consume all the events at once before processing. That also works. I still find the 1000ms wild though.

from souvlaki.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.