From 76bc3c93229446144d3cbf7927eb703e5d37f449 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Fri, 27 Feb 2015 22:21:54 +0100 Subject: [PATCH] [DEV] add The interface of the hardware link --- data/hardwareLinux.json | 4 ++++ river/io/Node.cpp | 13 +++++++++++++ river/io/Node.h | 3 ++- river/io/NodeAirTAudio.cpp | 21 +++++++++++++++++++-- test/main.cpp | 7 +++++-- 5 files changed, 43 insertions(+), 5 deletions(-) diff --git a/data/hardwareLinux.json b/data/hardwareLinux.json index c8c6e40..d2293bf 100644 --- a/data/hardwareLinux.json +++ b/data/hardwareLinux.json @@ -10,7 +10,10 @@ # name of the interface # name:"default", name:"hw:0,0", + timestamp-mode:"hardware", }, + # lik hardware ti the specified IO name : + hw-link:"speaker", # frequency to open device frequency:48000, # mapping of the harware device (mapping is not get under) @@ -29,6 +32,7 @@ interface:"alsa", #name:"default", name:"hw:0,0", + timestamp-mode:"hardware", }, frequency:48000, channel-map:[ diff --git a/river/io/Node.cpp b/river/io/Node.cpp index 157629f..b79a5bf 100644 --- a/river/io/Node.cpp +++ b/river/io/Node.cpp @@ -93,6 +93,19 @@ river::io::Node::Node(const std::string& _name, const std11::shared_ptrgetStringValue("hw-link", ""); + if (linkWith != "") { + std11::shared_ptr mng = river::io::Manager::getInstance(); + if (mng == nullptr) { + return; + } + m_link = mng->getNode(linkWith); + if (m_link == nullptr) { + RIVER_ERROR("can not link 2 interfaces ..."); + } else { + RIVER_INFO("******** REQUEST LINK interface ************"); + } + } } river::io::Node::~Node() { diff --git a/river/io/Node.h b/river/io/Node.h index 7c3d899..e8fa11b 100644 --- a/river/io/Node.h +++ b/river/io/Node.h @@ -63,7 +63,8 @@ namespace river { protected: std11::shared_ptr m_volume; //!< if a volume is set it is set here ... - + + std11::shared_ptr m_link; protected: std::vector > m_listAvaillable; //!< List of all interface that exist on this Node std::vector > m_list; diff --git a/river/io/NodeAirTAudio.cpp b/river/io/NodeAirTAudio.cpp index 4d35dda..30a9f54 100644 --- a/river/io/NodeAirTAudio.cpp +++ b/river/io/NodeAirTAudio.cpp @@ -217,6 +217,9 @@ river::io::NodeAirTAudio::NodeAirTAudio(const std::string& _name, const std11::s m_info.outputChannels = 2; params.nChannels = 2; } + airtaudio::StreamOptions option; + etk::from_string(option.mode, m_config->getStringValue("timestamp-mode", "soft")); + m_rtaudioFrameSize = nbChunk; RIVER_INFO("Open output stream nbChannels=" << params.nChannels); @@ -229,7 +232,8 @@ river::io::NodeAirTAudio::NodeAirTAudio(const std::string& _name, const std11::s std11::placeholders::_1, std11::placeholders::_2, std11::placeholders::_5, - std11::placeholders::_6) + std11::placeholders::_6), + option ); } else { err = m_adac.openStream(¶ms, nullptr, @@ -239,13 +243,26 @@ river::io::NodeAirTAudio::NodeAirTAudio(const std::string& _name, const std11::s std11::placeholders::_3, std11::placeholders::_4, std11::placeholders::_5, - std11::placeholders::_6) + std11::placeholders::_6), + option ); } if (err != airtaudio::error_none) { RIVER_ERROR("Create stream : '" << m_name << "' mode=" << (m_isInput?"input":"output") << " can not create stream " << err); } m_process.updateInterAlgo(); + // manage Link Between Nodes : + if (m_link != nullptr) { + RIVER_INFO("******** START LINK ************"); + std11::shared_ptr link = std11::dynamic_pointer_cast(m_link); + if (link == nullptr) { + RIVER_ERROR("Can not link 2 Interface with not the same type (reserved for HW interface)"); + return; + } + link->m_adac.isMasterOf(m_adac); + // TODO : Add return ... + RIVER_INFO("******** LINK might be done ************"); + } } river::io::NodeAirTAudio::~NodeAirTAudio() { diff --git a/test/main.cpp b/test/main.cpp index bed0ca3..2bd6280 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -609,6 +609,7 @@ static void threadVolume() { std11::shared_ptr manager; manager = river::Manager::create("testApplication"); std11::shared_ptr process = std11::make_shared(manager); + usleep(100000); process->run(); process.reset(); usleep(500000); @@ -617,12 +618,14 @@ static void threadVolume() { TEST(TestALL, testInputCallBackMicClean) { std11::shared_ptr manager; manager = river::Manager::create("testApplication"); - std11::thread tmpThread(std11::bind(&threadVolume)); - usleep(100000); + std11::thread tmpThread(std11::bind(&threadVolume)); + usleep(30000); APPL_INFO("test input (callback mode)"); std11::shared_ptr process = std11::make_shared(manager, "microphone-clean"); process->run(); + + usleep(100000); process.reset(); usleep(500000); tmpThread.join();