From 57c4795a1e4937b78a592f829661842dd52f514d Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Thu, 12 Mar 2015 23:17:14 +0100 Subject: [PATCH] [DEBUG] compilation OK --- river/io/Manager.cpp | 23 +++++++++++++++-------- river/io/Manager.h | 3 ++- river/river.cpp | 18 ++++++++++++++++-- river/river.h | 7 ++++++- test/main.cpp | 1 + test/testEchoDelay.h | 4 ++++ test/testFormat.h | 9 +++++++++ test/testMuxer.h | 4 ++++ test/testPlaybackCallback.h | 8 ++++++++ test/testPlaybackWrite.h | 4 ++++ test/testRecordCallback.h | 4 ++++ test/testVolume.h | 3 +++ 12 files changed, 76 insertions(+), 12 deletions(-) diff --git a/river/io/Manager.cpp b/river/io/Manager.cpp index 1cf66a6..30fd63e 100644 --- a/river/io/Manager.cpp +++ b/river/io/Manager.cpp @@ -4,13 +4,14 @@ * @license APACHE v2.0 (see license file) */ -#include "Manager.h" +#include #include -#include "Node.h" -#include "NodeAEC.h" -#include "NodeMuxer.h" -#include "NodeAirTAudio.h" -#include "NodePortAudio.h" +#include +#include +#include +#include +#include +#include #include #include #include @@ -65,7 +66,7 @@ river::io::Manager::Manager() { #endif } -void river::io::Manager::init(const std::string _filename) { +void river::io::Manager::init(const std::string& _filename) { std11::unique_lock lock(m_mutex); if (_filename == "") { RIVER_INFO("Load default config"); @@ -74,9 +75,15 @@ void river::io::Manager::init(const std::string _filename) { RIVER_ERROR("you must set a basic configuration file for harware configuration: '" << _filename << "'"); } } + +void river::io::Manager::initString(const std::string& _data) { + std11::unique_lock lock(m_mutex); + m_config.parse(_data); +} + void river::io::Manager::unInit() { std11::unique_lock lock(m_mutex); - + // TODO : ... } river::io::Manager::~Manager() { diff --git a/river/io/Manager.h b/river/io/Manager.h index e6d849b..8deea8e 100644 --- a/river/io/Manager.h +++ b/river/io/Manager.h @@ -39,7 +39,8 @@ namespace river { * @brief Destructor */ ~Manager(); - void init(); + void init(const std::string& _filename); + void initString(const std::string& _data); void unInit(); private: ejson::Document m_config; // harware configuration diff --git a/river/river.cpp b/river/river.cpp index d632686..09baf65 100644 --- a/river/river.cpp +++ b/river/river.cpp @@ -4,8 +4,8 @@ * @license APACHE v2.0 (see license file) */ -#iclude -#iclude +#include +#include #include static bool river_isInit = false; @@ -20,6 +20,20 @@ void river::init(const std::string& _filename) { RIVER_INFO("init RIVER :" << river_configFile); std11::shared_ptr mng = river::io::Manager::getInstance(); mng->init(river_configFile); + } else { + RIVER_ERROR("River is already init not use : " << _filename); + } +} + +void river::initString(const std::string& _config) { + if (river_isInit == false) { + river_isInit = true; + river_configFile = _config; + RIVER_INFO("init RIVER with config ..."); + std11::shared_ptr mng = river::io::Manager::getInstance(); + mng->initString(river_configFile); + } else { + RIVER_ERROR("River is already init not use Data ..."); } } diff --git a/river/river.h b/river/river.h index cc4913e..11f32a0 100644 --- a/river/river.h +++ b/river/river.h @@ -7,7 +7,7 @@ #ifndef __RIVER_H__ #define __RIVER_H__ -#include +#include namespace river { /** @@ -15,6 +15,11 @@ namespace river { * @param[in] _filename Name of the configuration file (if "" ==> default config file) */ void init(const std::string& _filename); + /** + * @brief Initialize the River Library with a json data string + * @param[in] _config json sting data + */ + void initString(const std::string& _config); /** * @brief Un-initialize the River Library * @note this close all stream of all interfaces. diff --git a/test/main.cpp b/test/main.cpp index c32eaf3..f69df65 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -5,6 +5,7 @@ */ #include "debug.h" +#include #include #include #include diff --git a/test/testEchoDelay.h b/test/testEchoDelay.h index 36e65dc..dd9838f 100644 --- a/test/testEchoDelay.h +++ b/test/testEchoDelay.h @@ -363,13 +363,17 @@ namespace river_test_echo_delay { } }; + static const std::string configurationRiver = ""; + TEST(TestTime, testDelay) { + river::initString(configurationRiver); std11::shared_ptr manager; manager = river::Manager::create("testApplication"); std11::shared_ptr process = std11::make_shared(manager); process->run(); process.reset(); usleep(500000); + river::unInit(); } }; diff --git a/test/testFormat.h b/test/testFormat.h index ef953dc..81e8dd2 100644 --- a/test/testFormat.h +++ b/test/testFormat.h @@ -128,15 +128,18 @@ namespace river_test_format { } }; + static const std::string configurationRiver = ""; class testResampling : public ::testing::TestWithParam {}; TEST_P(testResampling, base) { + river::initString(configurationRiver); std11::shared_ptr manager; manager = river::Manager::create("testApplication"); std11::shared_ptr process = std11::make_shared(manager, GetParam(), 2, audio::format_int16); process->run(); process.reset(); usleep(500000); + river::unInit(); } INSTANTIATE_TEST_CASE_P(InstantiationName, @@ -146,12 +149,14 @@ namespace river_test_format { class testFormat : public ::testing::TestWithParam {}; TEST_P(testFormat, base) { + river::initString(configurationRiver); std11::shared_ptr manager; manager = river::Manager::create("testApplication"); std11::shared_ptr process = std11::make_shared(manager, 48000, 2, GetParam()); process->run(); process.reset(); usleep(500000); + river::unInit(); } INSTANTIATE_TEST_CASE_P(InstantiationName, testFormat, @@ -160,12 +165,14 @@ namespace river_test_format { class testChannels : public ::testing::TestWithParam {}; TEST_P(testChannels, base) { + river::initString(configurationRiver); std11::shared_ptr manager; manager = river::Manager::create("testApplication"); std11::shared_ptr process = std11::make_shared(manager, 48000, GetParam(), audio::format_int16); process->run(); process.reset(); usleep(500000); + river::unInit(); } INSTANTIATE_TEST_CASE_P(InstantiationName, testChannels, @@ -173,6 +180,7 @@ namespace river_test_format { TEST(TestALL, testChannelsFormatResampling) { + river::initString(configurationRiver); std11::shared_ptr manager; manager = river::Manager::create("testApplication"); APPL_INFO("test convert flaot to output (callback mode)"); @@ -209,6 +217,7 @@ namespace river_test_format { } } } + river::unInit(); } diff --git a/test/testMuxer.h b/test/testMuxer.h index 3ce3fc8..7b56333 100644 --- a/test/testMuxer.h +++ b/test/testMuxer.h @@ -100,13 +100,17 @@ namespace river_test_muxer { } }; + static const std::string configurationRiver = ""; + TEST(TestMuxer, testMuxing) { + river::initString(configurationRiver); std11::shared_ptr manager; manager = river::Manager::create("testApplication"); std11::shared_ptr process = std11::make_shared(manager); process->run(); process.reset(); usleep(500000); + river::unInit(); } }; diff --git a/test/testPlaybackCallback.h b/test/testPlaybackCallback.h index 6d0390f..3d2d8e5 100644 --- a/test/testPlaybackCallback.h +++ b/test/testPlaybackCallback.h @@ -69,7 +69,10 @@ namespace river_test_playback_callback { } }; + static const std::string configurationRiver = ""; + TEST(TestALL, testOutputCallBack) { + river::initString(configurationRiver); std11::shared_ptr manager; manager = river::Manager::create("testApplication"); @@ -78,9 +81,11 @@ namespace river_test_playback_callback { process->run(); process.reset(); usleep(500000); + river::unInit(); } TEST(TestALL, testOutputCallBackPulse) { + river::initString(configurationRiver); std11::shared_ptr manager; manager = river::Manager::create("testApplication"); @@ -89,9 +94,11 @@ namespace river_test_playback_callback { process->run(); process.reset(); usleep(500000); + river::unInit(); } TEST(TestALL, testOutputCallBackJack) { + river::initString(configurationRiver); std11::shared_ptr manager; manager = river::Manager::create("testApplication"); @@ -100,6 +107,7 @@ namespace river_test_playback_callback { process->run(); process.reset(); usleep(500000); + river::unInit(); } diff --git a/test/testPlaybackWrite.h b/test/testPlaybackWrite.h index b1c09fd..cac412b 100644 --- a/test/testPlaybackWrite.h +++ b/test/testPlaybackWrite.h @@ -11,6 +11,8 @@ #define __class__ "test_playback_write" namespace river_test_playback_write { + static const std::string configurationRiver = ""; + class testOutWrite { private: std::vector m_channelMap; @@ -67,6 +69,7 @@ namespace river_test_playback_write { }; TEST(TestALL, testOutputWrite) { + river::initString(configurationRiver); std11::shared_ptr manager; manager = river::Manager::create("testApplication"); @@ -75,6 +78,7 @@ namespace river_test_playback_write { process->run(); process.reset(); usleep(500000); + river::unInit(); } class testOutWriteCallback { diff --git a/test/testRecordCallback.h b/test/testRecordCallback.h index a608106..494feb5 100644 --- a/test/testRecordCallback.h +++ b/test/testRecordCallback.h @@ -13,6 +13,8 @@ #define __class__ "test_record_callback" namespace river_test_record_callback { + static const std::string configurationRiver = ""; + class testInCallback { private: std11::shared_ptr m_manager; @@ -64,6 +66,7 @@ namespace river_test_record_callback { }; TEST(TestALL, testInputCallBack) { + river::initString(configurationRiver); std11::shared_ptr manager; manager = river::Manager::create("testApplication"); APPL_INFO("test input (callback mode)"); @@ -71,6 +74,7 @@ namespace river_test_record_callback { process->run(); process.reset(); usleep(500000); + river::unInit(); } }; diff --git a/test/testVolume.h b/test/testVolume.h index a4102a2..2ae3805 100644 --- a/test/testVolume.h +++ b/test/testVolume.h @@ -11,6 +11,7 @@ #define __class__ "test_volume" namespace river_test_volume { + static const std::string configurationRiver = ""; class testCallbackVolume { private: @@ -101,12 +102,14 @@ namespace river_test_volume { }; TEST(TestALL, testVolume) { + river::initString(configurationRiver); std11::shared_ptr manager; manager = river::Manager::create("testApplication"); std11::shared_ptr process = std11::make_shared(manager); process->run(); process.reset(); usleep(500000); + river::unInit(); } };