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
@@ -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
  require 'io/nonblock'
@@ -6,8 +6,8 @@ require_relative '../../dtas'
6
6
  require_relative '../pipe'
7
7
  require_relative '../nonblock'
8
8
 
9
- # compatibility code for systems lacking "splice" support via the
10
- # "sleepy_penguin" 3.5+ RubyGem. Used only by -player
9
+ # compatibility code for non-Linux systems lacking "splice" support.
10
+ # Used only by -player
11
11
  module DTAS::Buffer::ReadWrite # :nodoc:
12
12
  MAX_AT_ONCE = 512 # min PIPE_BUF value in POSIX
13
13
  attr_accessor :buffer_size
@@ -1,10 +1,12 @@
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
  require 'io/nonblock'
5
5
  require 'sleepy_penguin'
6
6
  require_relative '../../dtas'
7
7
  require_relative '../pipe'
8
+ SleepyPenguin.respond_to?(:splice) or
9
+ raise LoadError, 'sleepy_penguin 3.5+ required for splice', []
8
10
 
9
11
  # Used by -player on Linux systems with the "sleepy_penguin" RubyGem installed
10
12
  module DTAS::Buffer::Splice # :nodoc:
@@ -12,7 +14,6 @@ module DTAS::Buffer::Splice # :nodoc:
12
14
  MAX_AT_ONCE_1 = 65536
13
15
  F_MOVE = SleepyPenguin::F_MOVE
14
16
  F_NONBLOCK = SleepyPenguin::F_NONBLOCK
15
- TRY = { exception: false }.freeze
16
17
 
17
18
  def buffer_size
18
19
  @to_io.pipe_size
@@ -32,7 +33,8 @@ module DTAS::Buffer::Splice # :nodoc:
32
33
  def broadcast_one(targets, limit = nil)
33
34
  # single output is always non-blocking
34
35
  limit ||= MAX_AT_ONCE_1
35
- s = SleepyPenguin.splice(@to_io, targets[0], limit, F_MOVE|F_NONBLOCK, TRY)
36
+ s = SleepyPenguin.splice(@to_io, targets[0], limit, F_MOVE|F_NONBLOCK,
37
+ exception: false)
36
38
  if Symbol === s
37
39
  targets # our one and only target blocked on write
38
40
  else
@@ -71,7 +73,8 @@ module DTAS::Buffer::Splice # :nodoc:
71
73
  targets.delete_if do |dst|
72
74
  begin
73
75
  t = (dst.nonblock? || most_teed == 0) ?
74
- SleepyPenguin.tee(@to_io, dst, chunk_size, F_NONBLOCK, TRY) :
76
+ SleepyPenguin.tee(@to_io, dst, chunk_size, F_NONBLOCK,
77
+ exception: false) :
75
78
  __tee_in_full(@to_io, dst, chunk_size)
76
79
  if Integer === t
77
80
  if t > most_teed
@@ -119,7 +122,8 @@ module DTAS::Buffer::Splice # :nodoc:
119
122
  begin
120
123
  targets << last
121
124
  if last.nonblock? || most_teed == 0
122
- s = SleepyPenguin.splice(@to_io, last, bytes, F_MOVE|F_NONBLOCK, TRY)
125
+ s = SleepyPenguin.splice(@to_io, last, bytes, F_MOVE|F_NONBLOCK,
126
+ exception: false)
123
127
  if Symbol === s
124
128
  blocked << last
125
129
 
data/lib/dtas/buffer.rb CHANGED
@@ -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
  require 'io/wait'
@@ -8,12 +8,15 @@ require_relative '../dtas'
8
8
  class DTAS::Buffer # :nodoc:
9
9
  begin
10
10
  raise LoadError, "no splice with _DTAS_POSIX" if ENV["_DTAS_POSIX"]
11
- require 'sleepy_penguin' # splice is only in Linux for now...
12
- SleepyPenguin.respond_to?(:splice) or
13
- raise LoadError, 'sleepy_penguin 3.5+ required for splice', []
14
- require_relative 'buffer/splice'
15
- include DTAS::Buffer::Splice
16
- rescue LoadError
11
+ # splice is only in Linux for now
12
+ begin
13
+ require_relative 'buffer/splice'
14
+ include DTAS::Buffer::Splice
15
+ rescue LoadError
16
+ require_relative 'buffer/fiddle_splice'
17
+ include DTAS::Buffer::FiddleSplice
18
+ end
19
+ rescue LoadError, StandardError
17
20
  require_relative 'buffer/read_write'
