dtas 0.16.1 → 0.19.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (170) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/Documentation/.gitignore +1 -1
  4. data/Documentation/GNUmakefile +2 -2
  5. data/Documentation/dtas-archive.pod +2 -2
  6. data/Documentation/dtas-console.pod +2 -2
  7. data/Documentation/dtas-ctl.pod +2 -2
  8. data/Documentation/dtas-cueedit.pod +2 -2
  9. data/Documentation/dtas-enq.pod +2 -2
  10. data/Documentation/dtas-env.pod +3 -3
  11. data/Documentation/dtas-msinkctl.pod +2 -2
  12. data/Documentation/dtas-player.pod +2 -2
  13. data/Documentation/dtas-player_effects.pod +2 -2
  14. data/Documentation/dtas-player_protocol.pod +4 -4
  15. data/Documentation/dtas-player_sink_examples.pod +2 -2
  16. data/Documentation/dtas-sinkedit.pod +4 -4
  17. data/Documentation/dtas-sourceedit.pod +4 -4
  18. data/Documentation/dtas-splitfx.pod +7 -1
  19. data/Documentation/dtas-tl.pod +4 -4
  20. data/Documentation/dtas-xdelay.pod +2 -2
  21. data/Documentation/update-footer.rb +2 -2
  22. data/GIT-VERSION-FILE +1 -1
  23. data/GIT-VERSION-GEN +2 -2
  24. data/GNUmakefile +13 -1
  25. data/HACKING +2 -2
  26. data/INSTALL +10 -24
  27. data/NEWS +103 -0
  28. data/README +14 -8
  29. data/Rakefile +1 -1
  30. data/TODO +3 -1
  31. data/bin/dtas-archive +1 -1
  32. data/bin/dtas-console +17 -21
  33. data/bin/dtas-ctl +1 -1
  34. data/bin/dtas-cueedit +1 -1
  35. data/bin/dtas-enq +1 -1
  36. data/bin/dtas-mlib +1 -1
  37. data/bin/dtas-msinkctl +1 -1
  38. data/bin/dtas-partstats +1 -1
  39. data/bin/dtas-player +1 -1
  40. data/bin/dtas-readahead +3 -3
  41. data/bin/dtas-sinkedit +1 -1
  42. data/bin/dtas-sourceedit +1 -1
  43. data/bin/dtas-splitfx +8 -1
  44. data/bin/dtas-tl +1 -1
  45. data/bin/dtas-xdelay +1 -1
  46. data/dtas-linux.gemspec +2 -2
  47. data/dtas-mpris.gemspec +2 -2
  48. data/dtas.gemspec +3 -3
  49. data/dtas.sh +7 -0
  50. data/examples/zsh-completion/README +3 -0
  51. data/examples/zsh-completion/_dtas-archive +16 -0
  52. data/examples/zsh-completion/_dtas-ctl +114 -0
  53. data/examples/zsh-completion/_dtas-cueedit +7 -0
  54. data/examples/zsh-completion/_dtas-enq +7 -0
  55. data/examples/zsh-completion/_dtas-mlib +29 -0
  56. data/examples/zsh-completion/_dtas-msinkctl +8 -0
  57. data/examples/zsh-completion/_dtas-partstats +7 -0
  58. data/examples/zsh-completion/_dtas-sinkedit +11 -0
  59. data/examples/zsh-completion/_dtas-sourceedit +11 -0
  60. data/examples/zsh-completion/_dtas-splitfx +17 -0
  61. data/examples/zsh-completion/_dtas-tl +52 -0
  62. data/examples/zsh-completion/_dtas-xdelay +17 -0
  63. data/lib/dtas/buffer/fiddle_splice.rb +216 -0
  64. data/lib/dtas/buffer/read_write.rb +3 -3
  65. data/lib/dtas/buffer/splice.rb +9 -5
  66. data/lib/dtas/buffer.rb +10 -7
  67. data/lib/dtas/command.rb +1 -1
  68. data/lib/dtas/compat_onenine.rb +1 -1
  69. data/lib/dtas/cue_index.rb +1 -1
  70. data/lib/dtas/disclaimer.rb +1 -1
  71. data/lib/dtas/edit_client.rb +1 -1
  72. data/lib/dtas/encoding.rb +8 -9
  73. data/lib/dtas/fadefx.rb +1 -1
  74. data/lib/dtas/format.rb +1 -1
  75. data/lib/dtas/mcache.rb +1 -1
  76. data/lib/dtas/mlib/migrations/0001_initial.rb +1 -1
  77. data/lib/dtas/mlib.rb +19 -7
  78. data/lib/dtas/nonblock.rb +1 -1
  79. data/lib/dtas/parse_freq.rb +1 -1
  80. data/lib/dtas/parse_time.rb +1 -1
  81. data/lib/dtas/partstats.rb +2 -3
  82. data/lib/dtas/pipe.rb +13 -9
  83. data/lib/dtas/pipeline.rb +1 -1
  84. data/lib/dtas/player/client_handler.rb +23 -15
  85. data/lib/dtas/player.rb +3 -3
  86. data/lib/dtas/process.rb +1 -1
  87. data/lib/dtas/replaygain.rb +1 -1
  88. data/lib/dtas/rg_state.rb +1 -1
  89. data/lib/dtas/serialize.rb +1 -1
  90. data/lib/dtas/sigevent/efd.rb +3 -1
  91. data/lib/dtas/sigevent/fiddle_efd.rb +38 -0
  92. data/lib/dtas/sigevent/pipe.rb +2 -2
  93. data/lib/dtas/sigevent.rb +6 -3
  94. data/lib/dtas/sink.rb +1 -1
  95. data/lib/dtas/source/av.rb +1 -1
  96. data/lib/dtas/source/av_ff_common.rb +2 -2
  97. data/lib/dtas/source/cmd.rb +1 -1
  98. data/lib/dtas/source/common.rb +1 -1
  99. data/lib/dtas/source/ff.rb +1 -1
  100. data/lib/dtas/source/file.rb +1 -1
  101. data/lib/dtas/source/mp3gain.rb +1 -1
  102. data/lib/dtas/source/sox.rb +2 -2
  103. data/lib/dtas/source/splitfx.rb +1 -1
  104. data/lib/dtas/source.rb +1 -1
  105. data/lib/dtas/spawn_fix.rb +1 -1
  106. data/lib/dtas/splitfx.rb +9 -8
  107. data/lib/dtas/state_file.rb +1 -1
  108. data/lib/dtas/tfx.rb +1 -1
  109. data/lib/dtas/track.rb +1 -1
  110. data/lib/dtas/tracklist.rb +1 -1
  111. data/lib/dtas/unix_accepted.rb +1 -1
  112. data/lib/dtas/unix_client.rb +1 -1
  113. data/lib/dtas/unix_server.rb +1 -1
  114. data/lib/dtas/util.rb +1 -1
  115. data/lib/dtas/version.rb +1 -1
  116. data/lib/dtas/watchable/fiddle_ino.rb +78 -0
  117. data/lib/dtas/watchable/inotify.rb +13 -0
  118. data/lib/dtas/watchable.rb +59 -58
  119. data/lib/dtas/writable_iter.rb +1 -1
  120. data/lib/dtas/xs.rb +1 -1
  121. data/lib/dtas.rb +10 -2
  122. data/man/dtas-archive.1 +15 -15
  123. data/man/dtas-console.1 +19 -19
  124. data/man/dtas-ctl.1 +16 -16
  125. data/man/dtas-cueedit.1 +12 -12
  126. data/man/dtas-enq.1 +12 -12
  127. data/man/dtas-env.7 +15 -15
  128. data/man/dtas-msinkctl.1 +12 -12
  129. data/man/dtas-player.1 +24 -24
  130. data/man/dtas-player_effects.7 +9 -9
  131. data/man/dtas-player_protocol.7 +48 -48
  132. data/man/dtas-player_sink_examples.7 +15 -15
  133. data/man/dtas-sinkedit.1 +16 -16
  134. data/man/dtas-sourceedit.1 +17 -17
  135. data/man/dtas-splitfx.1 +43 -38
  136. data/man/dtas-tl.1 +16 -16
  137. data/man/dtas-xdelay.1 +16 -16
  138. data/perl/dtas-graph +7 -2
  139. data/setup.rb +1 -2
  140. data/test/covshow.rb +1 -1
  141. data/test/helper.rb +1 -1
  142. data/test/player_integration.rb +1 -1
  143. data/test/test_buffer.rb +6 -6
  144. data/test/test_encoding.rb +1 -1
  145. data/test/test_env.rb +1 -1
  146. data/test/test_fadefx.rb +1 -1
  147. data/test/test_format.rb +1 -1
  148. data/test/test_format_change.rb +1 -1
  149. data/test/test_mcache.rb +1 -1
  150. data/test/test_mlib.rb +1 -1
  151. data/test/test_parse_freq.rb +1 -1
  152. data/test/test_pipeline.rb +1 -1
  153. data/test/test_player.rb +1 -1
  154. data/test/test_player_client_handler.rb +1 -1
  155. data/test/test_player_integration.rb +1 -1
  156. data/test/test_process.rb +1 -1
  157. data/test/test_rg_integration.rb +1 -1
  158. data/test/test_rg_state.rb +1 -1
  159. data/test/test_sigevent.rb +20 -0
  160. data/test/test_sink.rb +1 -1
  161. data/test/test_sink_pipe_size.rb +13 -16
  162. data/test/test_sink_tee_integration.rb +1 -1
  163. data/test/test_source_av.rb +1 -1
  164. data/test/test_source_sox.rb +1 -1
  165. data/test/test_splitfx.rb +1 -1
  166. data/test/test_tfx.rb +1 -1
  167. data/test/test_tracklist.rb +1 -1
  168. data/test/test_unixserver.rb +1 -1
  169. data/test/test_util.rb +1 -1
  170. metadata +23 -4
