Reworked some constants

This commit is contained in:
Uriziel 2012-12-29 15:33:48 +01:00
parent fe2aae1d83
commit 73c275c89b
2 changed files with 13 additions and 12 deletions

View File

@ -117,7 +117,7 @@ class SyncplayClient(object):
pauseChange = self.getPlayerPaused() != paused and self.getGlobalPaused() != paused pauseChange = self.getPlayerPaused() != paused and self.getGlobalPaused() != paused
_playerDiff = abs(self.getPlayerPosition() - position) _playerDiff = abs(self.getPlayerPosition() - position)
_globalDiff = abs(self.getGlobalPosition() - position) _globalDiff = abs(self.getGlobalPosition() - position)
seeked = _playerDiff > constants.SEEK_BOUNDARY and _globalDiff > constants.SEEK_BOUNDARY seeked = _playerDiff > constants.SEEK_THRESHOLD and _globalDiff > constants.SEEK_THRESHOLD
return pauseChange, seeked return pauseChange, seeked
def updatePlayerStatus(self, paused, position): def updatePlayerStatus(self, paused, position):
@ -182,12 +182,12 @@ class SyncplayClient(object):
return madeChangeOnPlayer return madeChangeOnPlayer
def _slowDownToCoverTimeDifference(self, diff, setBy): def _slowDownToCoverTimeDifference(self, diff, setBy):
if(constants.SLOWDOWN_KICKIN_BOUNDARY < diff and not self._speedChanged): if(constants.SLOWDOWN_KICKIN_THRESHOLD < diff and not self._speedChanged):
self._player.setSpeed(constants.SLOWDOWN_RATE) self._player.setSpeed(constants.SLOWDOWN_RATE)
self._speedChanged = True self._speedChanged = True
message = "Slowing down due to time difference with <{}>".format(setBy) message = "Slowing down due to time difference with <{}>".format(setBy)
self.ui.showMessage(message) self.ui.showMessage(message)
elif(self._speedChanged and diff < constants.SLOWDOWN_RESET_BOUNDARY): elif(self._speedChanged and diff < constants.SLOWDOWN_RESET_THRESHOLD):
self._player.setSpeed(1.00) self._player.setSpeed(1.00)
self._speedChanged = False self._speedChanged = False
message = "Reverting speed back to normal" message = "Reverting speed back to normal"
@ -206,7 +206,7 @@ class SyncplayClient(object):
self._lastGlobalUpdate = time.time() self._lastGlobalUpdate = time.time()
if (doSeek): if (doSeek):
madeChangeOnPlayer = self._serverSeeked(position, setBy) madeChangeOnPlayer = self._serverSeeked(position, setBy)
if (diff > 4 and not doSeek): if (diff > constants.REWIND_THRESHOLD and not doSeek):
madeChangeOnPlayer = self._rewindPlayerDueToTimeDifference(position, setBy) madeChangeOnPlayer = self._rewindPlayerDueToTimeDifference(position, setBy)
if (self._player.speedSupported and not doSeek and not paused): if (self._player.speedSupported and not doSeek and not paused):
madeChangeOnPlayer = self._slowDownToCoverTimeDifference(diff, setBy) madeChangeOnPlayer = self._slowDownToCoverTimeDifference(diff, setBy)
@ -247,8 +247,7 @@ class SyncplayClient(object):
position = self._playerPosition position = self._playerPosition
if(not self._playerPaused): if(not self._playerPaused):
diff = time.time() - self._lastPlayerUpdate diff = time.time() - self._lastPlayerUpdate
if diff < 0.5: position += diff
position += diff
return position return position
def getPlayerPaused(self): def getPlayerPaused(self):
@ -363,7 +362,7 @@ class SyncplayUser(object):
return False return False
sameName = self.file['name'] == file_['name'] sameName = self.file['name'] == file_['name']
sameSize = self.file['size'] == file_['size'] sameSize = self.file['size'] == file_['size']
sameDuration = int(self.file['duration']) - int(file_['duration']) < constants.DIFFFERENT_DURATION_BOUNDARY sameDuration = int(self.file['duration']) - int(file_['duration']) < constants.DIFFFERENT_DURATION_THRESHOLD
return sameName and sameSize and sameDuration return sameName and sameSize and sameDuration
def __lt__(self, other): def __lt__(self, other):

View File

@ -8,14 +8,16 @@ DEFAULT_ROOM = 'default'
DEFAULT_CONFIG_NAME = ".syncplay" DEFAULT_CONFIG_NAME = ".syncplay"
#Changing these might be ok #Changing these might be ok
SEEK_BOUNDARY = 1 REWIND_THRESHOLD = 4
SEEK_THRESHOLD = 1
SLOWDOWN_RATE = 0.95 SLOWDOWN_RATE = 0.95
SLOWDOWN_KICKIN_BOUNDARY = 1.5 SLOWDOWN_KICKIN_THRESHOLD = 1.5
SLOWDOWN_RESET_BOUNDARY = 0.1 SLOWDOWN_RESET_THRESHOLD = 0.1
DIFFFERENT_DURATION_BOUNDARY = 1 DIFFFERENT_DURATION_THRESHOLD = 1
PROTOCOL_TIMEOUT = 5 PROTOCOL_TIMEOUT = 5
RECONNECT_RETRIES = 10 RECONNECT_RETRIES = 10
#Usually there's no need to adjust these #Usually there's no need to adjust these
COMMANDS_UNDO = ["u", "undo", "revert"] COMMANDS_UNDO = ["u", "undo", "revert"]
COMMANDS_LIST = ["l", "list", "users"] COMMANDS_LIST = ["l", "list", "users"]