fix: fixed #118, weird threading issue
This commit is contained in:
parent
eeaa09b564
commit
d32d30b795
@ -68,8 +68,8 @@ def register_all_commands(bot):
|
|||||||
|
|
||||||
# Just for debug use
|
# Just for debug use
|
||||||
bot.register_command('rtrms', cmd_real_time_rms, True)
|
bot.register_command('rtrms', cmd_real_time_rms, True)
|
||||||
bot.register_command('loop', cmd_loop_state, True)
|
#bot.register_command('loop', cmd_loop_state, True)
|
||||||
bot.register_command('item', cmd_item, True)
|
#bot.register_command('item', cmd_item, True)
|
||||||
|
|
||||||
|
|
||||||
def send_multi_lines(bot, lines, text, linebreak="<br />"):
|
def send_multi_lines(bot, lines, text, linebreak="<br />"):
|
||||||
@ -1191,5 +1191,4 @@ def cmd_loop_state(bot, user, text, command, parameter):
|
|||||||
|
|
||||||
|
|
||||||
def cmd_item(bot, user, text, command, parameter):
|
def cmd_item(bot, user, text, command, parameter):
|
||||||
print(bot.wait_for_downloading)
|
var.playlist._debug_print()
|
||||||
print(var.playlist.current_item().to_dict())
|
|
||||||
|
@ -202,7 +202,7 @@ class BasePlaylist(list):
|
|||||||
self.from_list(music_wrappers, current_index)
|
self.from_list(music_wrappers, current_index)
|
||||||
|
|
||||||
def _debug_print(self):
|
def _debug_print(self):
|
||||||
print("===== Playlist(%d)=====" % self.current_index)
|
print("===== Playlist(%d) =====" % self.current_index)
|
||||||
for index, item_wrapper in enumerate(self):
|
for index, item_wrapper in enumerate(self):
|
||||||
if index == self.current_index:
|
if index == self.current_index:
|
||||||
print("-> %d %s" % (index, item_wrapper.format_debug_string()))
|
print("-> %d %s" % (index, item_wrapper.format_debug_string()))
|
||||||
|
@ -443,7 +443,7 @@ class MumbleBot:
|
|||||||
else:
|
else:
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
|
|
||||||
if not self.is_pause and (self.thread is None or not raw_music):
|
if not self.is_pause and (self.thread is None or self.thread.poll() is not None):
|
||||||
# ffmpeg thread has gone. indicate that last song has finished, or something is wrong.
|
# ffmpeg thread has gone. indicate that last song has finished, or something is wrong.
|
||||||
if self.read_pcm_size < 481 and len(var.playlist) > 0 and var.playlist.current_index != -1 \
|
if self.read_pcm_size < 481 and len(var.playlist) > 0 and var.playlist.current_index != -1 \
|
||||||
and self.last_ffmpeg_err:
|
and self.last_ffmpeg_err:
|
||||||
@ -567,14 +567,13 @@ class MumbleBot:
|
|||||||
self.log.info("bot: music paused at %.2f seconds." % self.playhead)
|
self.log.info("bot: music paused at %.2f seconds." % self.playhead)
|
||||||
|
|
||||||
def resume(self):
|
def resume(self):
|
||||||
self.is_pause = False
|
|
||||||
|
|
||||||
if var.playlist.current_index == -1:
|
if var.playlist.current_index == -1:
|
||||||
var.playlist.next()
|
var.playlist.next()
|
||||||
|
|
||||||
music_wrapper = var.playlist.current_item()
|
music_wrapper = var.playlist.current_item()
|
||||||
|
|
||||||
if not music_wrapper or not music_wrapper.id == self.pause_at_id or not music_wrapper.is_ready():
|
if not music_wrapper or not music_wrapper.id == self.pause_at_id or not music_wrapper.is_ready():
|
||||||
|
self.is_pause = False
|
||||||
self.playhead = 0
|
self.playhead = 0
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -602,6 +601,7 @@ class MumbleBot:
|
|||||||
self.thread = sp.Popen(command, stdout=sp.PIPE, stderr=pipe_wd, bufsize=480)
|
self.thread = sp.Popen(command, stdout=sp.PIPE, stderr=pipe_wd, bufsize=480)
|
||||||
self.last_volume_cycle_time = time.time()
|
self.last_volume_cycle_time = time.time()
|
||||||
self.pause_at_id = ""
|
self.pause_at_id = ""
|
||||||
|
self.is_pause = False
|
||||||
|
|
||||||
|
|
||||||
def start_web_interface(addr, port):
|
def start_web_interface(addr, port):
|
||||||
|
@ -495,7 +495,6 @@
|
|||||||
statusCode : {
|
statusCode : {
|
||||||
200 : function(data) {
|
200 : function(data) {
|
||||||
if (data.ver !== playlist_ver) {
|
if (data.ver !== playlist_ver) {
|
||||||
playlist_ver = data.ver;
|
|
||||||
checkForPlaylistUpdate();
|
checkForPlaylistUpdate();
|
||||||
}
|
}
|
||||||
updateControls(data.empty, data.play, data.mode);
|
updateControls(data.empty, data.play, data.mode);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user