dtas 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (120) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/Documentation/.gitignore +1 -1
  4. data/Documentation/GNUmakefile +3 -1
  5. data/Documentation/dtas-archive.txt +61 -0
  6. data/Documentation/dtas-console.txt +4 -3
  7. data/Documentation/dtas-ctl.txt +4 -3
  8. data/Documentation/dtas-cueedit.txt +4 -3
  9. data/Documentation/dtas-enq.txt +4 -3
  10. data/Documentation/dtas-env.txt +60 -0
  11. data/Documentation/dtas-msinkctl.txt +4 -3
  12. data/Documentation/dtas-player.txt +6 -3
  13. data/Documentation/dtas-player_effects.txt +4 -3
  14. data/Documentation/dtas-player_protocol.txt +27 -4
  15. data/Documentation/dtas-player_sink_examples.txt +7 -3
  16. data/Documentation/dtas-sinkedit.txt +20 -3
  17. data/Documentation/dtas-sourceedit.txt +21 -3
  18. data/Documentation/dtas-splitfx.txt +14 -5
  19. data/Documentation/dtas-tl.txt +4 -3
  20. data/Documentation/dtas-xdelay.txt +4 -3
  21. data/Documentation/update-footer.rb +52 -0
  22. data/GIT-VERSION-GEN +2 -2
  23. data/GNUmakefile +1 -1
  24. data/HACKING +3 -2
  25. data/INSTALL +6 -6
  26. data/README +1 -1
  27. data/Rakefile +2 -3
  28. data/TODO +1 -1
  29. data/bin/dtas-archive +187 -0
  30. data/bin/dtas-console +7 -1
  31. data/bin/dtas-ctl +1 -1
  32. data/bin/dtas-cueedit +3 -3
  33. data/bin/dtas-enq +1 -1
  34. data/bin/dtas-msinkctl +1 -1
  35. data/bin/dtas-partstats +10 -4
  36. data/bin/dtas-player +1 -1
  37. data/bin/dtas-sinkedit +82 -20
  38. data/bin/dtas-sourceedit +64 -22
  39. data/bin/dtas-splitfx +1 -1
  40. data/bin/dtas-tl +1 -1
  41. data/bin/dtas-xdelay +1 -1
  42. data/dtas-linux.gemspec +1 -1
  43. data/dtas-mpris.gemspec +1 -1
  44. data/dtas.gemspec +1 -1
  45. data/examples/splitfx.sample.yml +11 -3
  46. data/examples/{trimfx.sample.yml → tfx.sample.yml} +1 -1
  47. data/lib/dtas.rb +2 -1
  48. data/lib/dtas/buffer.rb +5 -5
  49. data/lib/dtas/buffer/read_write.rb +8 -5
  50. data/lib/dtas/buffer/splice.rb +29 -8
  51. data/lib/dtas/command.rb +2 -2
  52. data/lib/dtas/compat_onenine.rb +1 -1
  53. data/lib/dtas/cue_index.rb +3 -1
  54. data/lib/dtas/disclaimer.rb +1 -1
  55. data/lib/dtas/edit_client.rb +1 -1
  56. data/lib/dtas/fadefx.rb +100 -0
  57. data/lib/dtas/format.rb +4 -2
  58. data/lib/dtas/parse_time.rb +3 -1
  59. data/lib/dtas/partstats.rb +8 -10
  60. data/lib/dtas/pipe.rb +2 -1
  61. data/lib/dtas/player.rb +33 -11
  62. data/lib/dtas/player/client_handler.rb +43 -8
  63. data/lib/dtas/process.rb +6 -14
  64. data/lib/dtas/replaygain.rb +3 -3
  65. data/lib/dtas/rg_state.rb +1 -1
  66. data/lib/dtas/serialize.rb +3 -1
  67. data/lib/dtas/sigevent.rb +1 -1
  68. data/lib/dtas/sigevent/efd.rb +5 -4
  69. data/lib/dtas/sigevent/pipe.rb +4 -1
  70. data/lib/dtas/sink.rb +4 -4
  71. data/lib/dtas/source.rb +1 -1
  72. data/lib/dtas/source/av.rb +2 -2
  73. data/lib/dtas/source/av_ff_common.rb +22 -11
  74. data/lib/dtas/source/cmd.rb +3 -3
  75. data/lib/dtas/source/common.rb +3 -2
  76. data/lib/dtas/source/ff.rb +2 -2
  77. data/lib/dtas/source/file.rb +22 -4
  78. data/lib/dtas/source/mp3gain.rb +1 -1
  79. data/lib/dtas/source/sox.rb +7 -7
  80. data/lib/dtas/source/splitfx.rb +99 -0
  81. data/lib/dtas/spawn_fix.rb +10 -0
  82. data/lib/dtas/splitfx.rb +63 -24
  83. data/lib/dtas/state_file.rb +3 -1
  84. data/lib/dtas/{trimfx.rb → tfx.rb} +50 -24
  85. data/lib/dtas/tracklist.rb +2 -1
  86. data/lib/dtas/unix_accepted.rb +2 -2
  87. data/lib/dtas/unix_client.rb +2 -2
  88. data/lib/dtas/unix_server.rb +1 -1
  89. data/lib/dtas/util.rb +1 -1
  90. data/lib/dtas/watchable.rb +54 -0
  91. data/lib/dtas/writable_iter.rb +2 -1
  92. data/lib/dtas/xs.rb +2 -2
  93. data/perl/dtas-graph +1 -1
  94. data/test/covshow.rb +1 -1
  95. data/test/helper.rb +1 -1
  96. data/test/player_integration.rb +1 -1
  97. data/test/test_buffer.rb +1 -1
  98. data/test/test_env.rb +1 -1
  99. data/test/test_fadefx.rb +45 -0
  100. data/test/test_format.rb +1 -1
  101. data/test/test_format_change.rb +1 -1
  102. data/test/test_player.rb +1 -1
  103. data/test/test_player_client_handler.rb +1 -1
  104. data/test/test_player_integration.rb +8 -8
  105. data/test/test_process.rb +1 -1
  106. data/test/test_rg_integration.rb +1 -1
  107. data/test/test_rg_state.rb +1 -1
  108. data/test/test_sink.rb +1 -1
  109. data/test/test_sink_pipe_size.rb +2 -2
  110. data/test/test_sink_tee_integration.rb +1 -1
  111. data/test/test_source_av.rb +1 -1
  112. data/test/test_source_sox.rb +1 -1
  113. data/test/test_splitfx.rb +43 -13
  114. data/test/test_tfx.rb +85 -0
  115. data/test/test_tracklist.rb +1 -1
  116. data/test/test_unixserver.rb +1 -1
  117. data/test/test_util.rb +1 -1
  118. metadata +17 -6
  119. data/lib/dtas/compat_rbx.rb +0 -12
  120. data/test/test_trimfx.rb +0 -81
