everything related to duct tape audio suite (dtas)
 help / color / mirror / code / Atom feed
* [RFC] player: "cue prev" reliably hits previous cue breakpoint
@ 2016-04-11  2:27 Eric Wong
  2016-04-24  2:45 ` [PATCH] player: extra "cue" seeking functionality Eric Wong
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Wong @ 2016-04-11  2:27 UTC (permalink / raw)
  To: dtas-all

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.
  Thoughts?  I'm _pretty_ sure this is the right thing to do;
  will think about it for a bit...

 lib/dtas/player/client_handler.rb | 14 +++++++++-----
 1 file 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 @@ def __bp_prev_next(io, msg, cur, bp)
       return io.emit("INVALID TYPE")
     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 @@ def __bp_prev_next(io, msg, cur, bp)
       # go to the next (real) track if not found
     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
       # offset may be nil/zero if we couldn't find a previous breakpoint
       seek_internal(cur, '0')

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-04-24  2:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-11  2:27 [RFC] player: "cue prev" reliably hits previous cue breakpoint Eric Wong
2016-04-24  2:45 ` [PATCH] player: extra "cue" seeking functionality Eric Wong

Code repositories for project(s) associated with this public inbox


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).