Free Software command-line tools for audio playback, mastering, and whatever else related to audio. dtas follows the worse-is-better philosophy and acts as duct tape to combine existing command-line tools for flexibility and ease-of-development. dtas is currently implemented in Ruby (and some embedded shell), but may use other languages in the future. Changes: dtas 0.18.0 fiddle is now supported for Linux users without a C compiler or Ruby headers installed to take advantage of inotify(7) functionality and efficiency improvements with splice(2) and eventfd(7). For non-RubyGems users, there's some setup.rb fixes thanks to James Rowe. Eric Wong (8): doc: fixup leftover ftp://lists.gnu.org links pipe: avoid loading sleepy_penguin provide fiddle-based eventfd implementation buffer: replace sleepy_penguin with fiddle watchable: use fiddle for inotify support doc: remove most recommendations for sleepy_penguin INSTALL: s/bogomips.org/yhbt.net/ doc: update copyrights for 2020 James Rowe (2): setup: update to use RbConfig setup: fix duplicate variable warning * homepage: https://80x24.org/dtas.git/about * https://80x24.org/dtas/INSTALL * https://80x24.org/dtas/dtas-player.txt * https://80x24.org/dtas/NEWS.atom * git clone https://80x24.org/dtas.git * dtas-all@nongnu.org (plain-text only, no HTML mail, please) * mail archives: https://80x24.org/dtas-all/ nntp://news.public-inbox.org/inbox.comp.audio.dtas https://80x24.org/dtas-all/new.atom
The values of F_{GET,SET}PIPE_SZ are architecture-independent and stable in Linux (unlike Ruby :P), so we won't need to bother loading an extra .so here for two constants. --- lib/dtas/pipe.rb | 20 ++++++++++++-------- test/test_sink_pipe_size.rb | 27 ++++++++++++--------------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/lib/dtas/pipe.rb b/lib/dtas/pipe.rb index 58d926c..4c3203d 100644 --- a/lib/dtas/pipe.rb +++ b/lib/dtas/pipe.rb @@ -1,10 +1,6 @@ # Copyright (C) 2013-2019 all contributors <dtas-all@nongnu.org> # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt> # frozen_string_literal: true -begin - require 'sleepy_penguin' -rescue LoadError -end require_relative '../dtas' require_relative 'writable_iter' require_relative 'nonblock' @@ -14,6 +10,11 @@ class DTAS::Pipe < DTAS::Nonblock # :nodoc: include DTAS::WritableIter attr_accessor :sink + if RUBY_PLATFORM =~ /linux/i && File.readable?('/proc/sys/fs/pipe-max-size') + F_SETPIPE_SZ = 1031 + F_GETPIPE_SZ = 1032 + end + def self.new _, w = rv = pipe w.writable_iter_init @@ -21,13 +22,16 @@ def self.new end def pipe_size=(nr) - defined?(SleepyPenguin::F_SETPIPE_SZ) and - fcntl(SleepyPenguin::F_SETPIPE_SZ, nr) + fcntl(F_SETPIPE_SZ, nr) if defined?(F_SETPIPE_SZ) + rescue Errno::EINVAL # old kernel + rescue Errno::EPERM + # resizes fail if Linux is close to the pipe limit for the user + # or if the user does not have permissions to resize end def pipe_size - fcntl(SleepyPenguin::F_GETPIPE_SZ) - end if defined?(SleepyPenguin::F_GETPIPE_SZ) + fcntl(F_GETPIPE_SZ) + end if defined?(F_GETPIPE_SZ) # avoid syscall, we never change IO#nonblock= directly def nonblock? diff --git a/test/test_sink_pipe_size.rb b/test/test_sink_pipe_size.rb index 1b6db72..bbe2884 100644 --- a/test/test_sink_pipe_size.rb +++ b/test/test_sink_pipe_size.rb @@ -1,20 +1,17 @@ # Copyright (C) 2013-2019 all contributors <dtas-all@nongnu.org> # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt> # frozen_string_literal: true -begin - require 'sleepy_penguin' - require './test/player_integration' - class TestSinkPipeSizeIntegration < Testcase - include PlayerIntegration +require './test/player_integration' +class TestSinkPipeSizeIntegration < Testcase + include PlayerIntegration - def test_sink_pipe_size_integration - s = client_socket - default_sink_pid(s) - s.req_ok("sink ed default pipe_size=0x1000") - s.req_ok("sink ed default pipe_size=0x10000") - s.req_ok("sink ed default pipe_size=") - s.req_ok("sink ed default pipe_size=4096") - end if SleepyPenguin.const_defined?(:F_SETPIPE_SZ) + def test_sink_pipe_size_integration + s = client_socket + default_sink_pid(s) + s.req_ok("sink ed default pipe_size=0x1000") + s.req_ok("sink ed default pipe_size=0x10000") + s.req_ok("sink ed default pipe_size=") + s.req_ok("sink ed default pipe_size=4096") end -rescue LoadError -end +end if RUBY_PLATFORM =~ /linux/i && + File.readable?('/proc/sys/fs/pipe-max-size')
fiddle can be used as an alternative to sleepy_penguin, since sleepy_penguin requires development headers and a compiler to install, and fiddle is bundled as part of Ruby. sleepy_penguin can still be faster, though, so we continue supporting sleepy_penguin. Eric Wong (5): pipe: avoid loading sleepy_penguin provide fiddle-based eventfd implementation buffer: replace sleepy_penguin with fiddle watchable: use fiddle for inotify support doc: remove most recommendations for sleepy_penguin Documentation/dtas-sinkedit.pod | 2 +- Documentation/dtas-sourceedit.pod | 2 +- INSTALL | 16 +-- lib/dtas.rb | 8 ++ lib/dtas/buffer.rb | 15 ++- lib/dtas/buffer/fiddle_splice.rb | 216 ++++++++++++++++++++++++++++++ lib/dtas/buffer/read_write.rb | 4 +- lib/dtas/buffer/splice.rb | 2 + lib/dtas/pipe.rb | 20 +-- lib/dtas/sigevent.rb | 7 +- lib/dtas/sigevent/efd.rb | 2 + lib/dtas/sigevent/fiddle_efd.rb | 38 ++++++ lib/dtas/sigevent/pipe.rb | 2 +- lib/dtas/watchable.rb | 115 ++++++++-------- lib/dtas/watchable/fiddle_ino.rb | 78 +++++++++++ lib/dtas/watchable/inotify.rb | 13 ++ test/test_buffer.rb | 10 +- test/test_sigevent.rb | 20 +++ test/test_sink_pipe_size.rb | 27 ++-- 19 files changed, 486 insertions(+), 111 deletions(-) create mode 100644 lib/dtas/buffer/fiddle_splice.rb create mode 100644 lib/dtas/sigevent/fiddle_efd.rb create mode 100644 lib/dtas/watchable/fiddle_ino.rb create mode 100644 lib/dtas/watchable/inotify.rb create mode 100644 test/test_sigevent.rb
The values of F_{GET,SET}PIPE_SZ are architecture-independent and stable in Linux (unlike Ruby :P), so we won't need to bother loading an extra .so here for two constants. --- lib/dtas/pipe.rb | 20 ++++++++++++-------- test/test_sink_pipe_size.rb | 27 ++++++++++++--------------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/lib/dtas/pipe.rb b/lib/dtas/pipe.rb index 58d926c..4c3203d 100644 --- a/lib/dtas/pipe.rb +++ b/lib/dtas/pipe.rb @@ -1,10 +1,6 @@ # Copyright (C) 2013-2019 all contributors <dtas-all@nongnu.org> # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt> # frozen_string_literal: true -begin - require 'sleepy_penguin' -rescue LoadError -end require_relative '../dtas' require_relative 'writable_iter' require_relative 'nonblock' @@ -14,6 +10,11 @@ class DTAS::Pipe < DTAS::Nonblock # :nodoc: include DTAS::WritableIter attr_accessor :sink + if RUBY_PLATFORM =~ /linux/i && File.readable?('/proc/sys/fs/pipe-max-size') + F_SETPIPE_SZ = 1031 + F_GETPIPE_SZ = 1032 + end + def self.new _, w = rv = pipe w.writable_iter_init @@ -21,13 +22,16 @@ def self.new end def pipe_size=(nr) - defined?(SleepyPenguin::F_SETPIPE_SZ) and - fcntl(SleepyPenguin::F_SETPIPE_SZ, nr) + fcntl(F_SETPIPE_SZ, nr) if defined?(F_SETPIPE_SZ) + rescue Errno::EINVAL # old kernel + rescue Errno::EPERM + # resizes fail if Linux is close to the pipe limit for the user + # or if the user does not have permissions to resize end def pipe_size - fcntl(SleepyPenguin::F_GETPIPE_SZ) - end if defined?(SleepyPenguin::F_GETPIPE_SZ) + fcntl(F_GETPIPE_SZ) + end if defined?(F_GETPIPE_SZ) # avoid syscall, we never change IO#nonblock= directly def nonblock? diff --git a/test/test_sink_pipe_size.rb b/test/test_sink_pipe_size.rb index 1b6db72..bbe2884 100644 --- a/test/test_sink_pipe_size.rb +++ b/test/test_sink_pipe_size.rb @@ -1,20 +1,17 @@ # Copyright (C) 2013-2019 all contributors <dtas-all@nongnu.org> # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt> # frozen_string_literal: true -begin - require 'sleepy_penguin' - require './test/player_integration' - class TestSinkPipeSizeIntegration < Testcase - include PlayerIntegration +require './test/player_integration' +class TestSinkPipeSizeIntegration < Testcase + include PlayerIntegration - def test_sink_pipe_size_integration - s = client_socket - default_sink_pid(s) - s.req_ok("sink ed default pipe_size=0x1000") - s.req_ok("sink ed default pipe_size=0x10000") - s.req_ok("sink ed default pipe_size=") - s.req_ok("sink ed default pipe_size=4096") - end if SleepyPenguin.const_defined?(:F_SETPIPE_SZ) + def test_sink_pipe_size_integration + s = client_socket + default_sink_pid(s) + s.req_ok("sink ed default pipe_size=0x1000") + s.req_ok("sink ed default pipe_size=0x10000") + s.req_ok("sink ed default pipe_size=") + s.req_ok("sink ed default pipe_size=4096") end -rescue LoadError -end +end if RUBY_PLATFORM =~ /linux/i && + File.readable?('/proc/sys/fs/pipe-max-size')
fiddle is distributed with Ruby since 1.9.2 (and the oldest we support is 1.9.3). So instead of expecting potential users to install Ruby development headers and a C compiler, just use fiddle to save potential users bandwidth and storage space. We have to define some hard-coded constants, but all of these constants are architecture-independent and we can trust the Linux kernel to never break userspace. Eric Wong (5): pipe: avoid loading sleepy_penguin use fiddle-based eventfd implementation buffer: replace sleepy_penguin with fiddle watchable: use fiddle for inotify support doc: remove "sleepy_penguin" references Documentation/dtas-sinkedit.pod | 2 +- Documentation/dtas-sourceedit.pod | 2 +- INSTALL | 19 ----- dtas-linux.gemspec | 19 ----- lib/dtas.rb | 8 ++ lib/dtas/buffer.rb | 7 +- .../buffer/{splice.rb => fiddle_splice.rb} | 75 ++++++++++++---- lib/dtas/buffer/read_write.rb | 4 +- lib/dtas/pipe.rb | 20 +++-- lib/dtas/sigevent.rb | 3 +- lib/dtas/sigevent/efd.rb | 20 ----- lib/dtas/sigevent/fiddle_efd.rb | 38 +++++++++ lib/dtas/sigevent/pipe.rb | 2 +- lib/dtas/watchable.rb | 85 +++++++++++++++++-- test/test_buffer.rb | 10 +-- test/test_sigevent.rb | 20 +++++ test/test_sink_pipe_size.rb | 27 +++--- 17 files changed, 240 insertions(+), 121 deletions(-) delete mode 100644 dtas-linux.gemspec rename lib/dtas/buffer/{splice.rb => fiddle_splice.rb} (68%) delete mode 100644 lib/dtas/sigevent/efd.rb create mode 100644 lib/dtas/sigevent/fiddle_efd.rb create mode 100644 test/test_sigevent.rb