diff options
author | Eric Wong <e@80x24.org> | 2016-02-09 04:35:58 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2016-02-12 20:40:41 +0000 |
commit | a10e809698f75a6b4da6b4f387f937aac1752882 (patch) | |
tree | 5c5839599450bb71acbd692b7fd98e926cdd6632 | |
parent | a2e8e0b912ad44a6dc9c8387145f3a48494dd56e (diff) | |
download | dtas-a10e809698f75a6b4da6b4f387f937aac1752882.tar.gz |
Both of these are optional, so stop trying them if we do not detect them.
-rwxr-xr-x | bin/dtas-readahead | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/bin/dtas-readahead b/bin/dtas-readahead index 36d34c4..97d5a89 100755 --- a/bin/dtas-readahead +++ b/bin/dtas-readahead @@ -9,6 +9,8 @@ unless RUBY_PLATFORM =~ /linux/ warn "this relies on Linux /proc and probably does not work well for you" end +@ffprobe = 'ffprobe' +@avprobe = 'avprobe' require 'yaml' require 'io/wait' @@ -97,8 +99,17 @@ def do_ra(fp, pos, w) len: '%.3f' % (len / (1024 * 1024.0)), pos: pos }) spawn('soxi', path, @redir) - spawn('avprobe', path, @redir) - spawn('ffprobe', path, @redir) + begin + spawn(@avprobe, path, @redir) + rescue Errno::ENOENT + @avprobe = false unless File.exist?(path) + end if @avprobe + begin + spawn(@ffprobe, path, @redir) + rescue Errno::ENOENT + @ffprobe = false unless File.exist?(path) + end if @ffprobe + fp.advise(:sequential, pos, len) Thread.new(fp.dup) { |d| d.advise(:willneed, pos, len); d.close } |