about summary refs log tree commit homepage
path: root/lib/dtas/player/client_handler.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-09-28 06:50:04 +0000
committerEric Wong <normalperson@yhbt.net>2013-09-28 07:10:53 +0000
commit77cbb5e71e466749f4966ef0caca6a5077ad72c9 (patch)
treeab5112f6a538e9bab91b0bbe6d5b7c1bceb819b2 /lib/dtas/player/client_handler.rb
parent2118e3aa78ebbd91b9d10ec524186820cbfa9c50 (diff)
downloaddtas-77cbb5e71e466749f4966ef0caca6a5077ad72c9.tar.gz
This may be used to avoid automatic:

* resampling (rate)
* down/upmixing (channel)
* dither/truncation (bits)

Using any bypass mode means we can no longer guarantee gapless
playback for audio collections where rate, channel, or bits vary.
This can however be useful when CPU usage is too high.  This may
also be useful in audio engineering situations.
Diffstat (limited to 'lib/dtas/player/client_handler.rb')
-rw-r--r--lib/dtas/player/client_handler.rb15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/dtas/player/client_handler.rb b/lib/dtas/player/client_handler.rb
index 9c28486..a44c1b7 100644
--- a/lib/dtas/player/client_handler.rb
+++ b/lib/dtas/player/client_handler.rb
@@ -295,6 +295,7 @@ module DTAS::Player::ClientHandler # :nodoc:
     end
     tmp["current_inflight"] = @sink_buf.inflight
     tmp["format"] = @format.to_hash.delete_if { |_,v| v.nil? }
+    tmp["bypass"] = @bypass.sort!
     tmp["paused"] = @paused
     rg = @rg.to_hsh
     tmp["rg"] = rg unless rg.empty?
@@ -402,20 +403,28 @@ module DTAS::Player::ClientHandler # :nodoc:
         new_fmt.valid_type?(v) or return io.emit("ERR invalid file type")
         new_fmt.type = v
       when "channels", "bits", "rate"
-        rv = set_uint(io, kv, v, false) { |u| new_fmt.__send__("#{k}=", u) }
-        rv == true or return rv
+        case v
+        when "bypass"
+          @bypass << k unless @bypass.include?(k)
+        else
+          rv = set_uint(io, kv, v, false) { |u| new_fmt.__send__("#{k}=", u) }
+          rv == true or return rv
+          @bypass.delete(k)
+        end
       when "endian"
         new_fmt.valid_endian?(v) or return io.emit("ERR invalid endian")
         new_fmt.endian = v
       end
     end
 
+    bypass_match!(new_fmt, @current.format) if @current
+
     if new_fmt != @format
       restart_pipeline # calls __current_requeue
 
       # we must assign this after __current_requeue since __current_requeue
       # relies on the old @format for calculation
-      @format = new_fmt
+      format_update!(new_fmt)
     end
     io.emit("OK")
   end