data/lib/dtas/process.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2016 all contributors <dtas-all@nongnu.org>
1
+ # Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
3
3
  # frozen_string_literal: true
4
4
  require 'io/wait'
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2016 all contributors <dtas-all@nongnu.org>
1
+ # Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
3
3
  # frozen_string_literal: true
4
4
 
data/lib/dtas/rg_state.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2016 all contributors <dtas-all@nongnu.org>
1
+ # Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
3
3
  # frozen_string_literal: true
4
4
  #
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2016 all contributors <dtas-all@nongnu.org>
1
+ # Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
3
3
  # frozen_string_literal: true
4
4
 
@@ -1,8 +1,10 @@
1
- # Copyright (C) 2013-2016 all contributors <dtas-all@nongnu.org>
1
+ # Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
3
3
 
4
4
  # used in various places for safe wakeups from IO.select via signals
5
5
  # This requires a modern Linux system and the "sleepy_penguin" RubyGem
6
+ require 'sleepy_penguin'
7
+
6
8
  class DTAS::Sigevent < SleepyPenguin::EventFD # :nodoc:
7
9
  def self.new
8
10
  super(0, :CLOEXEC)
@@ -0,0 +1,38 @@
1
+ # Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
2
+ # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
3
+ # frozen_string_literal: true
4
+
5
+ # used in various places for safe wakeups from IO.select via signals
6
+ # This requires a modern GNU/Linux system with eventfd(2) support
7
+ require_relative '../nonblock'
8
+ require 'fiddle'
9
+ class DTAS::Sigevent # :nodoc:
10
+
11
+ EventFD = Fiddle::Function.new(DTAS.libc['eventfd'],
12
+ [ Fiddle::TYPE_INT, Fiddle::TYPE_INT ], # initval, flags
13
+ Fiddle::TYPE_INT) # fd
14
+
15
+ attr_reader :to_io
16
+ ONE = [ 1 ].pack('Q').freeze
17
+
18
+ def initialize
19
+ fd = EventFD.call(0, 02000000|00004000) # EFD_CLOEXEC|EFD_NONBLOCK
20
+ raise "eventfd failed: #{Fiddle.last_error}" if fd < 0
21
+ @to_io = DTAS::Nonblock.for_fd(fd)
22
+ @buf = ''.b
23
+ end
24
+
25
+ def signal
26
+ @to_io.syswrite(ONE)
27
+ end
28
+
29
+ def readable_iter
30
+ @to_io.read_nonblock(8, @buf, exception: false)
31
+ yield self, nil # calls DTAS::Process.reaper
32
+ :wait_readable
33
+ end
34
+
35
+ def close
36
+ @to_io.close
37
+ end
38
+ end
@@ -1,9 +1,9 @@
1
- # Copyright (C) 2013-2016 all contributors <dtas-all@nongnu.org>
1
+ # Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
3
3
  # frozen_string_literal: true
