[DEV] rework test with new API

This commit is contained in:
Edouard DUPIN 2015-03-13 23:22:17 +01:00
parent 57c4795a1e
commit 0d448bed76
11 changed files with 203 additions and 36 deletions

View File

@ -14,7 +14,7 @@ def create(target):
'test/main.cpp', 'test/main.cpp',
'test/debug.cpp' 'test/debug.cpp'
]) ])
"""
if target.name=="Windows": if target.name=="Windows":
myModule.copy_file('data/hardwareWindows.json', 'hardware.json') myModule.copy_file('data/hardwareWindows.json', 'hardware.json')
elif target.name=="Linux": elif target.name=="Linux":
@ -27,6 +27,7 @@ def create(target):
myModule.copy_file('data/hardwareAndroid.json', 'hardware.json') myModule.copy_file('data/hardwareAndroid.json', 'hardware.json')
else: else:
debug.warning("unknow target for AIRTAudio : " + target.name); debug.warning("unknow target for AIRTAudio : " + target.name);
"""
myModule.add_module_depend(['river', 'gtest', 'etk']) myModule.add_module_depend(['river', 'gtest', 'etk'])

View File

@ -35,6 +35,7 @@ river::io::Node::Node(const std::string& _name, const std11::shared_ptr<const ej
mux-demux-type:"int16_on_int32", mux-demux-type:"int16_on_int32",
*/ */
std::string interfaceType = m_config->getStringValue("io"); std::string interfaceType = m_config->getStringValue("io");
RIVER_INFO("interfaceType=" << interfaceType);
if ( interfaceType == "input" if ( interfaceType == "input"
|| interfaceType == "PAinput" || interfaceType == "PAinput"
|| interfaceType == "aec" || interfaceType == "aec"
@ -72,7 +73,12 @@ river::io::Node::Node(const std::string& _name, const std11::shared_ptr<const ej
hardwareFormat.set(map, formatType, frequency); hardwareFormat.set(map, formatType, frequency);
std::string muxerDemuxerConfig = m_config->getStringValue("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); enum audio::format muxerFormatType = audio::getFormatFromString(muxerDemuxerConfig);
if (m_isInput == true) { if (m_isInput == true) {
if (muxerFormatType != audio::format_int16) { if (muxerFormatType != audio::format_int16) {

View File

@ -220,10 +220,15 @@ river::io::NodeAirTAudio::NodeAirTAudio(const std::string& _name, const std11::s
airtaudio::StreamOptions option; airtaudio::StreamOptions option;
etk::from_string(option.mode, tmpObject->getStringValue("timestamp-mode", "soft")); etk::from_string(option.mode, tmpObject->getStringValue("timestamp-mode", "soft"));
RIVER_DEBUG("interfaceFormat=" << interfaceFormat);
RIVER_DEBUG("hardwareFormat=" << hardwareFormat);
m_rtaudioFrameSize = nbChunk; m_rtaudioFrameSize = nbChunk;
RIVER_INFO("Open output stream nbChannels=" << params.nChannels); RIVER_INFO("Open output stream nbChannels=" << params.nChannels);
enum airtaudio::error err = airtaudio::error_none; enum airtaudio::error err = airtaudio::error_none;
if (m_isInput == true) { if (m_isInput == true) {
m_process.setInputConfig(hardwareFormat);
m_process.setOutputConfig(interfaceFormat);
err = m_adac.openStream(nullptr, &params, err = m_adac.openStream(nullptr, &params,
hardwareFormat.getFormat(), hardwareFormat.getFrequency(), &m_rtaudioFrameSize, hardwareFormat.getFormat(), hardwareFormat.getFrequency(), &m_rtaudioFrameSize,
std11::bind(&river::io::NodeAirTAudio::recordCallback, std11::bind(&river::io::NodeAirTAudio::recordCallback,
@ -235,6 +240,8 @@ river::io::NodeAirTAudio::NodeAirTAudio(const std::string& _name, const std11::s
option option
); );
} else { } else {
m_process.setInputConfig(interfaceFormat);
m_process.setOutputConfig(hardwareFormat);
err = m_adac.openStream(&params, nullptr, err = m_adac.openStream(&params, nullptr,
hardwareFormat.getFormat(), hardwareFormat.getFrequency(), &m_rtaudioFrameSize, hardwareFormat.getFormat(), hardwareFormat.getFrequency(), &m_rtaudioFrameSize,
std11::bind(&river::io::NodeAirTAudio::playbackCallback, std11::bind(&river::io::NodeAirTAudio::playbackCallback,

View File

@ -17,7 +17,7 @@ void river::init(const std::string& _filename) {
if (river_isInit == false) { if (river_isInit == false) {
river_isInit = true; river_isInit = true;
river_configFile = _filename; river_configFile = _filename;
RIVER_INFO("init RIVER :" << river_configFile); RIVER_DEBUG("init RIVER :" << river_configFile);
std11::shared_ptr<river::io::Manager> mng = river::io::Manager::getInstance(); std11::shared_ptr<river::io::Manager> mng = river::io::Manager::getInstance();
mng->init(river_configFile); mng->init(river_configFile);
} else { } else {
@ -29,7 +29,7 @@ void river::initString(const std::string& _config) {
if (river_isInit == false) { if (river_isInit == false) {
river_isInit = true; river_isInit = true;
river_configFile = _config; river_configFile = _config;
RIVER_INFO("init RIVER with config ..."); RIVER_DEBUG("init RIVER with config.");
std11::shared_ptr<river::io::Manager> mng = river::io::Manager::getInstance(); std11::shared_ptr<river::io::Manager> mng = river::io::Manager::getInstance();
mng->initString(river_configFile); mng->initString(river_configFile);
} else { } else {
@ -40,7 +40,7 @@ void river::initString(const std::string& _config) {
void river::unInit() { void river::unInit() {
if (river_isInit == true) { if (river_isInit == true) {
river_isInit = false; river_isInit = false;
RIVER_INFO("un-init RIVER :" << river_configFile); RIVER_DEBUG("un-init RIVER.");
std11::shared_ptr<river::io::Manager> mng = river::io::Manager::getInstance(); std11::shared_ptr<river::io::Manager> mng = river::io::Manager::getInstance();
mng->unInit(); mng->unInit();
} }

View File

@ -48,8 +48,8 @@ namespace river_test_echo_delay {
m_interfaceOut = m_manager->createOutput(48000, m_interfaceOut = m_manager->createOutput(48000,
channelMap, channelMap,
audio::format_int16, audio::format_int16,
"speaker", "speaker");
"delayTestOut"); EXPECT_NE(m_interfaceOut, nullptr);
// set callback mode ... // set callback mode ...
m_interfaceOut->setOutputCallback(std11::bind(&TestClass::onDataNeeded, m_interfaceOut->setOutputCallback(std11::bind(&TestClass::onDataNeeded,
this, this,
@ -65,8 +65,8 @@ namespace river_test_echo_delay {
m_interfaceIn = m_manager->createInput(48000, m_interfaceIn = m_manager->createInput(48000,
channelMap, channelMap,
audio::format_int16, audio::format_int16,
"microphone", "microphone");
"delayTestIn"); EXPECT_NE(m_interfaceIn, nullptr);
// set callback mode ... // set callback mode ...
m_interfaceIn->setInputCallback(std11::bind(&TestClass::onDataReceived, m_interfaceIn->setInputCallback(std11::bind(&TestClass::onDataReceived,
this, this,
@ -77,11 +77,11 @@ namespace river_test_echo_delay {
std11::placeholders::_5, std11::placeholders::_5,
std11::placeholders::_6)); std11::placeholders::_6));
m_interfaceFB = m_manager->createInput(48000, m_interfaceFB = m_manager->createFeedback(48000,
channelMap, channelMap,
audio::format_int16, audio::format_int16,
"feedback", "speaker");
"delayTestFB"); EXPECT_NE(m_interfaceFB, nullptr);
// set callback mode ... // set callback mode ...
m_interfaceFB->setInputCallback(std11::bind(&TestClass::onDataReceivedFeedBack, m_interfaceFB->setInputCallback(std11::bind(&TestClass::onDataReceivedFeedBack,
this, 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) { TEST(TestTime, testDelay) {
river::initString(configurationRiver); river::initString(configurationRiver);

View File

@ -11,6 +11,21 @@
#define __class__ "test_format" #define __class__ "test_format"
namespace river_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 { class testOutCallbackType {
private: private:
std11::shared_ptr<river::Manager> m_manager; std11::shared_ptr<river::Manager> m_manager;
@ -51,6 +66,7 @@ namespace river_test_format {
_format, _format,
"speaker", "speaker",
"WriteModeCallbackType"); "WriteModeCallbackType");
EXPECT_NE(m_interface, nullptr);
// set callback mode ... // set callback mode ...
m_interface->setOutputCallback(std11::bind(&testOutCallbackType::onDataNeeded, m_interface->setOutputCallback(std11::bind(&testOutCallbackType::onDataNeeded,
this, this,
@ -128,7 +144,6 @@ namespace river_test_format {
} }
}; };
static const std::string configurationRiver = "";
class testResampling : public ::testing::TestWithParam<float> {}; class testResampling : public ::testing::TestWithParam<float> {};
TEST_P(testResampling, base) { TEST_P(testResampling, base) {

View File

@ -29,8 +29,8 @@ namespace river_test_muxer {
m_interfaceOut = m_manager->createOutput(48000, m_interfaceOut = m_manager->createOutput(48000,
channelMap, channelMap,
audio::format_int16, audio::format_int16,
"speaker", "speaker");
"MuxerTestOut"); EXPECT_NE(m_interfaceOut, nullptr);
// set callback mode ... // set callback mode ...
m_interfaceOut->setOutputCallback(std11::bind(&TestClass::onDataNeeded, m_interfaceOut->setOutputCallback(std11::bind(&TestClass::onDataNeeded,
this, this,
@ -47,8 +47,8 @@ namespace river_test_muxer {
m_interfaceIn = m_manager->createInput(48000, m_interfaceIn = m_manager->createInput(48000,
std::vector<audio::channel>(), std::vector<audio::channel>(),
audio::format_int16, audio::format_int16,
"microphone-muxed", "microphone-muxed");
"microphone-muxed-local-name"); EXPECT_NE(m_interfaceIn, nullptr);
// set callback mode ... // set callback mode ...
m_interfaceIn->setInputCallback(std11::bind(&TestClass::onDataReceived, m_interfaceIn->setInputCallback(std11::bind(&TestClass::onDataReceived,
this, 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) { TEST(TestMuxer, testMuxing) {
river::initString(configurationRiver); river::initString(configurationRiver);

View File

@ -13,7 +13,7 @@
namespace river_test_playback_callback { namespace river_test_playback_callback {
class testOutCallback { class testOutCallback {
private: public:
std11::shared_ptr<river::Manager> m_manager; std11::shared_ptr<river::Manager> m_manager;
std11::shared_ptr<river::Interface> m_interface; std11::shared_ptr<river::Interface> m_interface;
double m_phase; double m_phase;
@ -28,8 +28,8 @@ namespace river_test_playback_callback {
m_interface = m_manager->createOutput(48000, m_interface = m_manager->createOutput(48000,
channelMap, channelMap,
audio::format_int16, audio::format_int16,
_io, _io);
"WriteModeCallback"); ASSERT_NE(m_interface, nullptr);
// set callback mode ... // set callback mode ...
m_interface->setOutputCallback(std11::bind(&testOutCallback::onDataNeeded, m_interface->setOutputCallback(std11::bind(&testOutCallback::onDataNeeded,
this, this,
@ -62,6 +62,7 @@ namespace river_test_playback_callback {
} }
} }
void run() { void run() {
ASSERT_NE(m_interface, nullptr);
m_interface->start(); m_interface->start();
// wait 2 second ... // wait 2 second ...
usleep(2000000); 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) { TEST(TestALL, testOutputCallBack) {
river::initString(configurationRiver); river::initString(configurationRiver);
@ -78,6 +93,7 @@ namespace river_test_playback_callback {
APPL_INFO("test output (callback mode)"); APPL_INFO("test output (callback mode)");
std11::shared_ptr<testOutCallback> process = std11::make_shared<testOutCallback>(manager, "speaker"); std11::shared_ptr<testOutCallback> process = std11::make_shared<testOutCallback>(manager, "speaker");
ASSERT_NE(process, nullptr);
process->run(); process->run();
process.reset(); process.reset();
usleep(500000); usleep(500000);

View File

@ -11,7 +11,21 @@
#define __class__ "test_playback_write" #define __class__ "test_playback_write"
namespace river_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 { class testOutWrite {
private: private:
@ -27,8 +41,8 @@ namespace river_test_playback_write {
m_interface = m_manager->createOutput(48000, m_interface = m_manager->createOutput(48000,
m_channelMap, m_channelMap,
audio::format_int16, audio::format_int16,
"speaker", "speaker");
"WriteMode"); EXPECT_NE(m_interface, nullptr);
m_interface->setReadwrite(); m_interface->setReadwrite();
} }
void run() { void run() {
@ -97,8 +111,7 @@ namespace river_test_playback_write {
m_interface = m_manager->createOutput(48000, m_interface = m_manager->createOutput(48000,
channelMap, channelMap,
audio::format_int16, audio::format_int16,
"speaker", "speaker");
"WriteMode+Callback");
m_interface->setReadwrite(); m_interface->setReadwrite();
m_interface->setWriteCallback(std11::bind(&testOutWriteCallback::onDataNeeded, m_interface->setWriteCallback(std11::bind(&testOutWriteCallback::onDataNeeded,
this, this,
@ -139,6 +152,7 @@ namespace river_test_playback_write {
}; };
TEST(TestALL, testOutputWriteWithCallback) { TEST(TestALL, testOutputWriteWithCallback) {
river::initString(configurationRiver);
std11::shared_ptr<river::Manager> manager; std11::shared_ptr<river::Manager> manager;
manager = river::Manager::create("testApplication"); manager = river::Manager::create("testApplication");
@ -147,6 +161,7 @@ namespace river_test_playback_write {
process->run(); process->run();
process.reset(); process.reset();
usleep(500000); usleep(500000);
river::unInit();
} }
}; };

View File

@ -13,7 +13,20 @@
#define __class__ "test_record_callback" #define __class__ "test_record_callback"
namespace river_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 { class testInCallback {
private: private:
@ -27,8 +40,8 @@ namespace river_test_record_callback {
m_interface = m_manager->createInput(48000, m_interface = m_manager->createInput(48000,
channelMap, channelMap,
audio::format_int16, audio::format_int16,
_input, _input);
"WriteModeCallback"); EXPECT_NE(m_interface, nullptr);
// set callback mode ... // set callback mode ...
m_interface->setInputCallback(std11::bind(&testInCallback::onDataReceived, m_interface->setInputCallback(std11::bind(&testInCallback::onDataReceived,
this, this,

View File

@ -11,7 +11,21 @@
#define __class__ "test_volume" #define __class__ "test_volume"
namespace river_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 { class testCallbackVolume {
private: private:
@ -29,8 +43,8 @@ namespace river_test_volume {
m_interface = m_manager->createOutput(48000, m_interface = m_manager->createOutput(48000,
channelMap, channelMap,
audio::format_int16, audio::format_int16,
"speaker", "speaker");
"WriteModeCallback"); EXPECT_NE(m_interface, nullptr);
// set callback mode ... // set callback mode ...
m_interface->setOutputCallback(std11::bind(&testCallbackVolume::onDataNeeded, m_interface->setOutputCallback(std11::bind(&testCallbackVolume::onDataNeeded,
this, this,