@@ -1,8 +1,9 @@
1
- # Copyright (C) 2013-2014, Eric Wong <e@80x24.org> and all contributors
1
+ # Copyright (C) 2013-2015 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
3
3
  require_relative '../dtas'
4
4
  require_relative 'serialize'
5
5
 
6
+ # the a tracklist object for -player
6
7
  # this is inspired by the MPRIS 2.0 TrackList spec
7
8
  class DTAS::Tracklist # :nodoc:
8
9
  include DTAS::Serialize
@@ -1,9 +1,9 @@
1
- # Copyright (C) 2013-2014, Eric Wong <e@80x24.org> and all contributors
1
+ # Copyright (C) 2013-2015 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
3
3
  require 'socket'
4
4
  require 'io/wait'
5
- require_relative 'compat_rbx'
6
5
 
6
+ # an accepted (client) socket in dtas-player server
7
7
  class DTAS::UNIXAccepted # :nodoc:
8
8
  attr_reader :to_io
9
9
 
@@ -1,12 +1,12 @@
1
- # Copyright (C) 2013-2014, Eric Wong <e@80x24.org> and all contributors
1
+ # Copyright (C) 2013-2015 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
3
3
  require_relative '../dtas'
4
4
  require_relative 'xs'
5
5
  require 'socket'
6
6
  require 'io/wait'
7
7
  require 'shellwords'
8
- require_relative 'compat_rbx'
9
8
 
9
+ # a socket connection used by dtas-player clients (e.g. dtas-ctl)
10
10
  class DTAS::UNIXClient # :nodoc:
