Made play method more robust by adding a try-finally.

This commit is contained in:
Sjoerd Mullender 1995-02-01 14:24:32 +00:00
parent 3d697ce447
commit 992ff06e98
2 changed files with 94 additions and 74 deletions

View File

@ -191,30 +191,38 @@ def play(self):
if len(self.list) == 0:
for i in range(self.status[5], self.status[6]+1):
self.appendtrack(i)
try:
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)
dummy = self.player.seektrack(
start)
else:
min, sec, frame = start
dummy = self.player.seek(min, sec, frame)
dummy = self.player.seek(
min, sec, frame)
if type(end) == type(0):
self.parser.setcallback(CD.PNUM, _dopnum, self)
self.parser.setcallback(
CD.PNUM, _dopnum, self)
self.end = end
func, arg = self.callbacks[CD.ATIME]
func, arg = \
self.callbacks[CD.ATIME]
if func:
self.parser.setcallback(CD.ATIME, func, arg)
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]
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:
@ -230,3 +238,5 @@ def play(self):
except _Stop:
self.playing = 0
self.listindex = self.listindex + 1
finally:
self.playing = 0

View File

@ -191,30 +191,38 @@ def play(self):
if len(self.list) == 0:
for i in range(self.status[5], self.status[6]+1):
self.appendtrack(i)
try:
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)
dummy = self.player.seektrack(
start)
else:
min, sec, frame = start
dummy = self.player.seek(min, sec, frame)
dummy = self.player.seek(
min, sec, frame)
if type(end) == type(0):
self.parser.setcallback(CD.PNUM, _dopnum, self)
self.parser.setcallback(
CD.PNUM, _dopnum, self)
self.end = end
func, arg = self.callbacks[CD.ATIME]
func, arg = \
self.callbacks[CD.ATIME]
if func:
self.parser.setcallback(CD.ATIME, func, arg)
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]
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:
@ -230,3 +238,5 @@ def play(self):
except _Stop:
self.playing = 0
self.listindex = self.listindex + 1
finally:
self.playing = 0