about summary refs log tree commit homepage
path: root/lib/dtas
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2013-08-25 00:50:22 +0000
committerEric Wong <normalperson@yhbt.net>2013-08-25 00:50:48 +0000
commit78e9feabf8030bbf37f36977c3f6ebca78260b20 (patch)
tree135f0c1b630e76bc6c5267136ff7d932156e39a3 /lib/dtas
parentf468d58468b224ea3fb468c9543d8631164f8c55 (diff)
downloaddtas-78e9feabf8030bbf37f36977c3f6ebca78260b20.tar.gz
It was never fully-realized and too crazy/complex to be worth it.
In case we ever need it in the future, git will remember it for us.
Diffstat (limited to 'lib/dtas')
-rw-r--r--lib/dtas/sink_reader_play.rb70
1 files changed, 0 insertions, 70 deletions
diff --git a/lib/dtas/sink_reader_play.rb b/lib/dtas/sink_reader_play.rb
deleted file mode 100644
index 17a0190..0000000
--- a/lib/dtas/sink_reader_play.rb
+++ /dev/null
@@ -1,70 +0,0 @@
-# -*- encoding: binary -*-
-# :stopdoc:
-# Copyright (C) 2013, Eric Wong <normalperson@yhbt.net>
-# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
-require_relative '../dtas'
-
-# parses lines from play(1) -S/--show-progress like this:
-#  In:0.00% 00:00:37.34 [00:00:00.00] Out:1.65M [ -====|====  ]        Clip:0
-#
-# The authors of sox probably did not intend for the output of play(1) to
-# be parsed, but we do it anyways.  We need to be ready to update this
-# code in case play(1) output changes.
-# play -S/--show-progress
-class DTAS::SinkReaderPlay
-  attr_reader :time, :out, :meter, :clips, :headroom
-  attr_reader :to_io
-  attr_reader :wr # this is stderr of play(1)
-
-  def initialize
-    @to_io, @wr = IO.pipe
-    reset
-  end
-
-  def readable_iter
-    buf = Thread.current[:dtas_lbuf] ||= ""
-    begin
-      @rbuf << @to_io.read_nonblock(1024, buf)
-
-      # do not OOM in case SoX changes output format on us
-      @rbuf.clear if @rbuf.size > 0x10000
-
-      # don't handle partial read
-      next unless / Clip:\S+ *\z/ =~ @rbuf
-
-      if @rbuf.gsub!(/(.*)\rIn:\S+ (\S+) \S+ Out:(\S+)\s+(\[[^\]]+\]) /m, "")
-        err = $1
-        @time = $2
-        @out = $3
-        @meter = $4
-        if @rbuf.gsub!(/Hd:(\d+\.\d+) Clip:(\S+) */, "")
-          @headroom = $1
-          @clips = $2
-        elsif @rbuf.gsub!(/\s+Clip:(\S+) */, "")
-          @headroom = nil
-          @clips = $1
-        end
-
-        $stderr.write(err)
-      end
-    rescue EOFError
-      return nil
-    rescue Errno::EAGAIN
-      return :wait_readable
-    end while true
-  end
-
-  def close
-    @wr.close unless @wr.closed?
-    @to_io.close
-  end
-
-  def reset
-    @rbuf = ""
-    @time = @out = @meter = @headroom = @clips = nil
-  end
-
-  def closed?
-    @to_io.closed?
-  end
-end