11
11
  attr_reader :to_io
12
12
 
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2014, Eric Wong <e@80x24.org> and all contributors
1
+ # Copyright (C) 2013-2015 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
3
3
  require 'socket'
4
4
  require_relative '../dtas'
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2014, Eric Wong <e@80x24.org> and all contributors
1
+ # Copyright (C) 2013-2015 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
3
3
  require_relative '../dtas'
4
4
 
@@ -0,0 +1,54 @@
1
+ # Copyright (C) 2013-2015 all contributors <dtas-all@nongnu.org>
2
+ # License: GPLv3 or later <https://www.gnu.org/licenses/gpl-3.0.txt>
3
+ begin
4
+ require 'sleepy_penguin'
5
+ rescue LoadError
6
+ end
7
+
8
+ # used to restart DTAS::Source::SplitFX processing in dtas-player
9
+ # if the YAML file is edited
10
+ module DTAS::Watchable
11
+ class InotifyReadableIter < SleepyPenguin::Inotify
12
+ def self.new
13
+ super(:CLOEXEC)
14
+ end
15
+
16
+ FLAGS = CLOSE_WRITE | MOVED_TO
17
+
18
+ def readable_iter
19
+ or_call = false
20
+ while event = take(true) # drain the buffer
21
+ if (event.mask & FLAGS) != 0 && @watching[1] == event.name
22
+ or_call = true
23
+ end
24
+ end
25
+ if or_call
26
+ @on_readable.call
27
+ :delete
28
+ else
29
+ :wait_readable
30
+ end
31
+ end
32
+
33
+ # we must watch the directory, since
34
+ def watch_file(path, blk)
35
+ @on_readable = blk
36
+ @watching = File.split(File.expand_path(path))
37
+ add_watch(@watching[0], FLAGS)
38
+ end
39
+ end
40
+
41
+ def watch_begin(blk)
42
+ @ino = InotifyReadableIter.new
43
+ @ino.watch_file(@infile, blk)
44
+ @ino
45
+ end
46
+
47
+ # Closing the inotify descriptor (instead of using inotify_rm_watch)
48
+ # is cleaner because it avoids EINVAL on race conditions in case
49
+ # a directory is deleted: https://lkml.org/lkml/2007/7/9/3
50
+ def watch_end(srv)
51
+ srv.wait_ctl(@ino, :delete)
52
+ @ino = @ino.close
53
+ end
54
+ end if defined?(SleepyPenguin::Inotify)
@@ -1,7 +1,8 @@
1
- # Copyright (C) 2013-2014, Eric Wong <e@80x24.org> and all contributors
1
+ # Copyright (C) 2013-2015 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
3
3
  require_relative '../dtas'
4
4
 
5
+ # used to manage writable state for -player pipes
5
6
  module DTAS::WritableIter # :nodoc:
6
7
  attr_accessor :on_writable
7
8
  # we may use the ready_write flag to avoid an extra IO.select
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2014, Eric Wong <e@80x24.org> and all contributors
1
+ # Copyright (C) 2013-2015 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
3
3
  require_relative '../dtas'
4
4
  require 'shellwords'
@@ -9,6 +9,6 @@ require 'shellwords'
9
9
  # again, filesystems can use any byte value in names except '\0'.
10
10
  module DTAS::XS # :nodoc:
11
11
  def xs(ary)
12
- Shellwords.join(ary.map(&:b))
12
+ Shellwords.join(Array(ary).map(&:b))
13
13
  end
14
14
  end
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/perl -w
2
- # Copyright (C) 2013-2014, Eric Wong <e@80x24.org> and all contributors
2
+ # Copyright (C) 2013-2015 all contributors <dtas-all@nongnu.org>
3
3
  # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
4
4
  use strict;
5
5
  use Graph::Easy; # for ASCII-art graphs
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2014, Eric Wong <e@80x24.org> and all contributors
1
+ # Copyright (C) 2013-2015 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
3
3
  #
4
4
  # this works with the __covmerge method in test/helper.rb
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2014, Eric Wong <e@80x24.org> and all contributors
1
+ # Copyright (C) 2013-2015 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
3
3
  $stdout.sync = $stderr.sync = Thread.abort_on_exception = true
