Skip to content

Commit

Permalink
fix: 修正在其他linux系统上播放问题
Browse files Browse the repository at this point in the history
  • Loading branch information
out0fmemory committed Jun 19, 2017
1 parent 4481d34 commit 4ef49f6
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions NEMbox/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def runInThread(onExit, arg):
log.error(e)

self.process_first = True
endless_loop_cnt = 0
while True:
if self.playing_flag is False:
break
Expand Down Expand Up @@ -149,18 +150,20 @@ def runInThread(onExit, arg):
break
else:
#有遇到播放玩后没有退出,mpg123一直在发送空消息的情况,此处直接终止处理
if len(strout) == 0 and platform.system() == 'Darwin':
log.error('mpg123 error, halt, endless loop and high cpu use, then we kill it')
try:
self.popen_handler.stdin.write(b'Q\n')
self.popen_handler.stdin.flush()
self.popen_handler.kill()
except IOError as e:
if len(strout) == 0:
endless_loop_cnt += 1
if platform.system() == 'Darwin' or endless_loop_cnt > 100:
log.error('mpg123 error, halt, endless loop and high cpu use, then we kill it')
try:
log.error(e)
except Exception as e1:
pass
break
self.popen_handler.stdin.write(b'Q\n')
self.popen_handler.stdin.flush()
self.popen_handler.kill()
except IOError as e:
try:
log.error(e)
except Exception as e1:
pass
break
if self.playing_flag:
self.next_idx()
onExit()
Expand Down

0 comments on commit 4ef49f6

Please sign in to comment.