From aecc68d704e251775732da23eea1cfa301316d65 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 26 Aug 2013 08:50:12 +0000 Subject: player: do not assign @current until successful spawn This should hopefully prevent us from getting wedged if we hit an error while preparing to spawn (or during spawn). --- lib/dtas/player.rb | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/dtas/player.rb b/lib/dtas/player.rb index 0e7a4b5..a508488 100644 --- a/lib/dtas/player.rb +++ b/lib/dtas/player.rb @@ -346,19 +346,20 @@ class DTAS::Player # :nodoc: case source_spec when String - @current = try_file(source_spec) or return - echo(%W(file #{@current.infile})) + pending = try_file(source_spec) or return + echo(%W(file #{pending.infile})) when Array - @current = try_file(*source_spec) or return - echo(%W(file #{@current.infile} #{@current.offset_samples}s)) + pending = try_file(*source_spec) or return + echo(%W(file #{pending.infile} #{pending.offset_samples}s)) else - @current = DTAS::Source::Cmd.new(source_spec["command"]) - echo(%W(command #{@current.command_string})) + pending = DTAS::Source::Cmd.new(source_spec["command"]) + echo(%W(command #{pending.command_string})) end dst = @sink_buf - @current.dst_assoc(dst) - @current.spawn(@format, @rg, out: dst.wr, in: "/dev/null") + pending.dst_assoc(dst) + pending.spawn(@format, @rg, out: dst.wr, in: "/dev/null") + @current = pending @srv.wait_ctl(dst, :wait_readable) else stop_sinks if @sink_buf.inflight == 0 -- cgit v1.2.3-24-ge0c7