4
4
  require 'thread'
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2014, Eric Wong <e@80x24.org> and all contributors
1
+ # Copyright (C) 2013-2015 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
3
3
  require './test/helper'
4
4
  require 'dtas/player'
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2014, Eric Wong <e@80x24.org> and all contributors
1
+ # Copyright (C) 2013-2015 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
3
3
  require './test/helper'
4
4
  require 'stringio'
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2014, Eric Wong <e@80x24.org> and all contributors
1
+ # Copyright (C) 2013-2015 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
3
3
  require_relative 'helper'
4
4
  require 'dtas/process'
@@ -0,0 +1,45 @@
1
+ # Copyright (C) 2013-2015 all contributors <dtas-all@nongnu.org>
2
+ # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
3
+ require_relative 'helper'
4
+ require 'dtas/fadefx'
5
+ require 'dtas/format'
6
+
7
+ class TestFadeFX < Testcase
8
+ def test_fadefx
9
+ ffx = DTAS::FadeFX.new("t1,t3.1;l4,t1")
10
+ assert_equal 't', ffx.out_prev.type
11
+ assert_equal 1, ffx.out_prev.flen
12
+ assert_equal 't', ffx.in_cur.type
13
+ assert_equal 3.1, ffx.in_cur.flen
14
+ assert_equal 'l', ffx.out_cur.type
15
+ assert_equal 4, ffx.out_cur.flen
16
+ assert_equal 't', ffx.in_next.type
17
+ assert_equal 1, ffx.in_next.flen
18
+
19
+ fmt = DTAS::Format.new
20
+ fmt.rate = 48000
21
+ tbeg = 0
22
+ tlen = 48000 * 9
23
+
24
+ # XXX: this isn't testing much...
25
+ cur = ffx.fade_cur_fx(fmt, tbeg, tlen, %w(vol +3dB))
26
+ assert_equal(%w(trim 0s 432000s vol +3dB
27
+ fade t 3.1 0 0 fade l 0 432000s 4), cur)
28
+ out = ffx.fade_out_prev_fx(fmt, tbeg, tlen)
29
+ assert_equal(%w(trim 0s
30
+ fade t 0 48000s 48000s pad 384000s@48000s), out)
31
+ inn = ffx.fade_in_next_fx(fmt, tbeg, tlen)
32
+ assert_equal(%w(trim 384000s 48000s
33
+ fade t 48000s 0 0 pad 384000s@0s), inn)
34
+ end
35
+
36
+ def test_fadefx_no_cur
37
+ ffx = DTAS::FadeFX.new("t1,;,t1")
38
+ assert_equal 't', ffx.out_prev.type
39
+ assert_equal 1, ffx.out_prev.flen
40
+ assert_nil ffx.in_cur
41
+ assert_nil ffx.out_cur
42
+ assert_equal 't', ffx.in_next.type
43
+ assert_equal 1, ffx.in_next.flen
44
+ end
45
+ end
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2014, Eric Wong <e@80x24.org> and all contributors
1
+ # Copyright (C) 2013-2015 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
3
3
  require './test/helper'
4
4
  require 'tempfile'
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2014, Eric Wong <e@80x24.org> and all contributors
1
+ # Copyright (C) 2013-2015 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
3
3
  require './test/player_integration'
4
4
  require 'tmpdir'
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2014, Eric Wong <e@80x24.org> and all contributors
1
+ # Copyright (C) 2013-2015 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
3
3
  require './test/helper'
4
4
  require 'tempfile'
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2014, Eric Wong <e@80x24.org> and all contributors
1
+ # Copyright (C) 2013-2015 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
3
3
  require './test/helper'
4
4
  require 'dtas/player'
@@ -1,14 +1,14 @@
1
- # Copyright (C) 2013-2014, Eric Wong <e@80x24.org> and all contributors
1
+ # Copyright (C) 2013-2015 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
3
3
  require './test/player_integration'
4
4
  class TestPlayerIntegration < Testcase
5
5
  include PlayerIntegration
6
+ include DTAS::SpawnFix
6
7
 
7
8
  def test_cmd_rate
8
- pid = fork do
9
- @fmt.to_env.each { |k,v| ENV[k] = v }
10
- exec("sox -n $SOXFMT - synth 3 pinknoise | #@cmd")
11
- end
9
+ env = ENV.to_hash.merge(@fmt.to_env)
10
+ cmd = "sox -n $SOXFMT - synth 3 pinknoise | #@cmd"
11
+ pid = spawn(env, cmd)
12
12
  t = Time.now
