mirror of
https://github.com/Syncplay/syncplay
synced 2025-02-15 10:27:09 +00:00
Use callback for FileSwitch (thanks Uriziel)
This commit is contained in:
parent
7022865cd0
commit
2b555134d1
@ -53,7 +53,6 @@ SYNC_ON_PAUSE = True # Client seek to global position - subtitles may disappear
|
||||
# Options for the File Switch feature:
|
||||
FOLDER_SEARCH_TIMEOUT = 60.0 # Secs - How long to wait until searches in folder to update cache are aborted (may be longer than this if hard drive needs to spin up)
|
||||
FOLDER_SEARCH_DOUBLE_CHECK_INTERVAL = 120.0 # Secs - Frequency of updating cache when someone is playing a file not in current cache
|
||||
MEDIA_CACHE_CHECK_INTERVAL = 0.2 # Secs - Frequency of checking for the cache being updated
|
||||
|
||||
#Usually there's no need to adjust these
|
||||
LAST_PAUSED_DIFF_THRESHOLD = 2
|
||||
|
@ -10,7 +10,7 @@ import re
|
||||
import os
|
||||
from syncplay.utils import formatTime, sameFilename, sameFilesize, sameFileduration, RoomPasswordProvider, formatSize, isURL
|
||||
from functools import wraps
|
||||
from twisted.internet import task
|
||||
from twisted.internet import task, threads
|
||||
import threading
|
||||
lastCheckedForUpdates = None
|
||||
|
||||
@ -89,8 +89,6 @@ class MainWindow(QtGui.QMainWindow):
|
||||
def __init__(self):
|
||||
self.fileSwitchTimer = task.LoopingCall(self.updateInfo)
|
||||
self.fileSwitchTimer.start(constants.FOLDER_SEARCH_DOUBLE_CHECK_INTERVAL, True)
|
||||
self.fileCheckTimer = task.LoopingCall(self.checkForUpdate)
|
||||
self.fileCheckTimer.start(constants.MEDIA_CACHE_CHECK_INTERVAL, True)
|
||||
|
||||
mediaFilesCache = {}
|
||||
filenameWatchlist = []
|
||||
@ -123,7 +121,7 @@ class MainWindow(QtGui.QMainWindow):
|
||||
MainWindow.FileSwitchManager.updateInfo()
|
||||
|
||||
@staticmethod
|
||||
def checkForUpdate():
|
||||
def checkForUpdate(self=None):
|
||||
if MainWindow.FileSwitchManager.newInfo:
|
||||
MainWindow.FileSwitchManager.newInfo = False
|
||||
MainWindow.FileSwitchManager.infoUpdated()
|
||||
@ -131,9 +129,7 @@ class MainWindow(QtGui.QMainWindow):
|
||||
@staticmethod
|
||||
def updateInfo():
|
||||
if len(MainWindow.FileSwitchManager.filenameWatchlist) > 0 or len(MainWindow.FileSwitchManager.mediaFilesCache) == 0 and MainWindow.FileSwitchManager.currentlyUpdating == False:
|
||||
newThread = threading.Thread(target=MainWindow.FileSwitchManager._updateInfoThread)
|
||||
newThread.setDaemon(True)
|
||||
newThread.start()
|
||||
threads.deferToThread(MainWindow.FileSwitchManager._updateInfoThread).addCallback(MainWindow.FileSwitchManager.checkForUpdate)
|
||||
|
||||
@staticmethod
|
||||
def setFilenameWatchlist(unfoundFilenames):
|
||||
|
Loading…
Reference in New Issue
Block a user