18
21
  include DTAS::Buffer::ReadWrite
19
22
  end
data/lib/dtas/command.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 'serialize'
@@ -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
 
4
4
  # Make Ruby 1.9.3 look like Ruby 2.0.0 to us
@@ -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,5 +1,5 @@
1
1
  # :enddoc:
2
- # Copyright (C) 2013-2016 all contributors <dtas-all@nongnu.org>
2
+ # Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
3
3
  # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
4
4
  # frozen_string_literal: true
5
5
  DTAS_PROGNAME = File.basename($0)
@@ -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 'tempfile'
data/lib/dtas/encoding.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2018-2019 all contributors <dtas-all@nongnu.org>
1
+ # Copyright (C) 2018-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
 
@@ -11,15 +11,14 @@ module DTAS::Encoding # :nodoc:
11
11
  private
12
12
 
13
13
  def try_enc_harder(str, enc, old) # :nodoc:
14
+ begin
15
+ require 'charlock_holmes'
16
+ @charlock_holmes = CharlockHolmes::EncodingDetector.new
17
+ rescue LoadError
18
+ @charlock_holmes = false
19
+ end if @charlock_holmes.nil?
20
+
14
21
  case @charlock_holmes
15
- when nil
16
- begin
17
- require 'charlock_holmes'
18
- @charlock_holmes = CharlockHolmes::EncodingDetector.new
19
- rescue LoadError
20
- warn "`charlock_holmes` gem not available for encoding detection"
21
- @charlock_holmes = false
22
- end
23
22
  when false
24
23
  enc_fallback(str, enc, old)
25
24
  else
data/lib/dtas/fadefx.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/format.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/mcache.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2016 all contributors <dtas-all@nongnu.org>
1
+ # Copyright (C) 2016-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
@@ -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
 
4
4
  Sequel.migration do
data/lib/dtas/mlib.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # Copyright (C) 2015-2019 all contributors <dtas-all@nongnu.org>
2
+ # Copyright (C) 2015-2021 all contributors <dtas-all@nongnu.org>
3
3
  # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
4
4
  # frozen_string_literal: true
5
5
  #
@@ -129,9 +129,13 @@ class DTAS::Mlib # :nodoc:
129
129
  comments.where(q).delete
130
130
  tmp.each do |tid, val|
131
131
  v = vals[val: val]
132
- q[:val_id] = v ? v[:id] : vals.insert(val: val)
133
- q[:tag_id] = tid
134
- comments.insert(q)
132
+ begin
133
+ q[:val_id] = v ? v[:id] : vals.insert(val: val)
134
+ q[:tag_id] = tid
135
+ comments.insert(q)
136
+ rescue => e
137
+ warn "E: #{e.message} (#{e.class}) q=#{q.inspect} val=#{val.inspect}"
138
+ end
135
139
  end
136
140
  end
137
141
  end
@@ -214,12 +218,16 @@ class DTAS::Mlib # :nodoc:
214
218
  end
215
219
  end
216
220
 
221
+ def maybe_blob(path)
222
+ path.valid_encoding? ? path : Sequel.blob(path)
223
+ end
224
+
217
225
  def scan_file(path, st, parent_id)
218
226
  return if @suffixes !~ path || st.size == 0
219
227
 
220
228
  # no-op if no change
221
229
  unless @force
222
- if node = @db[:nodes][name: path, parent_id: parent_id]
230
+ if node = @db[:nodes][name: maybe_blob(path), parent_id: parent_id]
223
231
  return if st.ctime.to_i == node[:ctime] || node[:tlen] == DM_IGN
224
232
  end
225
233
  end
@@ -271,14 +279,16 @@ class DTAS::Mlib # :nodoc:
271
279
  node_id = node.delete(:id)
272
280
  @db[:nodes].where(id: node_id).update(node.merge(q))
273
281
  node[:id] = node_id
282
+ rescue => e
283
+ warn "E: #{e.message} (#{e.class}) node=#{node.inspect}"
274
284
  end
