From 5572b85c7f42f5eb699a372b0b0d1ed3e2c26a69 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 26 Aug 2013 07:19:10 +0000 Subject: player: restart sinks on "sink ed" modification This is for consistency with source handlers. --- lib/dtas/player/client_handler.rb | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'lib') 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) -- cgit v1.2.3-24-ge0c7