4
4
 
5
5
  # used in various places for safe wakeups from IO.select via signals
6
- # A fallback for non-Linux systems lacking the "sleepy_penguin" RubyGem
6
+ # A fallback for non-Linux systems lacking the "splice" syscall
7
7
  require_relative '../nonblock'
8
8
  class DTAS::Sigevent # :nodoc:
9
9
  attr_reader :to_io
data/lib/dtas/sigevent.rb CHANGED
@@ -1,10 +1,13 @@
1
- # Copyright (C) 2013-2016 all contributors <dtas-all@nongnu.org>
1
+ # Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
3
3
  # frozen_string_literal: true
4
4
  begin
5
5
  raise LoadError, "no eventfd with _DTAS_POSIX" if ENV["_DTAS_POSIX"]
6
- require 'sleepy_penguin'
7
- require_relative 'sigevent/efd'
6
+ begin
7
+ require_relative 'sigevent/efd'
8
+ rescue LoadError
9
+ require_relative 'sigevent/fiddle_efd'
10
+ end
8
11
  rescue LoadError
9
12
  require_relative 'sigevent/pipe'
10
13
  end
data/lib/dtas/sink.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2016 all contributors <dtas-all@nongnu.org>
1
+ # Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
3
3
  # frozen_string_literal: true
4
4
  require 'yaml'
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2016 all contributors <dtas-all@nongnu.org>
1
+ # Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
3
3
  # frozen_string_literal: true
