From 285155328f7236539504ea224f2c6250c6b35f75 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 11 Apr 2016 02:19:19 +0000 Subject: player: "cue prev" reliably hits previous cue breakpoint Seeking around a track should not be done relative to a previous seek, but should rather be analogous to the "tl prev" command to skip around the tracklist. I'm not sure what drugs I was on when I originally wrote this original version, but I'm fairly certain this is a bugfix and not intentional behavior. --- lib/dtas/player/client_handler.rb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'lib/dtas/player/client_handler.rb') diff --git a/lib/dtas/player/client_handler.rb b/lib/dtas/player/client_handler.rb index 7b33967..8a15974 100644 --- a/lib/dtas/player/client_handler.rb +++ b/lib/dtas/player/client_handler.rb @@ -745,9 +745,9 @@ module DTAS::Player::ClientHandler # :nodoc: return io.emit("INVALID TYPE") end fmt = cur.format + ds = __current_decoded_samples case msg[0] when "next" - ds = __current_decoded_samples bp.each do |ci| next if ci.offset_samples(fmt) < ds seek_internal(cur, ci.offset) @@ -756,11 +756,15 @@ module DTAS::Player::ClientHandler # :nodoc: # go to the next (real) track if not found __current_drop when "prev" - os = cur.offset_samples # where we currently started + prev = nil bp.reverse_each do |ci| - next if ci.offset_samples(fmt) >= os - seek_internal(cur, ci.offset) - return io.emit("OK") + if prev.nil? + next if ci.offset_samples(fmt) >= ds + prev = ci + else + seek_internal(cur, ci.offset) + return io.emit("OK") + end end # offset may be nil/zero if we couldn't find a previous breakpoint seek_internal(cur, '0') -- cgit v1.2.3-24-ge0c7