From 1caccb72485e06a17cae6cf2c03c54d434d32949 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 31 Dec 2015 02:37:55 +0000 Subject: dtas-console: show trim and "tl repeat" status It probably makes sense for the -console user to know if tracklist repeat and trim are enabled. Have player emit these in "current" output and let the console client track them for now. --- bin/dtas-console | 18 +++++++++++------- lib/dtas/player/client_handler.rb | 8 +++++++- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/bin/dtas-console b/bin/dtas-console index 18f42b6..909f307 100755 --- a/bin/dtas-console +++ b/bin/dtas-console @@ -149,16 +149,14 @@ begin fmt = "(#{fmt} > #{fmt})" end elsif cur['paused'] && infile = cur['current_paused'] + fmt = '(paused)' paused = true if Array === infile infile, elapsed = infile elapsed = elapsed.to_i - samples = qx(%W(soxi -s #{infile})).to_i rescue 0 - rate = 0 + samples = rate = 0 begin - fmt = DTAS::Format.from_file({}, infile) - rate = fmt.rate - fmt = "(#{fmt_to_s(fmt.to_hash)})" + rate = qx(%W(soxi -r #{infile})).to_i rescue => e warn "#{e.message} (#{e.class})" end @@ -174,7 +172,7 @@ begin Curses.setpos(lineno += 1, 0) Curses.clrtoeol Curses.addstr(infile) - total = " [#{Time.at(samples / rate).strftime(tfmt)}]" + total = " [#{Time.at(samples / rate).strftime(tfmt)}]" if samples != 0 Curses.setpos(lineno += 1, 0) Curses.clrtoeol Curses.addstr("#{Time.at(elapsed).strftime(tfmt)}#{total} #{fmt}") @@ -195,7 +193,13 @@ begin Curses.setpos(lineno += 1, 0) Curses.clrtoeol cur_vol = rg['volume'] || 1.0 - Curses.addstr("volume=#{cur_vol}") + extra = [ "volume=#{cur_vol}" ] + repeat = 'false' + tl = cur['tracklist'] || {} + extra << "repeat=#{tl['repeat'] || 'false'}" + trim = cur['trim'] || 'off' + extra << "trim=#{trim}" + Curses.addstr(extra.join(' ')) pre_mute_vol = cur_vol if cur_vol != 0 show_events(lineno, screen, events) diff --git a/lib/dtas/player/client_handler.rb b/lib/dtas/player/client_handler.rb index 6167fcb..617a20c 100644 --- a/lib/dtas/player/client_handler.rb +++ b/lib/dtas/player/client_handler.rb @@ -302,6 +302,7 @@ module DTAS::Player::ClientHandler # :nodoc: tmp["current_inflight"] = @sink_buf.inflight tmp["format"] = @format.to_hash.delete_if { |_,v| v.nil? } tmp["bypass"] = @bypass.sort! + t = @trim and tmp['trim'] = t.join(' ') if tmp['paused'] = @paused first = @queue[0] and tmp['current_paused'] = first end @@ -602,12 +603,15 @@ module DTAS::Player::ClientHandler # :nodoc: def _dpc_tl_repeat(io, msg) prev = @tl.repeat.to_s + do_wall = true case msg.shift when 'true' then @tl.repeat = true when 'false' then @tl.repeat = false when '1' then @tl.repeat = 1 when nil + do_wall = false end + __wall("tl repeat #{@tl.repeat}") if do_wall io.emit("tl repeat #{prev}") end @@ -793,7 +797,9 @@ module DTAS::Player::ClientHandler # :nodoc: else return io.emit('ERR usage: trim [off|TBEG [TLEN]]') end - io.emit(t ? t.map(&:to_s).join(' ') : 'off') + t = t ? t.map(&:to_s).join(' ') : 'off' + __wall("trim #{t}") + io.emit(t) end end # :startdoc: -- cgit v1.2.3-24-ge0c7