Skip to content

Commit

Permalink
Revert "Merge pull request #34 from eonpatapon/no-polling-2"
Browse files Browse the repository at this point in the history
Keep polling for now, to detect connection loss during idle (issue #35).
Maybe a better solution will be found in the future.
  • Loading branch information
grawity committed Dec 31, 2012
1 parent bf6edc0 commit aeeb4c9
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 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
# when idle mode is not supported
if not self._poll_id and not self._can_idle:
self._poll_id = gobject.timeout_add_seconds(1,
if not self._poll_id:
interval = 15 if self._can_idle else 1
self._poll_id = gobject.timeout_add_seconds(interval,
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._update_properties()
self.timer_callback()
self.idle_enter()
# Return False to stop trying to connect
return False
Expand Down Expand Up @@ -431,6 +431,8 @@ class MPDWrapper(mpd.MPDClient):
return self._currentsong.copy()

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

def _update_properties(self):
Expand Down

0 comments on commit aeeb4c9

Please sign in to comment.