[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC] player: "cue prev" reliably hits previous cue breakpoint
From: |
Eric Wong |
Subject: |
[RFC] player: "cue prev" reliably hits previous cue breakpoint |
Date: |
Mon, 11 Apr 2016 02:27:43 +0000 |
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")
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 @@ def __bp_prev_next(io, msg, cur, bp)
# 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')
--
EW
- [RFC] player: "cue prev" reliably hits previous cue breakpoint,
Eric Wong <=