275
285
 
276
286
  def node_lookup(parent_id, name)
277
- @db[:nodes][name: name, parent_id: parent_id]
287
+ @db[:nodes][name: maybe_blob(name), parent_id: parent_id]
278
288
  end
279
289
 
280
290
  def node_ensure(parent_id, name, tlen, ctime = nil)
281
- q = { name: name, parent_id: parent_id }
291
+ q = { name: maybe_blob(name), parent_id: parent_id }
282
292
  if node = @db[:nodes][q]
283
293
  node_update_maybe(node, tlen, ctime)
284
294
  else
@@ -289,6 +299,8 @@ class DTAS::Mlib # :nodoc:
289
299
  node[:id] = @db[:nodes].insert(node)
290
300
  end
291
301
  node
302
+ rescue => e
303
+ warn "E: #{e.message} (#{e.class}) q=#{q.inspect}"
292
304
  end
293
305
 
294
306
  def cd(path)
data/lib/dtas/nonblock.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
 
4
4
  class DTAS::Nonblock < IO # :nodoc:
@@ -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,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- # Copyright (C) 2013-2016 all contributors <dtas-all@nongnu.org>
2
+ # Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
3
3
  # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
4
4
  # frozen_string_literal: true
5
5
  require_relative '../dtas'
@@ -1,9 +1,8 @@
1
1
  # -*- encoding: binary -*-
2
- # Copyright (C) 2013-2016 all contributors <dtas-all@nongnu.org>
2
+ # Copyright (C) 2013-2020 all contributors <dtas-all@nongnu.org>
3
3
  # License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
4
4
  # frozen_string_literal: true
5
5
  require_relative '../dtas'
6
- require_relative 'xs'
7
6
  require_relative 'process'
8
7
  require_relative 'sigevent'
9
8
 
@@ -56,7 +55,7 @@ class DTAS::PartStats # :nodoc:
56
55
  rd, wr = IO.pipe
57
56
  env = opts[:env]
58
57
  env = env ? env.dup : {}
59
- env["INFILE"] = xs(@infile)
58
+ env["INFILE"] = @infile
60
59
  env["TRIMFX"] = "trim #{trim_part.tbeg}s #{trim_part.tlen}s"
61
60
  opts = { pgroup: true, close_others: true, err: wr }
62
61
  pid = spawn(env, CMD, opts)
data/lib/dtas/pipe.rb CHANGED
@@ -1,10 +1,6 @@
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
- begin
5
- require 'sleepy_penguin'
6
- rescue LoadError
7
- end
8
4
  require_relative '../dtas'
9
5
  require_relative 'writable_iter'
10
6
  require_relative 'nonblock'
@@ -14,6 +10,11 @@ class DTAS::Pipe < DTAS::Nonblock # :nodoc:
14
10
  include DTAS::WritableIter
15
11
  attr_accessor :sink
16
12
 
13
+ if RUBY_PLATFORM =~ /linux/i && File.readable?('/proc/sys/fs/pipe-max-size')
14
+ F_SETPIPE_SZ = 1031
15
+ F_GETPIPE_SZ = 1032
16
+ end
17
+
17
18
  def self.new
18
19
  _, w = rv = pipe
19
20
  w.writable_iter_init
@@ -21,13 +22,16 @@ class DTAS::Pipe < DTAS::Nonblock # :nodoc:
21
22
  end
22
23
 
23
24
  def pipe_size=(nr)
24
- defined?(SleepyPenguin::F_SETPIPE_SZ) and
25
- fcntl(SleepyPenguin::F_SETPIPE_SZ, nr)
25
+ fcntl(F_SETPIPE_SZ, nr) if defined?(F_SETPIPE_SZ)
26
+ rescue Errno::EINVAL # old kernel
27
+ rescue Errno::EPERM
28
+ # resizes fail if Linux is close to the pipe limit for the user
29
+ # or if the user does not have permissions to resize
26
30
  end
27
31
 
28
32
  def pipe_size
29
- fcntl(SleepyPenguin::F_GETPIPE_SZ)
30
- end if defined?(SleepyPenguin::F_GETPIPE_SZ)
33
+ fcntl(F_GETPIPE_SZ)
34
+ end if defined?(F_GETPIPE_SZ)
31
35
 
