about summary refs log tree commit homepage
path: root/lib/dtas/player/client_handler.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/dtas/player/client_handler.rb')
-rw-r--r--lib/dtas/player/client_handler.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/dtas/player/client_handler.rb b/lib/dtas/player/client_handler.rb
index 7028c5e..40825a0 100644
--- a/lib/dtas/player/client_handler.rb
+++ b/lib/dtas/player/client_handler.rb
@@ -91,6 +91,9 @@ module DTAS::Player::ClientHandler # :nodoc:
         # do not reactivate it until we've reaped it
         if sink.pid
           drop_sink(sink)
+
+          # we must restart @current if there's a moment we're target-less:
+          __current_requeue unless @targets[0]
         else
           __sink_activate(sink)
         end
@@ -104,6 +107,10 @@ module DTAS::Player::ClientHandler # :nodoc:
     @srv.wait_ctl(@sink_buf, :wait_readable)
   end
 
+  def __sink_snapshot(sink)
+    [ sink.command, sink.env, sink.pipe_size ].inspect
+  end
+
   # returns a wait_ctl arg
   def sink_handler(io, msg)
     name = msg[1]
@@ -123,6 +130,7 @@ module DTAS::Player::ClientHandler # :nodoc:
 
       sink.name = name
       active_before = sink.active
+      before = __sink_snapshot(sink)
 
       # multiple changes may be made at once
       msg[2..-1].each do |kv|
@@ -149,11 +157,13 @@ module DTAS::Player::ClientHandler # :nodoc:
       end
 
       @sinks[name] = new_sink if new_sink # no errors? it's a new sink!
+      after = __sink_snapshot(sink)
 
       # start or stop a sink if its active= flag changed.  Additionally,
       # account for a crashed-but-marked-active sink.  The user may have
       # fixed the command to not crash it.
-      if (active_before != sink.active) || (sink.active && !sink.pid)
+      if (active_before != sink.active) ||
+         (sink.active && (!sink.pid || before != after))
         __sink_switch(sink)
       end
       io.emit("OK")
@@ -298,7 +308,7 @@ module DTAS::Player::ClientHandler # :nodoc:
     io.emit(tmp.to_yaml)
   end
 
-  def __buf_reset(buf)
+  def __buf_reset(buf) # buf is always @sink_buf for now
     @srv.wait_ctl(buf, :ignore)
     buf.buf_reset
     @srv.wait_ctl(buf, :wait_readable)