diff options
author | Adrian C. (anrxc) <anrxc@sysphere.org> | 2011-03-14 22:18:02 +0100 |
---|---|---|
committer | Adrian C. (anrxc) <anrxc@sysphere.org> | 2011-03-14 22:18:02 +0100 |
commit | e4d238b6080cd3bcae6de45cdcf6a4df2df9f494 (patch) | |
tree | 8e14d579b0ddfd74667c904095c3f697fc68175c /play.py | |
parent | 75be0e23b77900da37f143b75031fd00a8f7201b (diff) | |
download | play-e4d238b6080cd3bcae6de45cdcf6a4df2df9f494.tar.xz |
play: unlink mplayer FIFO on exit
Diffstat (limited to 'play.py')
-rwxr-xr-x | play.py | 25 |
1 files changed, 16 insertions, 9 deletions
@@ -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 |