Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't use any polling when idle mode is used #34

Merged
merged 1 commit into from
Dec 30, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/mpDris2.in
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,9 @@ class MPDWrapper(mpd.MPDClient):
self.init_state()

# Add periodic status check for sending MPRIS events
if not self._poll_id:
interval = 15 if self._can_idle else 1
self._poll_id = gobject.timeout_add_seconds(interval,
# when idle mode is not supported
if not self._poll_id and not self._can_idle:
self._poll_id = gobject.timeout_add_seconds(1,
self.timer_callback)
if self._can_idle and not self._watch_id:
self._watch_id = gobject.io_add_watch(self,
Expand All @@ -305,7 +305,7 @@ class MPDWrapper(mpd.MPDClient):
# Reset error counter
self._errors = 0

self.timer_callback()
self._update_properties()
self.idle_enter()
# Return False to stop trying to connect
return False
Expand Down Expand Up @@ -428,8 +428,6 @@ class MPDWrapper(mpd.MPDClient):
self.stop()

def last_status(self):
if time.time() - self._time >= 2:
self.timer_callback()
return self._status.copy()

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why we should refresh the properties here

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, it's probably not necessary. I guess I was just afraid of self._status becoming out of date for some reason...

def _update_properties(self):
Expand Down