blob: 73b44037b5796677cc0130fc8daa29940f4fbc20 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# Copyright (C) 2013-2016 all contributors <dtas-all@nongnu.org>
# License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
# frozen_string_literal: true
require './test/player_integration'
require 'tmpdir'
class TestFormatChange < Testcase
include PlayerIntegration
def test_format_change
s = client_socket
default_pid = default_sink_pid(s)
Dir.mktmpdir do |dir|
d = "#{dir}/dump.$CHANNELS.$RATE"
f44100 = File.open("#{dir}/dump.2.44100", IO::RDWR|IO::CREAT)
f88200 = File.open("#{dir}/dump.2.88200", IO::RDWR|IO::CREAT)
s.req_ok("sink ed dump active=true command='cat > #{d}'")
noise, len = tmp_noise
s.req_ok(%W(enq #{noise.path}))
wait_files_not_empty(default_pid, f44100)
s.req_ok("format rate=88200")
wait_files_not_empty(f88200)
dethrottle_decoder(s)
Timeout.timeout(len) do
begin
cur = YAML.load(s.req("current"))
end while cur["sinks"] && sleep(0.01)
end
c = "sox -R -ts32 -c2 -r88200 #{dir}/dump.2.88200 " \
"-ts32 -c2 -r44100 #{dir}/part2"
assert(system(c), c)
c = "sox -R -ts32 -c2 -r44100 #{dir}/dump.2.44100 " \
"-ts32 -c2 -r44100 #{dir}/part2 #{dir}/res.sox"
assert(system(c), c)
assert_equal `soxi -s #{dir}/res.sox`, `soxi -s #{noise.path}`
File.unlink(*Dir["#{dir}/*"].to_a)
end
end
end
|