about summary refs log tree commit homepage
path: root/lib/dtas/buffer/splice.rb
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2015-02-04 07:09:29 +0000
committerEric Wong <e@80x24.org>2015-02-04 07:09:29 +0000
commit33746aa40a70e38aa8386d81d1f22a884db3ed9f (patch)
tree7646a5d2fa70f5f76792aa90c2e05690feff23f3 /lib/dtas/buffer/splice.rb
parent2946d628a4853c7c130778ea62ffa2c6bbcadcc3 (diff)
downloaddtas-33746aa40a70e38aa8386d81d1f22a884db3ed9f.tar.gz
This will aid in allowing us to create effects which affect
only a certain part of a track.
Diffstat (limited to 'lib/dtas/buffer/splice.rb')
-rw-r--r--lib/dtas/buffer/splice.rb9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/dtas/buffer/splice.rb b/lib/dtas/buffer/splice.rb
index b987f3a..02ce877 100644
--- a/lib/dtas/buffer/splice.rb
+++ b/lib/dtas/buffer/splice.rb
@@ -28,9 +28,10 @@ module DTAS::Buffer::Splice # :nodoc:
     IO.splice(@to_io, nil, DEVNULL, nil, bytes)
   end
 
-  def broadcast_one(targets)
+  def broadcast_one(targets, limit = nil)
     # single output is always non-blocking
-    s = IO.trysplice(@to_io, nil, targets[0], nil, MAX_AT_ONCE_1, F_MOVE)
+    limit ||= MAX_AT_ONCE_1
+    s = IO.trysplice(@to_io, nil, targets[0], nil, limit, F_MOVE)
     if Symbol === s
       targets # our one and only target blocked on write
     else
@@ -88,7 +89,7 @@ module DTAS::Buffer::Splice # :nodoc:
     most_teed
   end
 
-  def broadcast_inf(targets)
+  def broadcast_inf(targets, limit = nil)
     if targets.all?(&:ready_write_optimized?)
       blocked = []
     elsif targets.none?(&:nonblock?)
@@ -105,7 +106,7 @@ module DTAS::Buffer::Splice # :nodoc:
     end
 
     # don't pin too much on one target
-    bytes = MAX_AT_ONCE
+    bytes = limit || MAX_AT_ONCE
     last = targets.pop # we splice to the last one, tee to the rest
 
     # this may return zero if all targets were non-blocking