From e4d238b6080cd3bcae6de45cdcf6a4df2df9f494 Mon Sep 17 00:00:00 2001 From: "Adrian C. (anrxc)" Date: Mon, 14 Mar 2011 22:18:02 +0100 Subject: play: unlink mplayer FIFO on exit --- play.py | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/play.py b/play.py index 99b8304..d21ff18 100755 --- a/play.py +++ b/play.py @@ -1309,14 +1309,18 @@ class TimeOffsetPlayerMplayer(Player): re_progress = re.compile("^A:.*?(\d+)\.\d \([^)]+\) of (\d+)\.\d") def play(self): - if os.path.exists(CONTROL_FIFO + "-mplayer"): - os.unlink(CONTROL_FIFO + "-mplayer") - os.mkfifo(CONTROL_FIFO + "-mplayer", 0600) - Player.play(self) - fifo = open(CONTROL_FIFO + "-mplayer", 'w') - fifo.write("seek %d\n" % self.offset) - fifo.flush() - fifo.close() + self.fd = None + try: + if os.path.exists(CONTROL_FIFO + "-mplayer"): + os.unlink(CONTROL_FIFO + "-mplayer") + os.mkfifo(CONTROL_FIFO + "-mplayer", 0600) + Player.play(self) + self.fd = open(CONTROL_FIFO + "-mplayer", "w") + self.fd.write("seek %d\n" % self.offset) + self.fd.flush() + self.fd.close() + except IOError: + return def parse_buf(self): match = self.re_progress.search(self.buf) @@ -1480,7 +1484,10 @@ class Application: tty and tty.tcsetattr(sys.stdin.fileno(), tty.TCSADRAIN, self.tcattr) print try: - if os.path.exists(CONTROL_FIFO): os.unlink(CONTROL_FIFO) + if os.path.exists(CONTROL_FIFO): + os.unlink(CONTROL_FIFO) + if os.path.exists(CONTROL_FIFO + "-mplayer"): + os.unlink(CONTROL_FIFO + "-mplayer") except IOError: pass -- cgit v1.2.3