4
4
  require_relative '../../dtas'
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2016 all contributors <dtas-all@nongnu.org>
1
+ # Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
3
3
  # frozen_string_literal: true
4
4
  require_relative '../../dtas'
@@ -186,7 +186,7 @@ module DTAS::Source::AvFfCommon # :nodoc:
186
186
 
187
187
  e["PROBE"] = @probe_harder ? @probe_harder.join(' ') : nil
188
188
  # make sure these are visible to the source command...
189
- e["INFILE"] = xs(@infile)
189
+ e["INFILE"] = @infile
190
190
  e["AMAP"] = amap
191
191
  e["SSPOS"] = sspos
192
192
  e["RGFX"] = rg_state.effect(self) || nil
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2016 all contributors <dtas-all@nongnu.org>
1
+ # Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
3
3
  # frozen_string_literal: true
4
4
  require_relative '../../dtas'
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2016 all contributors <dtas-all@nongnu.org>
1
+ # Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
3
3
  module DTAS::Source::Common # :nodoc:
4
4
  attr_reader :dst_zero_byte # first byte this source object saw
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2016 all contributors <dtas-all@nongnu.org>
1
+ # Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
3
3
  # frozen_string_literal: true
4
4
  require_relative '../../dtas'
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2016 all contributors <dtas-all@nongnu.org>
1
+ # Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
3
3
  # frozen_string_literal: true
4
4
  require_relative '../../dtas'
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2016 all contributors <dtas-all@nongnu.org>
1
+ # Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
3
3
  # frozen_string_literal: true
4
4
  require_relative '../process'
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2019 all contributors <dtas-all@nongnu.org>
1
+ # Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
3
3
  # frozen_string_literal: true
4
4
  # encoding: binary
@@ -113,7 +113,7 @@ class DTAS::Source::Sox # :nodoc:
113
113
  def src_spawn(player_format, rg_state, opts)
114
114
  raise "BUG: #{self.inspect}#src_spawn called twice" if @to_io
115
115
  e = @env.merge!(player_format.to_env)
116
- e["INFILE"] = xs(@infile)
116
+ e["INFILE"] = @infile
117
117
 
118
118
  # make sure these are visible to the "current" command...
119
119
  e["TRIMFX"] = trimfx
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2014-2016 all contributors <dtas-all@nongnu.org>
1
+ # Copyright (C) 2014-2020 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
3
3
  # frozen_string_literal: true
4
4
  require 'yaml'
data/lib/dtas/source.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2016 all contributors <dtas-all@nongnu.org>
1
+ # Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
3
3
  # frozen_string_literal: true
4
4
  require_relative '../dtas'
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2016 all contributors <dtas-all@nongnu.org>
1
+ # Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
3
3
  # workaround for older Rubies: https://bugs.ruby-lang.org/issues/8770
4
4
  module DTAS::SpawnFix # :nodoc:
data/lib/dtas/splitfx.rb CHANGED
@@ -1,10 +1,9 @@
1
- # Copyright (C) 2013-2016 all contributors <dtas-all@nongnu.org>
1
+ # Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
3
3
  # frozen_string_literal: true
4
4
  require_relative '../dtas'
5
5
  require_relative 'format'
6
6
  require_relative 'process'
