From 0d448bed76d097d4db0ece7e4ba5538297e93242 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Fri, 13 Mar 2015 23:22:17 +0100 Subject: [PATCH] [DEV] rework test with new API --- lutin_river_test.py | 3 +- river/io/Node.cpp | 8 ++++- river/io/NodeAirTAudio.cpp | 7 +++++ river/river.cpp | 6 ++-- test/testEchoDelay.h | 50 ++++++++++++++++++++++++------- test/testFormat.h | 17 ++++++++++- test/testMuxer.h | 60 +++++++++++++++++++++++++++++++++---- test/testPlaybackCallback.h | 24 ++++++++++++--- test/testPlaybackWrite.h | 25 ++++++++++++---- test/testRecordCallback.h | 19 ++++++++++-- test/testVolume.h | 20 +++++++++++-- 11 files changed, 203 insertions(+), 36 deletions(-) diff --git a/lutin_river_test.py b/lutin_river_test.py index f5f5e30..cf40e96 100644 --- a/lutin_river_test.py +++ b/lutin_river_test.py @@ -14,7 +14,7 @@ def create(target): 'test/main.cpp', 'test/debug.cpp' ]) - + """ if target.name=="Windows": myModule.copy_file('data/hardwareWindows.json', 'hardware.json') elif target.name=="Linux": @@ -27,6 +27,7 @@ def create(target): myModule.copy_file('data/hardwareAndroid.json', 'hardware.json') else: debug.warning("unknow target for AIRTAudio : " + target.name); + """ myModule.add_module_depend(['river', 'gtest', 'etk']) diff --git a/river/io/Node.cpp b/river/io/Node.cpp index 2281707..b0a8c17 100644 --- a/river/io/Node.cpp +++ b/river/io/Node.cpp @@ -35,6 +35,7 @@ river::io::Node::Node(const std::string& _name, const std11::shared_ptrgetStringValue("io"); + RIVER_INFO("interfaceType=" << interfaceType); if ( interfaceType == "input" || interfaceType == "PAinput" || interfaceType == "aec" @@ -72,7 +73,12 @@ river::io::Node::Node(const std::string& _name, const std11::shared_ptrgetStringValue("mux-demux-type", "int16-on-int32"); + std::string muxerDemuxerConfig; + if (m_isInput == true) { + muxerDemuxerConfig = m_config->getStringValue("mux-demux-type", "int16"); + } else { + muxerDemuxerConfig = m_config->getStringValue("mux-demux-type", "int16-on-int32"); + } enum audio::format muxerFormatType = audio::getFormatFromString(muxerDemuxerConfig); if (m_isInput == true) { if (muxerFormatType != audio::format_int16) { diff --git a/river/io/NodeAirTAudio.cpp b/river/io/NodeAirTAudio.cpp index b32c8c5..21df441 100644 --- a/river/io/NodeAirTAudio.cpp +++ b/river/io/NodeAirTAudio.cpp @@ -220,10 +220,15 @@ river::io::NodeAirTAudio::NodeAirTAudio(const std::string& _name, const std11::s airtaudio::StreamOptions option; etk::from_string(option.mode, tmpObject->getStringValue("timestamp-mode", "soft")); + RIVER_DEBUG("interfaceFormat=" << interfaceFormat); + RIVER_DEBUG("hardwareFormat=" << hardwareFormat); + m_rtaudioFrameSize = nbChunk; RIVER_INFO("Open output stream nbChannels=" << params.nChannels); enum airtaudio::error err = airtaudio::error_none; if (m_isInput == true) { + m_process.setInputConfig(hardwareFormat); + m_process.setOutputConfig(interfaceFormat); err = m_adac.openStream(nullptr, ¶ms, hardwareFormat.getFormat(), hardwareFormat.getFrequency(), &m_rtaudioFrameSize, std11::bind(&river::io::NodeAirTAudio::recordCallback, @@ -235,6 +240,8 @@ river::io::NodeAirTAudio::NodeAirTAudio(const std::string& _name, const std11::s option ); } else { + m_process.setInputConfig(interfaceFormat); + m_process.setOutputConfig(hardwareFormat); err = m_adac.openStream(¶ms, nullptr, hardwareFormat.getFormat(), hardwareFormat.getFrequency(), &m_rtaudioFrameSize, std11::bind(&river::io::NodeAirTAudio::playbackCallback, diff --git a/river/river.cpp b/river/river.cpp index 09baf65..82950bf 100644 --- a/river/river.cpp +++ b/river/river.cpp @@ -17,7 +17,7 @@ void river::init(const std::string& _filename) { if (river_isInit == false) { river_isInit = true; river_configFile = _filename; - RIVER_INFO("init RIVER :" << river_configFile); + RIVER_DEBUG("init RIVER :" << river_configFile); std11::shared_ptr mng = river::io::Manager::getInstance(); mng->init(river_configFile); } else { @@ -29,7 +29,7 @@ void river::initString(const std::string& _config) { if (river_isInit == false) { river_isInit = true; river_configFile = _config; - RIVER_INFO("init RIVER with config ..."); + RIVER_DEBUG("init RIVER with config."); std11::shared_ptr mng = river::io::Manager::getInstance(); mng->initString(river_configFile); } else { @@ -40,7 +40,7 @@ void river::initString(const std::string& _config) { void river::unInit() { if (river_isInit == true) { river_isInit = false; - RIVER_INFO("un-init RIVER :" << river_configFile); + RIVER_DEBUG("un-init RIVER."); std11::shared_ptr mng = river::io::Manager::getInstance(); mng->unInit(); } diff --git a/test/testEchoDelay.h b/test/testEchoDelay.h index dd9838f..1236076 100644 --- a/test/testEchoDelay.h +++ b/test/testEchoDelay.h @@ -48,8 +48,8 @@ namespace river_test_echo_delay { m_interfaceOut = m_manager->createOutput(48000, channelMap, audio::format_int16, - "speaker", - "delayTestOut"); + "speaker"); + EXPECT_NE(m_interfaceOut, nullptr); // set callback mode ... m_interfaceOut->setOutputCallback(std11::bind(&TestClass::onDataNeeded, this, @@ -65,8 +65,8 @@ namespace river_test_echo_delay { m_interfaceIn = m_manager->createInput(48000, channelMap, audio::format_int16, - "microphone", - "delayTestIn"); + "microphone"); + EXPECT_NE(m_interfaceIn, nullptr); // set callback mode ... m_interfaceIn->setInputCallback(std11::bind(&TestClass::onDataReceived, this, @@ -77,11 +77,11 @@ namespace river_test_echo_delay { std11::placeholders::_5, std11::placeholders::_6)); - m_interfaceFB = m_manager->createInput(48000, - channelMap, - audio::format_int16, - "feedback", - "delayTestFB"); + m_interfaceFB = m_manager->createFeedback(48000, + channelMap, + audio::format_int16, + "speaker"); + EXPECT_NE(m_interfaceFB, nullptr); // set callback mode ... m_interfaceFB->setInputCallback(std11::bind(&TestClass::onDataReceivedFeedBack, this, @@ -363,7 +363,37 @@ namespace river_test_echo_delay { } }; - static const std::string configurationRiver = ""; + static const std::string configurationRiver = + "{\n" + " speaker:{\n" + " io:'output',\n" + " map-on:{\n" + " interface:'auto',\n" + " name:'default',\n" + //" name:'hw:0,0',\n" + " timestamp-mode:'trigered',\n" + " },\n" + //" group:'groupSynchro',\n" + " frequency:0,\n" + " channel-map:['front-left', 'front-right'],\n" + " type:'auto',\n" + " nb-chunk:1024,\n" + " },\n" + " microphone:{\n" + " io:'input',\n" + " map-on:{\n" + " interface:'auto',\n" + " name:'default',\n" + //" name:'hw:0,0',\n" + " timestamp-mode:'trigered',\n" + " },\n" + //" group:'groupSynchro',\n" + " frequency:0,\n" + " channel-map:['front-left', 'front-right'],\n" + " type:'auto',\n" + " nb-chunk:1024\n" + " }\n" + "}\n"; TEST(TestTime, testDelay) { river::initString(configurationRiver); diff --git a/test/testFormat.h b/test/testFormat.h index 81e8dd2..6c48d7a 100644 --- a/test/testFormat.h +++ b/test/testFormat.h @@ -11,6 +11,21 @@ #define __class__ "test_format" namespace river_test_format { + static const std::string configurationRiver = + "{\n" + " speaker:{\n" + " io:'output',\n" + " map-on:{\n" + " interface:'auto',\n" + " name:'default',\n" + " },\n" + " frequency:0,\n" + " channel-map:['front-left', 'front-right'],\n" + " type:'auto',\n" + " nb-chunk:1024,\n" + " volume-name:'MASTER'\n" + " }\n" + "}\n"; class testOutCallbackType { private: std11::shared_ptr m_manager; @@ -51,6 +66,7 @@ namespace river_test_format { _format, "speaker", "WriteModeCallbackType"); + EXPECT_NE(m_interface, nullptr); // set callback mode ... m_interface->setOutputCallback(std11::bind(&testOutCallbackType::onDataNeeded, this, @@ -128,7 +144,6 @@ namespace river_test_format { } }; - static const std::string configurationRiver = ""; class testResampling : public ::testing::TestWithParam {}; TEST_P(testResampling, base) { diff --git a/test/testMuxer.h b/test/testMuxer.h index 7b56333..7911861 100644 --- a/test/testMuxer.h +++ b/test/testMuxer.h @@ -29,8 +29,8 @@ namespace river_test_muxer { m_interfaceOut = m_manager->createOutput(48000, channelMap, audio::format_int16, - "speaker", - "MuxerTestOut"); + "speaker"); + EXPECT_NE(m_interfaceOut, nullptr); // set callback mode ... m_interfaceOut->setOutputCallback(std11::bind(&TestClass::onDataNeeded, this, @@ -47,8 +47,8 @@ namespace river_test_muxer { m_interfaceIn = m_manager->createInput(48000, std::vector(), audio::format_int16, - "microphone-muxed", - "microphone-muxed-local-name"); + "microphone-muxed"); + EXPECT_NE(m_interfaceIn, nullptr); // set callback mode ... m_interfaceIn->setInputCallback(std11::bind(&TestClass::onDataReceived, this, @@ -100,7 +100,57 @@ namespace river_test_muxer { } }; - static const std::string configurationRiver = ""; + static const std::string configurationRiver = + "{\n" + " speaker:{\n" + " io:'output',\n" + " map-on:{\n" + " interface:'auto',\n" + " name:'default',\n" + " timestamp-mode:'trigered',\n" + " },\n" + " group:'groupSynchro',\n" + " frequency:0,\n" + " channel-map:['front-left', 'front-right'],\n" + " type:'auto',\n" + " nb-chunk:1024,\n" + " },\n" + " microphone:{\n" + " io:'input',\n" + " map-on:{\n" + " interface:'auto',\n" + " name:'default',\n" + " timestamp-mode:'trigered',\n" + " },\n" + " group:'groupSynchro',\n" + " frequency:0,\n" + " channel-map:['front-left', 'front-right'],\n" + " type:'auto',\n" + " nb-chunk:1024\n" + " },\n" + " microphone-muxed:{\n" + " io:'muxer',\n" + " # connect in input mode\n" + " map-on-input-1:{\n" + " # generic virtual definition\n" + " io:'input',\n" + " map-on:'microphone',\n" + " },\n" + " # connect in feedback mode\n" + " map-on-input-2:{\n" + " io:'feedback',\n" + " map-on:'speaker',\n" + " },\n" + " input-2-remap:['rear-left', 'rear-right'],\n" + " #classical format configuration:\n" + " frequency:48000,\n" + " channel-map:[\n" + " 'front-left', 'front-right', 'rear-left', 'rear-right'\n" + " ],\n" + " type:'int16',\n" + " mux-demux-type:'int16',\n" + " }\n" + "}\n"; TEST(TestMuxer, testMuxing) { river::initString(configurationRiver); diff --git a/test/testPlaybackCallback.h b/test/testPlaybackCallback.h index 3d2d8e5..65986d1 100644 --- a/test/testPlaybackCallback.h +++ b/test/testPlaybackCallback.h @@ -13,7 +13,7 @@ namespace river_test_playback_callback { class testOutCallback { - private: + public: std11::shared_ptr m_manager; std11::shared_ptr m_interface; double m_phase; @@ -28,8 +28,8 @@ namespace river_test_playback_callback { m_interface = m_manager->createOutput(48000, channelMap, audio::format_int16, - _io, - "WriteModeCallback"); + _io); + ASSERT_NE(m_interface, nullptr); // set callback mode ... m_interface->setOutputCallback(std11::bind(&testOutCallback::onDataNeeded, this, @@ -62,6 +62,7 @@ namespace river_test_playback_callback { } } void run() { + ASSERT_NE(m_interface, nullptr); m_interface->start(); // wait 2 second ... usleep(2000000); @@ -69,7 +70,21 @@ namespace river_test_playback_callback { } }; - static const std::string configurationRiver = ""; + static const std::string configurationRiver = + "{\n" + " speaker:{\n" + " io:'output',\n" + " map-on:{\n" + " interface:'auto',\n" + " name:'default',\n" + " },\n" + " frequency:0,\n" + " channel-map:['front-left', 'front-right'],\n" + " type:'auto',\n" + " nb-chunk:1024,\n" + " volume-name:'MASTER'\n" + " }\n" + "}\n"; TEST(TestALL, testOutputCallBack) { river::initString(configurationRiver); @@ -78,6 +93,7 @@ namespace river_test_playback_callback { APPL_INFO("test output (callback mode)"); std11::shared_ptr process = std11::make_shared(manager, "speaker"); + ASSERT_NE(process, nullptr); process->run(); process.reset(); usleep(500000); diff --git a/test/testPlaybackWrite.h b/test/testPlaybackWrite.h index cac412b..66117dd 100644 --- a/test/testPlaybackWrite.h +++ b/test/testPlaybackWrite.h @@ -11,7 +11,21 @@ #define __class__ "test_playback_write" namespace river_test_playback_write { - static const std::string configurationRiver = ""; + static const std::string configurationRiver = + "{\n" + " speaker:{\n" + " io:'output',\n" + " map-on:{\n" + " interface:'auto',\n" + " name:'default',\n" + " },\n" + " frequency:0,\n" + " channel-map:['front-left', 'front-right'],\n" + " type:'auto',\n" + " nb-chunk:1024,\n" + " volume-name:'MASTER'\n" + " }\n" + "}\n"; class testOutWrite { private: @@ -27,8 +41,8 @@ namespace river_test_playback_write { m_interface = m_manager->createOutput(48000, m_channelMap, audio::format_int16, - "speaker", - "WriteMode"); + "speaker"); + EXPECT_NE(m_interface, nullptr); m_interface->setReadwrite(); } void run() { @@ -97,8 +111,7 @@ namespace river_test_playback_write { m_interface = m_manager->createOutput(48000, channelMap, audio::format_int16, - "speaker", - "WriteMode+Callback"); + "speaker"); m_interface->setReadwrite(); m_interface->setWriteCallback(std11::bind(&testOutWriteCallback::onDataNeeded, this, @@ -139,6 +152,7 @@ namespace river_test_playback_write { }; TEST(TestALL, testOutputWriteWithCallback) { + river::initString(configurationRiver); std11::shared_ptr manager; manager = river::Manager::create("testApplication"); @@ -147,6 +161,7 @@ namespace river_test_playback_write { process->run(); process.reset(); usleep(500000); + river::unInit(); } }; diff --git a/test/testRecordCallback.h b/test/testRecordCallback.h index 494feb5..5429457 100644 --- a/test/testRecordCallback.h +++ b/test/testRecordCallback.h @@ -13,7 +13,20 @@ #define __class__ "test_record_callback" namespace river_test_record_callback { - static const std::string configurationRiver = ""; + static const std::string configurationRiver = + "{\n" + " microphone:{\n" + " io:'input',\n" + " map-on:{\n" + " interface:'auto',\n" + " name:'default',\n" + " },\n" + " frequency:0,\n" + " channel-map:['front-left', 'front-right'],\n" + " type:'auto',\n" + " nb-chunk:1024\n" + " }\n" + "}\n"; class testInCallback { private: @@ -27,8 +40,8 @@ namespace river_test_record_callback { m_interface = m_manager->createInput(48000, channelMap, audio::format_int16, - _input, - "WriteModeCallback"); + _input); + EXPECT_NE(m_interface, nullptr); // set callback mode ... m_interface->setInputCallback(std11::bind(&testInCallback::onDataReceived, this, diff --git a/test/testVolume.h b/test/testVolume.h index 2ae3805..5c07acf 100644 --- a/test/testVolume.h +++ b/test/testVolume.h @@ -11,7 +11,21 @@ #define __class__ "test_volume" namespace river_test_volume { - static const std::string configurationRiver = ""; + static const std::string configurationRiver = + "{\n" + " speaker:{\n" + " io:'output',\n" + " map-on:{\n" + " interface:'auto',\n" + " name:'default',\n" + " },\n" + " frequency:0,\n" + " channel-map:['front-left', 'front-right'],\n" + " type:'auto',\n" + " nb-chunk:1024,\n" + " volume-name:'MASTER'\n" + " }\n" + "}\n"; class testCallbackVolume { private: @@ -29,8 +43,8 @@ namespace river_test_volume { m_interface = m_manager->createOutput(48000, channelMap, audio::format_int16, - "speaker", - "WriteModeCallback"); + "speaker"); + EXPECT_NE(m_interface, nullptr); // set callback mode ... m_interface->setOutputCallback(std11::bind(&testCallbackVolume::onDataNeeded, this,