about summary refs log tree commit homepage
path: root/lib/dtas/player
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2016-04-11 02:19:19 +0000
committerEric Wong <e@80x24.org>2016-04-11 02:23:47 +0000
commit285155328f7236539504ea224f2c6250c6b35f75 (patch)
tree2cf1a1068b58ce83a3c6d89e7215f24cab7a2cd1 /lib/dtas/player
parent397d0a58703f887df0adf9c2754422d0af50f92d (diff)
downloaddtas-285155328f7236539504ea224f2c6250c6b35f75.tar.gz
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.
Diffstat (limited to 'lib/dtas/player')
-rw-r--r--lib/dtas/player/client_handler.rb14
1 files changed, 9 insertions, 5 deletions
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')