13
13
  _, _ = Process.waitpid2(pid)
14
14
  elapsed = Time.now - t
@@ -209,11 +209,11 @@ class TestPlayerIntegration < Testcase
209
209
 
210
210
  def test_source_ed
211
211
  s = client_socket
212
- assert_equal "sox av ff", s.req("source ls")
212
+ assert_equal "sox av ff splitfx", s.req("source ls")
213
213
  s.req_ok("source ed av tryorder=-1")
214
- assert_equal "av sox ff", s.req("source ls")
214
+ assert_equal "av sox ff splitfx", s.req("source ls")
215
215
  s.req_ok("source ed av tryorder=")
216
- assert_equal "sox av ff", s.req("source ls")
216
+ assert_equal "sox av ff splitfx", s.req("source ls")
217
217
 
218
218
  s.req_ok("source ed sox command=true")
219
219
  sox = YAML.load(s.req("source cat sox"))
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2014, Eric Wong <e@80x24.org> and all contributors
1
+ # Copyright (C) 2013-2015 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
3
3
  require './test/helper'
4
4
  require 'dtas/process'
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2014, Eric Wong <e@80x24.org> and all contributors
1
+ # Copyright (C) 2013-2015 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
3
3
  require './test/player_integration'
4
4
  class TestRgIntegration < Testcase
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2014, Eric Wong <e@80x24.org> and all contributors
1
+ # Copyright (C) 2013-2015 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
3
3
  require './test/helper'
4
4
  require 'dtas/rg_state'
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2014, Eric Wong <e@80x24.org> and all contributors
1
+ # Copyright (C) 2013-2015 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
3
3
  require './test/helper'
4
4
  require 'dtas/sink'
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2014, Eric Wong <e@80x24.org> and all contributors
1
+ # Copyright (C) 2013-2015 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
3
3
  begin
4
4
  require 'io/splice'
@@ -11,7 +11,7 @@ begin
11
11
  default_sink_pid(s)
12
12
  s.req_ok("sink ed default pipe_size=0x1000")
13
13
  s.req_ok("sink ed default pipe_size=0x10000")
14
- assert_match %r{\AERR }, s.req("sink ed default pipe_size=")
14
+ s.req_ok("sink ed default pipe_size=")
15
15
  s.req_ok("sink ed default pipe_size=4096")
16
16
  end if IO.method_defined?(:pipe_size=)
17
17
  end
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2014, Eric Wong <e@80x24.org> and all contributors
1
+ # Copyright (C) 2013-2015 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
3
3
  require './test/player_integration'
4
4
  class TestSinkTeeIntegration < Testcase
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2014, Eric Wong <e@80x24.org> and all contributors
1
+ # Copyright (C) 2013-2015 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
3
3
  require './test/helper'
4
4
  require 'dtas/source/av'
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2014, Eric Wong <e@80x24.org> and all contributors
1
+ # Copyright (C) 2013-2015 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
3
3
  require './test/helper'
4
4
  require 'dtas/source/sox'
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2013-2014, Eric Wong <e@80x24.org> and all contributors
1
+ # Copyright (C) 2013-2015 all contributors <dtas-all@nongnu.org>
2
2
  # License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt)
3
3
  require 'yaml'
4
4
  require 'dtas/splitfx'
@@ -6,6 +6,19 @@ require 'thread'
6
6
  require_relative 'helper'
7
7
 
8
8
  class TestSplitfx < Testcase
9
+ include DTAS::SpawnFix
10
+
11
+ def tmp_err(path)
12
+ err = $stderr.dup
13
+ $stderr.reopen(path, 'a')
14
+ begin
15
+ yield
16
+ ensure
17
+ $stderr.reopen(err)
18
+ err.close
19
+ end
20
+ end
21
+
9
22
  def test_t2s
10
23
  sfx = DTAS::SplitFX.new
11
24
  sfx.instance_eval do
@@ -15,6 +28,17 @@ class TestSplitfx < Testcase
15
28
  assert_equal 118554030, sfx.t2s('44:48.3')
