summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1992-04-22 14:33:26 (GMT)
committerGuido van Rossum <guido@python.org>1992-04-22 14:33:26 (GMT)
commit58230c3a0585b1f52500109b46aaf3cd5f7b34eb (patch)
tree5f2a769d867a88241bee7b96eea58ae40a8a9d6d /Lib
parent9ac9063cefe1daa73228d567d03104565b764610 (diff)
downloadcpython-58230c3a0585b1f52500109b46aaf3cd5f7b34eb.zip
cpython-58230c3a0585b1f52500109b46aaf3cd5f7b34eb.tar.gz
cpython-58230c3a0585b1f52500109b46aaf3cd5f7b34eb.tar.bz2
Changed caching code
Diffstat (limited to 'Lib')
-rwxr-xr-xLib/irix5/readcd.py36
-rwxr-xr-xLib/plat-irix5/readcd.py36
2 files changed, 46 insertions, 26 deletions
diff --git a/Lib/irix5/readcd.py b/Lib/irix5/readcd.py
index 68e1b4d..b4da9b8 100755
--- a/Lib/irix5/readcd.py
+++ b/Lib/irix5/readcd.py
@@ -53,11 +53,11 @@ class Readcd():
def pmsf2msf(self, track, min, sec, frame):
if not self.status:
- self.status = self.player.getstatus()
- if not self.trackinfo:
- dummy = self.gettrackinfo()
+ self.cachestatus()
if track < self.status[5] or track > self.status[6]:
raise Error, 'track number out of range'
+ if not self.trackinfo:
+ self.cacheinfo()
start, total = self.trackinfo[track]
start = ((start[0] * 60) + start[1]) * 75 + start[2]
total = ((total[0] * 60) + total[1]) * 75 + total[2]
@@ -77,7 +77,7 @@ class Readcd():
def appendstretch(self, start, end):
if not self.status:
- self.status = self.player.getstatus()
+ self.cachestatus()
if not start:
start = 1
if not end:
@@ -149,13 +149,9 @@ class Readcd():
def gettrackinfo(self, *arg):
if not self.status:
- self.status = self.player.getstatus()
+ self.cachestatus()
if not self.trackinfo:
- self.trackinfo = []
- for i in range(self.status[5]):
- self.trackinfo.append(None)
- for i in range(self.status[5], self.status[6]+1):
- self.trackinfo.append(self.player.gettrackinfo(i))
+ self.cacheinfo()
if len(arg) == 0:
return self.trackinfo[self.status[5]:self.status[6]+1]
result = []
@@ -165,13 +161,27 @@ class Readcd():
result.append(self.trackinfo[i])
return result
- def getstatus(self):
+ def cacheinfo(self):
+ if not self.status:
+ self.cachestatus()
+ self.trackinfo = []
+ for i in range(self.status[5]):
+ self.trackinfo.append(None)
+ for i in range(self.status[5], self.status[6]+1):
+ self.trackinfo.append(self.player.gettrackinfo(i))
+
+ def cachestatus(self):
self.status = self.player.getstatus()
- return self.status
+ if self.status[0] == CD.NODISK:
+ self.status = None
+ raise Error, 'no disk in player'
+
+ def getstatus(self):
+ return self.player.getstatus()
def play(self):
if not self.status:
- self.status = self.player.getstatus()
+ self.cachestatus()
size = self.player.bestreadsize()
self.listindex = 0
self.playing = 0
diff --git a/Lib/plat-irix5/readcd.py b/Lib/plat-irix5/readcd.py
index 68e1b4d..b4da9b8 100755
--- a/Lib/plat-irix5/readcd.py
+++ b/Lib/plat-irix5/readcd.py
@@ -53,11 +53,11 @@ class Readcd():
def pmsf2msf(self, track, min, sec, frame):
if not self.status:
- self.status = self.player.getstatus()
- if not self.trackinfo:
- dummy = self.gettrackinfo()
+ self.cachestatus()
if track < self.status[5] or track > self.status[6]:
raise Error, 'track number out of range'
+ if not self.trackinfo:
+ self.cacheinfo()
start, total = self.trackinfo[track]
start = ((start[0] * 60) + start[1]) * 75 + start[2]
total = ((total[0] * 60) + total[1]) * 75 + total[2]
@@ -77,7 +77,7 @@ class Readcd():
def appendstretch(self, start, end):
if not self.status:
- self.status = self.player.getstatus()
+ self.cachestatus()
if not start:
start = 1
if not end:
@@ -149,13 +149,9 @@ class Readcd():
def gettrackinfo(self, *arg):
if not self.status:
- self.status = self.player.getstatus()
+ self.cachestatus()
if not self.trackinfo:
- self.trackinfo = []
- for i in range(self.status[5]):
- self.trackinfo.append(None)
- for i in range(self.status[5], self.status[6]+1):
- self.trackinfo.append(self.player.gettrackinfo(i))
+ self.cacheinfo()
if len(arg) == 0:
return self.trackinfo[self.status[5]:self.status[6]+1]
result = []
@@ -165,13 +161,27 @@ class Readcd():
result.append(self.trackinfo[i])
return result
- def getstatus(self):
+ def cacheinfo(self):
+ if not self.status:
+ self.cachestatus()
+ self.trackinfo = []
+ for i in range(self.status[5]):
+ self.trackinfo.append(None)
+ for i in range(self.status[5], self.status[6]+1):
+ self.trackinfo.append(self.player.gettrackinfo(i))
+
+ def cachestatus(self):
self.status = self.player.getstatus()
- return self.status
+ if self.status[0] == CD.NODISK:
+ self.status = None
+ raise Error, 'no disk in player'
+
+ def getstatus(self):
+ return self.player.getstatus()
def play(self):
if not self.status:
- self.status = self.player.getstatus()
+ self.cachestatus()
size = self.player.bestreadsize()
self.listindex = 0
self.playing = 0