7
- require_relative 'xs'
8
7
  require 'tempfile'
9
8
 
10
9
  # The backend for dtas-splitfx(1) command, but also supported by dtas-player
@@ -13,7 +12,6 @@ require 'tempfile'
13
12
  class DTAS::SplitFX # :nodoc:
14
13
  CMD = 'sox "$INFILE" $COMMENTS $OUTFMT $OUTDST $TRIMFX $FX $RATEFX $DITHERFX'
15
14
  include DTAS::Process
16
- include DTAS::XS
17
15
  attr_reader :infile, :env, :command
18
16
 
19
17
  # for --trim on the command-line
@@ -207,11 +205,11 @@ class DTAS::SplitFX # :nodoc:
207
205
  env["DITHERFX"] = "dither -s"
208
206
  end
209
207
  comments = Tempfile.new(%W(dtas-splitfx-#{t.comments["TRACKNUMBER"]} .txt))
210
- comments.sync = true
211
208
  t.comments.each do |k,v|
212
209
  env[k] = v.to_s
213
210
  comments.puts("#{k}=#{v}")
214
211
  end
212
+ comments.flush
215
213
  env["COMMENTS"] = "--comment-file=#{comments.path}"
216
214
  infile_env(env, @infile)
217
215
  outarg = outfmt.to_sox_arg
@@ -250,7 +248,10 @@ class DTAS::SplitFX # :nodoc:
250
248
  command = 'true' if opts[:dryrun] # still gotta fork
251
249
 
252
250
  # pgroup: false so Ctrl-C on command-line will immediately stop everything
253
- [ dtas_spawn(env, command, pgroup: false), comments ]
251
+ o = { pgroup: false }
252
+ e = opts[:err_suffix] and
253
+ o[:err] = [ "#{env['OUTDIR']}#{env['TRACKNUMBER']}#{e}", 'a' ]
254
+ [ dtas_spawn(env, command, o), comments ]
254
255
  end
255
256
 
256
257
  def load_tracks!(hash)
@@ -401,10 +402,10 @@ class DTAS::SplitFX # :nodoc:
401
402
  end
402
403
 
403
404
  def infile_env(env, infile)
404
- env["INFILE"] = xs(infile)
405
+ env["INFILE"] = infile
405
406
  dir, base = File.split(File.expand_path(infile))
406
- env["INDIR"] = xs(dir)
407
- env["INBASE"] = xs(base)
407
+ env["INDIR"] = dir
408
+ env["INBASE"] = base
408
409
  end
409
410
 
410
411
  def expand_cmd(env, command) # for display purposes only
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2016 all contributors <dtas-all@nongnu.org>
1
+ # Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
3
3
  # frozen_string_literal: true
4
4
  require 'yaml'
data/lib/dtas/tfx.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2016 all contributors <dtas-all@nongnu.org>
1
+ # Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
3
3
  # frozen_string_literal: true
4
4
  require_relative '../dtas'
data/lib/dtas/track.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2015-2016 all contributors <dtas-all@nongnu.org>
1
+ # Copyright (C) 2015-2020 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
3
3
  # frozen_string_literal: true
4
4
  require_relative '../dtas'
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2016 all contributors <dtas-all@nongnu.org>
1
+ # Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
3
3
  # frozen_string_literal: true
4
4
  require_relative '../dtas'
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2016 all contributors <dtas-all@nongnu.org>
1
+ # Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
3
3
  # frozen_string_literal: true
4
4
  require 'socket'
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2016 all contributors <dtas-all@nongnu.org>
1
+ # Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
3
3
  # frozen_string_literal: true
4
4
  require_relative '../dtas'
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2016 all contributors <dtas-all@nongnu.org>
1
+ # Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
3
3
  # frozen_string_literal: true
4
4
  require 'socket'
data/lib/dtas/util.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2016 all contributors <dtas-all@nongnu.org>
1
+ # Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
3
3
  # frozen_string_literal: true
4
4
  require_relative '../dtas'
data/lib/dtas/version.rb CHANGED
@@ -1 +1 @@
1
- DTAS::VERSION = '0.16.1'.freeze # :nodoc:
1
+ DTAS::VERSION = '0.19.0'.freeze # :nodoc:
@@ -0,0 +1,78 @@
1
+ # Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
2
+ # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
3
+ # frozen_string_literal: true
4
+ require 'fiddle'
5
+
6
+ # used to restart DTAS::Source::SplitFX processing in dtas-player
7
+ # if the YAML file is edited
8
+ class DTAS::Watchable::InotifyReadableIter # :nodoc:
9
+ include DTAS::Watchable::InotifyCommon
10
+
11
+ Inotify_init = Fiddle::Function.new(DTAS.libc['inotify_init1'],
12
+ [ Fiddle::TYPE_INT ],
13
+ Fiddle::TYPE_INT)
14
+
15
+ Inotify_add_watch = Fiddle::Function.new(DTAS.libc['inotify_add_watch'],
16
+ [ Fiddle::TYPE_INT, Fiddle::TYPE_VOIDP, Fiddle::TYPE_INT ],
17
+ Fiddle::TYPE_INT)
18
+
19
+ # IO.select compatibility
20
+ attr_reader :to_io #:nodoc:
21
+
22
+ def initialize # :nodoc:
23
+ fd = Inotify_init.call(02000000 | 04000) # CLOEXEC | NONBLOCK
24
+ raise "inotify_init failed: #{Fiddle.last_error}" if fd < 0
25
+ @to_io = DTAS::Nonblock.for_fd(fd)
26
+ @buf = ''.b
27
+ @q = []
28
+ end
29
+
30
+ # struct inotify_event {
31
+ # int wd; /* Watch descriptor */
32
+ # uint32_t mask; /* Mask describing event */
33
+ # uint32_t cookie; /* Unique cookie associating related
34
+ # events (for rename(2)) */
35
+ # uint32_t len; /* Size of name field */
36
+ # char name[]; /* Optional null-terminated name */
37
+ InotifyEvent = Struct.new(:wd, :mask, :cookie, :len, :name) # :nodoc:
38
+
39
+ def take(nonblock) # :nodoc:
40
+ event = @q.pop and return event
41
+ case rv = @to_io.read_nonblock(16384, @buf, exception: false)
42
+ when :wait_readable, nil
43
+ return
44
+ else
45
+ until rv.empty?
46
+ hdr = rv.slice!(0,16)
47
+ name = nil
48
+ wd, mask, cookie, len = res = hdr.unpack('iIII')
49
+ wd && mask && cookie && len or
50
+ raise "bogus inotify_event #{res.inspect} hdr=#{hdr.inspect}"
51
+ if len > 0
52
+ name = rv.slice!(0, len)
53
+ name.size == len or raise "short name #{name.inspect} != #{len}"
54
+ name.sub!(/\0+\z/, '') or
55
+ raise "missing: `\\0', inotify_event.name=#{name.inspect}"
56
+ name = DTAS.dedupe_str(name)
57
+ end
58
+ ie = InotifyEvent.new(wd, mask, cookie, len, name)
59
+ if event
60
+ @q << ie
61
+ else
62
+ event = ie
63
+ end
64
+ end # /until rv.empty?
65
+ return event
66
+ end while true
67
+ end
68
+
69
+ def add_watch(watchdir, flags)
70
+ wd = Inotify_add_watch.call(@to_io.fileno, watchdir, flags)
71
+ raise "inotify_add_watch failed: #{Fiddle.last_error}" if wd < 0
72
+ wd
73
+ end
74
+
75
+ def close
76
+ @to_io = @to_io.close if @to_io
77
+ end
78
+ end
@@ -0,0 +1,13 @@
1
+ # Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
2
+ # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
3
+ # frozen_string_literal: true
4
+ require 'sleepy_penguin'
5
+
6
+ # used to restart DTAS::Source::SplitFX processing in dtas-player
7
+ # if the YAML file is edited
8
+ class DTAS::Watchable::InotifyReadableIter < SleepyPenguin::Inotify # :nodoc:
9
+ include DTAS::Watchable::InotifyCommon
10
+ def self.new
11
+ super(:CLOEXEC)
12
+ end
13
+ end
@@ -1,71 +1,72 @@
1
- # Copyright (C) 2013-2019 all contributors <dtas-all@nongnu.org>
1
+ # Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
3
3
  # frozen_string_literal: true
4
+ require_relative '../dtas'
5
+ require_relative 'nonblock'
4
6
  begin
5
- require 'sleepy_penguin'
7
+ module DTAS::Watchable # :nodoc:
8
+ module InotifyCommon # :nodoc:
9
+ FLAGS = 8 | 128 # IN_CLOSE_WRITE | IN_MOVED_TO
6
10
 
7
- # used to restart DTAS::Source::SplitFX processing in dtas-player
8
- # if the YAML file is edited
9
- module DTAS::Watchable # :nodoc:
10
- class InotifyReadableIter < SleepyPenguin::Inotify # :nodoc:
11
- def self.new
12
- super(:CLOEXEC)
13
- end
14
-
15
- FLAGS = CLOSE_WRITE | MOVED_TO
16
-
17
- def readable_iter
18
- or_call = false
19
- while event = take(true) # drain the buffer
20
- w = @watches[event.wd] or next
21
- if (event.mask & FLAGS) != 0 && w[event.name]
22
- or_call = true
11
+ def readable_iter
12
+ or_call = false
13
+ while event = take(true) # drain the buffer
14
+ w = @watches[event.wd] or next
15
+ if (event.mask & FLAGS) != 0 && w[event.name]
16
+ or_call = true
17
+ end
18
+ end
19
+ if or_call
20
+ @on_readable.call
21
+ :delete
22
+ else
23
+ :wait_readable
23
24
  end
24
25
  end
25
- if or_call
26
- @on_readable.call
27
- :delete
28
- else
29
- :wait_readable
30
- end
31
- end
32
26
 
33
- # we must watch the directory, since
34
- def watch_files(paths, blk)
35
- @watches = {} # wd -> { basename -> true }
36
- @on_readable = blk
37
- @dir2wd = {}
38
- Array(paths).each do |path|
39
- watchdir, watchbase = File.split(File.expand_path(path))
40
- begin
41
- wd = @dir2wd[watchdir] ||= add_watch(watchdir, FLAGS)
42
- m = @watches[wd] ||= {}
43
- m[watchbase] = true
44
- rescue SystemCallError => e
45
- warn "#{watchdir.dump}: #{e.message} (#{e.class})"
27
+ # we must watch the directory, since
28
+ def watch_files(paths, blk)
29
+ @watches = {} # wd -> { basename -> true }
30
+ @on_readable = blk
31
+ @dir2wd = {}
32
+ Array(paths).each do |path|
33
+ watchdir, watchbase = File.split(File.expand_path(path))
34
+ begin
35
+ wd = @dir2wd[watchdir] ||= add_watch(watchdir, FLAGS)
36
+ m = @watches[wd] ||= {}
37
+ m[watchbase] = true
38
+ rescue SystemCallError => e
39
+ warn "#{watchdir.dump}: #{e.message} (#{e.class})"
40
+ end
46
41
  end
47
42
  end
48
- end
49
- end
43
+ end # module InotifyCommon
50
44
 
51
- def watch_begin(blk)
52
- @ino = InotifyReadableIter.new
53
- @ino.watch_files(@watch_extra << @infile, blk)
54
- @ino
55
- end
45
+ begin
46
+ require_relative 'watchable/inotify'
47
+ rescue LoadError
48
+ # TODO: support kevent
49
+ require_relative 'watchable/fiddle_ino'
50
+ end
56
51
 
57
- def watch_extra(paths)
58
- @ino.watch_extra(paths)
59
- end
52
+ def watch_begin(blk)
53
+ @ino = DTAS::Watchable::InotifyReadableIter.new
54
+ @ino.watch_files(@watch_extra << @infile, blk)
55
+ @ino
56
+ end
60
57
 
61
- # Closing the inotify descriptor (instead of using inotify_rm_watch)
62
- # is cleaner because it avoids EINVAL on race conditions in case
63
- # a directory is deleted: https://lkml.org/lkml/2007/7/9/3
64
- def watch_end(srv)
65
- srv.wait_ctl(@ino, :delete)
66
- @ino = @ino.close
67
- end
68
- end
58
+ def watch_extra(paths)
59
+ @ino.watch_extra(paths)
60
+ end
69
61
 
70
- rescue LoadError
71
- end
62
+ # Closing the inotify descriptor (instead of using inotify_rm_watch)
63
+ # is cleaner because it avoids EINVAL on race conditions in case
64
+ # a directory is deleted: https://lkml.org/lkml/2007/7/9/3
65
+ def watch_end(srv)
66
+ srv.wait_ctl(@ino, :delete)
67
+ @ino = @ino.close
68
+ end
69
+ end # module DTAS::Watchable
70
+ rescue LoadError, StandardError => e
71
+ warn "#{e.message} (#{e.class})"
72
+ end # begin