Mercurial > code > home > repos > light9
changeset 549:fc14e2e87e9e
add preload safety to ascoltami2
Ignore-this: e60dad9c288f05ed91acd2a2ed827389
author | drewp@bigasterisk.com |
---|---|
date | Tue, 15 Jun 2010 05:44:32 +0000 |
parents | f65d7d1cae67 |
children | f233fa1ec801 |
files | light9/ascoltami/player.py |
diffstat | 1 files changed, 14 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/light9/ascoltami/player.py Tue Jun 15 05:40:38 2010 +0000 +++ b/light9/ascoltami/player.py Tue Jun 15 05:44:32 2010 +0000 @@ -63,11 +63,25 @@ """ log.info("set song to %r" % songUri) self.pipeline.set_state(gst.STATE_READY) + self.preload(songUri) self.pipeline.set_property("uri", songUri) # todo: don't have any error report yet if the uri can't be read self.pipeline.set_state(gst.STATE_PLAYING) self.playStartTime = time.time() + def preload(self, songUri): + """ + to avoid disk seek stutters, which happened sometimes (in 2007) with the + non-gst version of this program, we read the whole file to get + more OS caching. + + i don't care that it's blocking. + """ + assert songUri.startswith('file://') + p = songUri[len('file://'):] + log.info("preloading %s", p) + open(p).read() + def currentTime(self): try: cur, _format = self.playbin.query_position(gst.FORMAT_TIME)