dtas 0.16.1 → 0.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/Documentation/.gitignore +1 -1
- data/Documentation/GNUmakefile +2 -2
- data/Documentation/dtas-archive.pod +2 -2
- data/Documentation/dtas-console.pod +2 -2
- data/Documentation/dtas-ctl.pod +2 -2
- data/Documentation/dtas-cueedit.pod +2 -2
- data/Documentation/dtas-enq.pod +2 -2
- data/Documentation/dtas-env.pod +3 -3
- data/Documentation/dtas-msinkctl.pod +2 -2
- data/Documentation/dtas-player.pod +2 -2
- data/Documentation/dtas-player_effects.pod +2 -2
- data/Documentation/dtas-player_protocol.pod +4 -4
- data/Documentation/dtas-player_sink_examples.pod +2 -2
- data/Documentation/dtas-sinkedit.pod +4 -4
- data/Documentation/dtas-sourceedit.pod +4 -4
- data/Documentation/dtas-splitfx.pod +7 -1
- data/Documentation/dtas-tl.pod +4 -4
- data/Documentation/dtas-xdelay.pod +2 -2
- data/Documentation/update-footer.rb +2 -2
- data/GIT-VERSION-FILE +1 -1
- data/GIT-VERSION-GEN +2 -2
- data/GNUmakefile +13 -1
- data/HACKING +2 -2
- data/INSTALL +10 -24
- data/NEWS +103 -0
- data/README +14 -8
- data/Rakefile +1 -1
- data/TODO +3 -1
- data/bin/dtas-archive +1 -1
- data/bin/dtas-console +17 -21
- data/bin/dtas-ctl +1 -1
- data/bin/dtas-cueedit +1 -1
- data/bin/dtas-enq +1 -1
- data/bin/dtas-mlib +1 -1
- data/bin/dtas-msinkctl +1 -1
- data/bin/dtas-partstats +1 -1
- data/bin/dtas-player +1 -1
- data/bin/dtas-readahead +3 -3
- data/bin/dtas-sinkedit +1 -1
- data/bin/dtas-sourceedit +1 -1
- data/bin/dtas-splitfx +8 -1
- data/bin/dtas-tl +1 -1
- data/bin/dtas-xdelay +1 -1
- data/dtas-linux.gemspec +2 -2
- data/dtas-mpris.gemspec +2 -2
- data/dtas.gemspec +3 -3
- data/dtas.sh +7 -0
- data/examples/zsh-completion/README +3 -0
- data/examples/zsh-completion/_dtas-archive +16 -0
- data/examples/zsh-completion/_dtas-ctl +114 -0
- data/examples/zsh-completion/_dtas-cueedit +7 -0
- data/examples/zsh-completion/_dtas-enq +7 -0
- data/examples/zsh-completion/_dtas-mlib +29 -0
- data/examples/zsh-completion/_dtas-msinkctl +8 -0
- data/examples/zsh-completion/_dtas-partstats +7 -0
- data/examples/zsh-completion/_dtas-sinkedit +11 -0
- data/examples/zsh-completion/_dtas-sourceedit +11 -0
- data/examples/zsh-completion/_dtas-splitfx +17 -0
- data/examples/zsh-completion/_dtas-tl +52 -0
- data/examples/zsh-completion/_dtas-xdelay +17 -0
- data/lib/dtas/buffer/fiddle_splice.rb +216 -0
- data/lib/dtas/buffer/read_write.rb +3 -3
- data/lib/dtas/buffer/splice.rb +9 -5
- data/lib/dtas/buffer.rb +10 -7
- data/lib/dtas/command.rb +1 -1
- data/lib/dtas/compat_onenine.rb +1 -1
- data/lib/dtas/cue_index.rb +1 -1
- data/lib/dtas/disclaimer.rb +1 -1
- data/lib/dtas/edit_client.rb +1 -1
- data/lib/dtas/encoding.rb +8 -9
- data/lib/dtas/fadefx.rb +1 -1
- data/lib/dtas/format.rb +1 -1
- data/lib/dtas/mcache.rb +1 -1
- data/lib/dtas/mlib/migrations/0001_initial.rb +1 -1
- data/lib/dtas/mlib.rb +19 -7
- data/lib/dtas/nonblock.rb +1 -1
- data/lib/dtas/parse_freq.rb +1 -1
- data/lib/dtas/parse_time.rb +1 -1
- data/lib/dtas/partstats.rb +2 -3
- data/lib/dtas/pipe.rb +13 -9
- data/lib/dtas/pipeline.rb +1 -1
- data/lib/dtas/player/client_handler.rb +23 -15
- data/lib/dtas/player.rb +3 -3
- data/lib/dtas/process.rb +1 -1
- data/lib/dtas/replaygain.rb +1 -1
- data/lib/dtas/rg_state.rb +1 -1
- data/lib/dtas/serialize.rb +1 -1
- data/lib/dtas/sigevent/efd.rb +3 -1
- data/lib/dtas/sigevent/fiddle_efd.rb +38 -0
- data/lib/dtas/sigevent/pipe.rb +2 -2
- data/lib/dtas/sigevent.rb +6 -3
- data/lib/dtas/sink.rb +1 -1
- data/lib/dtas/source/av.rb +1 -1
- data/lib/dtas/source/av_ff_common.rb +2 -2
- data/lib/dtas/source/cmd.rb +1 -1
- data/lib/dtas/source/common.rb +1 -1
- data/lib/dtas/source/ff.rb +1 -1
- data/lib/dtas/source/file.rb +1 -1
- data/lib/dtas/source/mp3gain.rb +1 -1
- data/lib/dtas/source/sox.rb +2 -2
- data/lib/dtas/source/splitfx.rb +1 -1
- data/lib/dtas/source.rb +1 -1
- data/lib/dtas/spawn_fix.rb +1 -1
- data/lib/dtas/splitfx.rb +9 -8
- data/lib/dtas/state_file.rb +1 -1
- data/lib/dtas/tfx.rb +1 -1
- data/lib/dtas/track.rb +1 -1
- data/lib/dtas/tracklist.rb +1 -1
- data/lib/dtas/unix_accepted.rb +1 -1
- data/lib/dtas/unix_client.rb +1 -1
- data/lib/dtas/unix_server.rb +1 -1
- data/lib/dtas/util.rb +1 -1
- data/lib/dtas/version.rb +1 -1
- data/lib/dtas/watchable/fiddle_ino.rb +78 -0
- data/lib/dtas/watchable/inotify.rb +13 -0
- data/lib/dtas/watchable.rb +59 -58
- data/lib/dtas/writable_iter.rb +1 -1
- data/lib/dtas/xs.rb +1 -1
- data/lib/dtas.rb +10 -2
- data/man/dtas-archive.1 +15 -15
- data/man/dtas-console.1 +19 -19
- data/man/dtas-ctl.1 +16 -16
- data/man/dtas-cueedit.1 +12 -12
- data/man/dtas-enq.1 +12 -12
- data/man/dtas-env.7 +15 -15
- data/man/dtas-msinkctl.1 +12 -12
- data/man/dtas-player.1 +24 -24
- data/man/dtas-player_effects.7 +9 -9
- data/man/dtas-player_protocol.7 +48 -48
- data/man/dtas-player_sink_examples.7 +15 -15
- data/man/dtas-sinkedit.1 +16 -16
- data/man/dtas-sourceedit.1 +17 -17
- data/man/dtas-splitfx.1 +43 -38
- data/man/dtas-tl.1 +16 -16
- data/man/dtas-xdelay.1 +16 -16
- data/perl/dtas-graph +7 -2
- data/setup.rb +1 -2
- data/test/covshow.rb +1 -1
- data/test/helper.rb +1 -1
- data/test/player_integration.rb +1 -1
- data/test/test_buffer.rb +6 -6
- data/test/test_encoding.rb +1 -1
- data/test/test_env.rb +1 -1
- data/test/test_fadefx.rb +1 -1
- data/test/test_format.rb +1 -1
- data/test/test_format_change.rb +1 -1
- data/test/test_mcache.rb +1 -1
- data/test/test_mlib.rb +1 -1
- data/test/test_parse_freq.rb +1 -1
- data/test/test_pipeline.rb +1 -1
- data/test/test_player.rb +1 -1
- data/test/test_player_client_handler.rb +1 -1
- data/test/test_player_integration.rb +1 -1
- data/test/test_process.rb +1 -1
- data/test/test_rg_integration.rb +1 -1
- data/test/test_rg_state.rb +1 -1
- data/test/test_sigevent.rb +20 -0
- data/test/test_sink.rb +1 -1
- data/test/test_sink_pipe_size.rb +13 -16
- data/test/test_sink_tee_integration.rb +1 -1
- data/test/test_source_av.rb +1 -1
- data/test/test_source_sox.rb +1 -1
- data/test/test_splitfx.rb +1 -1
- data/test/test_tfx.rb +1 -1
- data/test/test_tracklist.rb +1 -1
- data/test/test_unixserver.rb +1 -1
- data/test/test_util.rb +1 -1
- metadata +23 -4
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2013-
|
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
|
10
|
-
#
|
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
|
data/lib/dtas/buffer/splice.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
-
# Copyright (C) 2013-
|
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,
|
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,
|
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,
|
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-
|
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
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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
data/lib/dtas/compat_onenine.rb
CHANGED
data/lib/dtas/cue_index.rb
CHANGED
data/lib/dtas/disclaimer.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# :enddoc:
|
2
|
-
# Copyright (C) 2013-
|
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)
|
data/lib/dtas/edit_client.rb
CHANGED
data/lib/dtas/encoding.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2018-
|
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
data/lib/dtas/format.rb
CHANGED
data/lib/dtas/mcache.rb
CHANGED
data/lib/dtas/mlib.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# Copyright (C) 2015-
|
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
|
-
|
133
|
-
|
134
|
-
|
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
data/lib/dtas/parse_freq.rb
CHANGED
data/lib/dtas/parse_time.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
# Copyright (C) 2013-
|
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'
|
data/lib/dtas/partstats.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
# -*- encoding: binary -*-
|
2
|
-
# Copyright (C) 2013-
|
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"] =
|
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-
|
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?(
|
25
|
-
|
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(
|
30
|
-
end if defined?(
|
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) 2013-
|
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
|
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
|
-
|
208
|
-
|
209
|
-
|
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
|
400
|
-
offset = __seek_offset_adj(
|
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-
|
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
|
-
|
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
|
-
|
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
|