32
36
  # avoid syscall, we never change IO#nonblock= directly
33
37
  def nonblock?
data/lib/dtas/pipeline.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2017-2019 all contributors <dtas-all@nongnu.org>
1
+ # Copyright (C) 2017-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 '../xs'
@@ -197,19 +197,20 @@ module DTAS::Player::ClientHandler # :nodoc:
197
197
  end
198
198
  end
199
199
 
200
+ def __offset_to_i(offset, src)
201
+ # either "999s" for 999 samples or HH:MM:SS for time
202
+ offset.sub!(/s\z/, '') ? offset.to_i : src.format.hhmmss_to_samples(offset)
203
+ end
204
+
200
205
  def __offset_to_samples(offset)
201
- offset.sub!(/s\z/, '') and return offset.to_i
202
- @current.format.hhmmss_to_samples(offset)
206
+ __offset_to_i(offset, @current)
203
207
  end
204
208
 
205
209
  # returns seek offset as an Integer in sample count
206
- def __seek_offset_adj(dir, offset)
207
- if offset.sub!(/s\z/, '')
208
- offset = offset.to_i
209
- else # time
210
- offset = @current.format.hhmmss_to_samples(offset)
211
- end
212
- n = __current_decoded_samples + (dir * offset)
210
+ def __seek_offset_adj(dir, offset,
211
+ src = @current,
212
+ current_decoded_samples = __current_decoded_samples)
213
+ n = current_decoded_samples + (dir * __offset_to_i(offset, src))
213
214
  n = 0 if n < 0
214
215
  "#{n}s"
215
216
  end
@@ -391,15 +392,17 @@ module DTAS::Player::ClientHandler # :nodoc:
391
392
  end
392
393
  end
393
394
 
395
+ def __offset_direction(offset)
396
+ offset.sub!(/\A\+/, '') ? 1 : (offset.sub!(/\A-/, '') ? -1 : nil)
397
+ end
398
+
394
399
  def dpc_seek(io, msg)
395
400
  offset = msg[0] or return io.emit('ERR usage: seek OFFSET')
396
401
  if @current
397
402
  if @current.respond_to?(:infile)
398
403
  begin
399
- if offset.sub!(/\A\+/, '')
400
- offset = __seek_offset_adj(1, offset)
401
- elsif offset.sub!(/\A-/, '')
402
- offset = __seek_offset_adj(-1, offset)
404
+ if direction = __offset_direction(offset)
405
+ offset = __seek_offset_adj(direction, offset)
403
406
  # else: pass to sox directly
404
407
  end
405
408
  rescue ArgumentError
@@ -413,7 +416,12 @@ module DTAS::Player::ClientHandler # :nodoc:
413
416
  case file = @queue[0]
414
417
  when String
415
418
  @queue[0] = [ file, offset ]
416
- when Array
419
+ when Array # offset already stored, adjust
420
+ if direction = __offset_direction(offset)
421
+ tmp = try_file(*file)
422
+ cur_off = __offset_to_i(file[1].dup, tmp)
423
+ offset = __seek_offset_adj(direction, offset, tmp, cur_off)
424
+ end
417
425
  file[1] = offset
418
426
  else
419
427
  return io.emit("ERR unseekable")
data/lib/dtas/player.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'
@@ -282,7 +282,7 @@ class DTAS::Player # :nodoc:
282
282
  if deleted[0]
283
283
  warn("#{sink.name} died unexpectedly: #{status.inspect}")
284
284
  deleted.each { |t| drop_target(t) }
285
- __current_drop unless @targets[0]
285
+ do_pause unless @targets[0]
286
286
  return # sink stays dead if it died unexpectedly
287
287
  end
288
288
 
@@ -451,7 +451,7 @@ class DTAS::Player # :nodoc:
451
451
  # pull data from sink_buf into @targets, source feeds into sink_buf
452
452
  def sink_iter
453
453
  wait_iter = broadcast_iter(@sink_buf, @targets)
454
- __current_drop if nil == wait_iter # sink error, stop source
454
+ do_pause if nil == wait_iter # sink error, stop source
455
455
  return wait_iter if @current
456
456
 
457
457
  # no source left to feed sink_buf, drain the remaining data