16
29
  end
17
30
 
31
+ def assert_contains_stats(file)
32
+ buf = File.read(file)
33
+ [ 'DC offset', 'Min level', 'Max level', 'Pk lev dB',
34
+ 'RMS lev dB', 'RMS Pk dB', 'RMS Tr dB', 'Crest factor', 'Flat factor',
35
+ 'Pk count', 'Bit-depth', 'Num samples',
36
+ 'Length s', 'Scale max', 'Window s'
37
+ ].each do |re|
38
+ assert_match(/^#{re}/, buf, buf)
39
+ end
40
+ end
41
+
18
42
  def test_example
19
43
  hash = YAML.load(File.read("examples/splitfx.sample.yml"))
20
44
  sfx = DTAS::SplitFX.new
@@ -25,19 +49,25 @@ class TestSplitfx < Testcase
25
49
  opts = { jobs: nil, silent: true }
26
50
 
27
51
  # ensure default FLAC target works
28
- WAIT_ALL_MTX.synchronize { sfx.run("flac", opts) }
52
+ WAIT_ALL_MTX.synchronize do
53
+ tmp_err('err.txt') { sfx.run("flac", opts) }
54
+ end
29
55
  expect = %w(1.flac 2.flac foo.flac)
30
56
  assert_equal expect, Dir["*.flac"].sort
31
57
 
32
58
  # compare results with expected output
33
- res_cmd = "sox 1.flac 2.flac -ts32 -c2 -r44100 result.s32"
34
- res_pid = fork { exec res_cmd }
35
- exp_cmd = "sox foo.flac -ts32 -c2 -r44100 expect.s32 trim 4"
36
- exp_pid = fork { exec exp_cmd }
59
+ res_cmd = "sox 1.flac 2.flac -ts32 -c2 -r44100 result.s32 stats"
60
+ res_pid = spawn(res_cmd, err: 'b.txt')
61
+ exp_cmd = "sox foo.flac -ts32 -c2 -r44100 expect.s32 trim 4 stats"
62
+ exp_pid = spawn(exp_cmd, err: 'a.txt')
37
63
  _, s = Process.waitpid2(res_pid)
38
64
  assert s.success?, "#{res_cmd}: #{s.inspect}"
39
65
  _, s = Process.waitpid2(exp_pid)
40
66
  assert s.success?, "#{exp_cmd}: #{s.inspect}"
67
+ assert_equal File.read('a.txt'), File.read('b.txt')
68
+
69
+ assert_contains_stats('err.txt')
70
+
41
71
  cmp = "cmp result.s32 expect.s32"
42
72
  assert system(cmp), cmp
43
73
 
@@ -46,13 +76,10 @@ class TestSplitfx < Testcase
46
76
  # hasn't made it into Debian, yet)
47
77
  if `which opusenc 2>/dev/null`.size > 0 &&
48
78
  `which opusdec 2>/dev/null`.size > 0
49
- err = $stderr.dup
50
- begin
51
- $stderr.reopen("/dev/null", "a")
52
- WAIT_ALL_MTX.synchronize { sfx.run("opusenc", opts) }
53
- ensure
54
- $stderr.reopen(err)
79
+ WAIT_ALL_MTX.synchronize do
80
+ tmp_err('opus.err.txt') { sfx.run("opusenc", opts) }
55
81
  end
82
+ assert_contains_stats('opus.err.txt')
56
83
 
57
84
  # ensure opus lengths match flac ones, we decode using opusdec
58
85
  # since sox does not yet have opus support in Debian 7.0
@@ -64,7 +91,10 @@ class TestSplitfx < Testcase
64
91
 
65
92
  # ensure 16/44.1kHz FLAC works (CDDA-like)
66
93
  File.unlink('1.flac', '2.flac')
67
- WAIT_ALL_MTX.synchronize { sfx.run("flac-cdda", opts) }
94
+ WAIT_ALL_MTX.synchronize do
95
+ tmp_err('flac-cdda.err.txt') { sfx.run("flac-cdda", opts) }
96
+ end
97
+ assert_contains_stats('flac-cdda.err.txt')
68
98
  %w(1 2).each do |nr|
69
99
  assert_equal `soxi -D #{nr}.flac`, `soxi -D #{nr}.wav`
70
100
  end