avoid exception on broken pipe when mplayer exits
Stefan Schuermans

Stefan Schuermans commited on 2014-05-16 18:10:18
Showing 1 changed files, with 15 additions and 0 deletions.

... ...
@@ -124,12 +124,18 @@ class Synchronizer:
124 124
     # switch to pause mode
125 125
     if pause:
126 126
       self.dbg_print("MPlayer stdin: pausing seek 0 0")
127
+      try:
127 128
         self.mplayer.stdin.write("pausing seek 0 0\n") # rel seek 0s, then pause
129
+      except:
130
+        pass
128 131
       self.mplayer_pause = True
129 132
     # continue playing
130 133
     else:
131 134
       self.dbg_print("MPlayer stdin: seek 0 0")
135
+      try:
132 136
         self.mplayer.stdin.write("seek 0 0\n") # realtive seek of 0s
137
+      except:
138
+        pass
133 139
       self.mplayer_pause = False
134 140
     self.mplayer_last_cmd_timestamp = datetime.datetime.now()
135 141
 
... ...
@@ -143,7 +149,10 @@ class Synchronizer:
143 149
       pos = 0.0
144 150
     # set new position
145 151
     self.dbg_print("MPlayer stdin: seek %5.3f 2" % pos)
152
+    try:
146 153
       self.mplayer.stdin.write("seek %5.3f 2\n" % pos) # 2 means absolute pos
154
+    except:
155
+      pass
147 156
     self.mplayer_pos = pos
148 157
     self.mplayer_last_cmd_timestamp = datetime.datetime.now()
149 158
 
... ...
@@ -159,7 +168,10 @@ class Synchronizer:
159 168
       speed = 2.0
160 169
     # set new speed
161 170
     self.dbg_print("MPlayer stdin: speed_set %5.3f" % speed)
171
+    try:
162 172
       self.mplayer.stdin.write("speed_set %5.3f\n" % speed)
173
+    except:
174
+      pass
163 175
     self.mplayer_speed = speed
164 176
     self.mplayer_last_cmd_timestamp = datetime.datetime.now()
165 177
 
... ...
@@ -216,7 +228,10 @@ class Synchronizer:
216 228
     """stop MPlayer process in background"""
217 229
     if self.mplayer is not None:
218 230
       # send quit command
231
+      try:
219 232
         self.mplayer.stdin.write("quit\n")
233
+      except:
234
+        pass
220 235
       # close pipes
221 236
       self.mplayer.stdin.close()
222 237
       self.mplayer.stdout.close()
223 238