From 4bb0b33402635da9702c255f11dbf3b18e4d28f0 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 24 Aug 2013 22:56:00 +0000 Subject: player: preserve format across invocations We maintain most everything else, so we should maintain this, too. --- lib/dtas/player.rb | 4 ++++ test/test_player.rb | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/lib/dtas/player.rb b/lib/dtas/player.rb index e055fa5..b39989b 100644 --- a/lib/dtas/player.rb +++ b/lib/dtas/player.rb @@ -111,6 +111,10 @@ class DTAS::Player e = v["env"] and @srcenv = e end + if v = hash["format"] + @format = DTAS::Format.load(v) + end + if sinks = hash["sinks"] sinks.each do |sink_hsh| sink = DTAS::Sink.load(sink_hsh) diff --git a/test/test_player.rb b/test/test_player.rb index 18a8a9e..78feff9 100644 --- a/test/test_player.rb +++ b/test/test_player.rb @@ -34,4 +34,14 @@ class TestPlayer < Minitest::Unit::TestCase hash = @player.to_hsh assert_equal({"socket" => @path}, hash) end + + def test_player_serialize_format + fmt = DTAS::Format.new + fmt.type = "f32" + fmt.rate = 48000 + player = DTAS::Player.load("format" => fmt.to_hsh) + fhash = player.to_hsh["format"] + assert_equal "f32", fhash["type"] + assert_equal 48000, fhash["rate"] + end end -- cgit v1.2.3-24-ge0c7