Changeset - 776401dea077
[Not reviewed]
default
0 2 0
drewp@bigasterisk.com - 15 years ago 2010-06-20 05:04:47
drewp@bigasterisk.com
vidref: try not to stop gathering time even upon error; don't scan dirs repeatedly, which was ruining seeks
Ignore-this: a303b02cbdc2e1224534b8d5a2500fcc
2 files changed with 22 insertions and 11 deletions:
0 comments (0 inline, 0 general)
light9/vidref/main.py
Show inline comments
 
@@ -51,16 +51,20 @@ class MusicTime(object):
 

	
 
    def _timeUpdate(self):
 
        while True:
 
            position = jsonlib.loads(self.musicResource.get("time").body,
 
                                     use_float=True)
 
            try:
 
                position = jsonlib.loads(self.musicResource.get("time").body,
 
                                         use_float=True)
 

	
 
            # this is meant to be the time when the server gave me its
 
            # report, and I don't know if that's closer to the
 
            # beginning of my request or the end of it (or some
 
            # fraction of the way through)
 
            self.positionFetchTime = time.time()
 
            
 
            self.position = position
 
                # this is meant to be the time when the server gave me its
 
                # report, and I don't know if that's closer to the
 
                # beginning of my request or the end of it (or some
 
                # fraction of the way through)
 
                self.positionFetchTime = time.time()
 

	
 
                self.position = position
 
            except restkit.RequestError, e:
 
                log.error(e)
 
                time.sleep(1)
 
            time.sleep(self.period)
 
        
 
class VideoRecordSink(gst.Element):
light9/vidref/replay.py
Show inline comments
 
@@ -182,6 +182,8 @@ class ReplayView(object):
 
                self.picWidget.queue_draw_area(0,0,320,240)
 
                self.picWidget.get_window().process_updates(True)
 
        self.showingPic = inPic
 

	
 
_existingFrames = {}  # takeDir : frames
 
    
 
class Replay(object):
 
    """
 
@@ -189,8 +191,13 @@ class Replay(object):
 
    """
 
    def __init__(self, takeDir):
 
        self.takeDir = takeDir
 
        self.existingFrames = sorted([Decimal(f.split('.jpg')[0])
 
                                 for f in os.listdir(self.takeDir)])
 
        try:
 
            self.existingFrames = _existingFrames[self.takeDir]
 
        except KeyError:
 
            log.info("scanning %s", self.takeDir)
 
            self.existingFrames = sorted([Decimal(f.split('.jpg')[0])
 
                                          for f in os.listdir(self.takeDir)])
 
            _existingFrames[self.takeDir] = self.existingFrames
 

	
 
    def tooShort(self, minSeconds=5):
 
        return len(self.existingFrames) < (minSeconds * framerate)
0 comments (0 inline, 0 general)