[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/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'])

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",
*/
std::string interfaceType = m_config->getStringValue("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_ptr<const ej
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);
if (m_isInput == true) {
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;
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, &params,
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(&params, nullptr,
hardwareFormat.getFormat(), hardwareFormat.getFrequency(), &m_rtaudioFrameSize,
std11::bind(&river::io::NodeAirTAudio::playbackCallback,

View File

@ -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<river::io::Manager> 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<river::io::Manager> 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<river::io::Manager> mng = river::io::Manager::getInstance();
mng->unInit();
}

View File

@ -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);

View File

@ -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<river::Manager> 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<float> {};
TEST_P(testResampling, base) {

View File

@ -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::channel>(),
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);

View File

@ -13,7 +13,7 @@
namespace river_test_playback_callback {
class testOutCallback {
private:
public:
std11::shared_ptr<river::Manager> m_manager;
std11::shared_ptr<river::Interface> 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<testOutCallback> process = std11::make_shared<testOutCallback>(manager, "speaker");
ASSERT_NE(process, nullptr);
process->run();
process.reset();
usleep(500000);

View File

@ -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<river::Manager> manager;
manager = river::Manager::create("testApplication");
@ -147,6 +161,7 @@ namespace river_test_playback_write {
process->run();
process.reset();
usleep(500000);
river::unInit();
}
};

View File

@ -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,

View File

@ -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,