summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorSjoerd Mullender <sjoerd@acm.org>1995-02-01 14:24:32 (GMT)
committerSjoerd Mullender <sjoerd@acm.org>1995-02-01 14:24:32 (GMT)
commit992ff06e9894d81d18322ec3011619df43b2738a (patch)
tree09ee5604b5cceab689b49642592394fc2a5367d5 /Lib
parent3d697ce447a74e4979d578bc729b977b88a6e2d3 (diff)
downloadcpython-992ff06e9894d81d18322ec3011619df43b2738a.zip
cpython-992ff06e9894d81d18322ec3011619df43b2738a.tar.gz
cpython-992ff06e9894d81d18322ec3011619df43b2738a.tar.bz2
Made play method more robust by adding a try-finally.
Diffstat (limited to 'Lib')
-rwxr-xr-xLib/irix5/readcd.py84
-rwxr-xr-xLib/plat-irix5/readcd.py84
2 files changed, 94 insertions, 74 deletions
diff --git a/Lib/irix5/readcd.py b/Lib/irix5/readcd.py
index fffb6fe..5c4b824 100755
--- a/Lib/irix5/readcd.py
+++ b/Lib/irix5/readcd.py
@@ -191,42 +191,52 @@ class Readcd:
if len(self.list) == 0:
for i in range(self.status[5], self.status[6]+1):
self.appendtrack(i)
- while 1:
- if not self.playing:
- if self.listindex >= len(self.list):
- return
- start, end = self.list[self.listindex]
-## print 'starting with',`(start, end)`
- if type(start) == type(0):
- dummy = self.player.seektrack(start)
- else:
- min, sec, frame = start
- dummy = self.player.seek(min, sec, frame)
- if type(end) == type(0):
- self.parser.setcallback(CD.PNUM, _dopnum, self)
- self.end = end
- func, arg = self.callbacks[CD.ATIME]
- if func:
- self.parser.setcallback(CD.ATIME, func, arg)
+ try:
+ while 1:
+ if not self.playing:
+ if self.listindex >= len(self.list):
+ return
+ start, end = self.list[self.listindex]
+ if type(start) == type(0):
+ dummy = self.player.seektrack(
+ start)
else:
- self.parser.removecallback(CD.ATIME)
- else:
- min, sec, frame = end
- self.parser.setcallback(CD.ATIME, _doatime, self)
- self.end = (min * 60 + sec) * 75 + frame
- func, arg = self.callbacks[CD.PNUM]
- if func:
- self.parser.setcallback(CD.PNUM, func, arg)
+ min, sec, frame = start
+ dummy = self.player.seek(
+ min, sec, frame)
+ if type(end) == type(0):
+ self.parser.setcallback(
+ CD.PNUM, _dopnum, self)
+ self.end = end
+ func, arg = \
+ self.callbacks[CD.ATIME]
+ if func:
+ self.parser.setcallback(CD.ATIME, func, arg)
+ else:
+ self.parser.removecallback(CD.ATIME)
else:
- self.parser.removecallback(CD.PNUM)
- self.playing = 1
- data = self.player.readda(size)
- if data == '':
- self.playing = 0
- self.listindex = self.listindex + 1
- continue
- try:
- self.parser.parseframe(data)
- except _Stop:
- self.playing = 0
- self.listindex = self.listindex + 1
+ min, sec, frame = end
+ self.parser.setcallback(
+ CD.ATIME, _doatime,
+ self)
+ self.end = (min * 60 + sec) * \
+ 75 + frame
+ func, arg = \
+ self.callbacks[CD.PNUM]
+ if func:
+ self.parser.setcallback(CD.PNUM, func, arg)
+ else:
+ self.parser.removecallback(CD.PNUM)
+ self.playing = 1
+ data = self.player.readda(size)
+ if data == '':
+ self.playing = 0
+ self.listindex = self.listindex + 1
+ continue
+ try:
+ self.parser.parseframe(data)
+ except _Stop:
+ self.playing = 0
+ self.listindex = self.listindex + 1
+ finally:
+ self.playing = 0
diff --git a/Lib/plat-irix5/readcd.py b/Lib/plat-irix5/readcd.py
index fffb6fe..5c4b824 100755
--- a/Lib/plat-irix5/readcd.py
+++ b/Lib/plat-irix5/readcd.py
@@ -191,42 +191,52 @@ class Readcd:
if len(self.list) == 0:
for i in range(self.status[5], self.status[6]+1):
self.appendtrack(i)
- while 1:
- if not self.playing:
- if self.listindex >= len(self.list):
- return
- start, end = self.list[self.listindex]
-## print 'starting with',`(start, end)`
- if type(start) == type(0):
- dummy = self.player.seektrack(start)
- else:
- min, sec, frame = start
- dummy = self.player.seek(min, sec, frame)
- if type(end) == type(0):
- self.parser.setcallback(CD.PNUM, _dopnum, self)
- self.end = end
- func, arg = self.callbacks[CD.ATIME]
- if func:
- self.parser.setcallback(CD.ATIME, func, arg)
+ try:
+ while 1:
+ if not self.playing:
+ if self.listindex >= len(self.list):
+ return
+ start, end = self.list[self.listindex]
+ if type(start) == type(0):
+ dummy = self.player.seektrack(
+ start)
else:
- self.parser.removecallback(CD.ATIME)
- else:
- min, sec, frame = end
- self.parser.setcallback(CD.ATIME, _doatime, self)
- self.end = (min * 60 + sec) * 75 + frame
- func, arg = self.callbacks[CD.PNUM]
- if func:
- self.parser.setcallback(CD.PNUM, func, arg)
+ min, sec, frame = start
+ dummy = self.player.seek(
+ min, sec, frame)
+ if type(end) == type(0):
+ self.parser.setcallback(
+ CD.PNUM, _dopnum, self)
+ self.end = end
+ func, arg = \
+ self.callbacks[CD.ATIME]
+ if func:
+ self.parser.setcallback(CD.ATIME, func, arg)
+ else:
+ self.parser.removecallback(CD.ATIME)
else:
- self.parser.removecallback(CD.PNUM)
- self.playing = 1
- data = self.player.readda(size)
- if data == '':
- self.playing = 0
- self.listindex = self.listindex + 1
- continue
- try:
- self.parser.parseframe(data)
- except _Stop:
- self.playing = 0
- self.listindex = self.listindex + 1
+ min, sec, frame = end
+ self.parser.setcallback(
+ CD.ATIME, _doatime,
+ self)
+ self.end = (min * 60 + sec) * \
+ 75 + frame
+ func, arg = \
+ self.callbacks[CD.PNUM]
+ if func:
+ self.parser.setcallback(CD.PNUM, func, arg)
+ else:
+ self.parser.removecallback(CD.PNUM)
+ self.playing = 1
+ data = self.player.readda(size)
+ if data == '':
+ self.playing = 0
+ self.listindex = self.listindex + 1
+ continue
+ try:
+ self.parser.parseframe(data)
+ except _Stop:
+ self.playing = 0
+ self.listindex = self.listindex + 1
+ finally:
+ self.playing = 0