diff --git a/data/hardware.json b/data/hardware.json index 4e4bed2..4c80448 100644 --- a/data/hardware.json +++ b/data/hardware.json @@ -25,5 +25,33 @@ type:"int16", nb-chunk:1024, volume-name:"MASTER" + }, + speaker-pulse:{ + io:"output", + map-on:{ + interface:"pulse", + name:"default", + }, + frequency:48000, + channel-map:[ + "front-left", "front-right", + ], + type:"int16", + nb-chunk:1024, + volume-name:"MASTER" + }, + speaker-jack:{ + io:"output", + map-on:{ + interface:"jack", + name:"default", + }, + frequency:48000, + channel-map:[ + "front-left", "front-right", + ], + type:"float", + nb-chunk:1024, + volume-name:"MASTER" } } \ No newline at end of file diff --git a/river/Interface.cpp b/river/Interface.cpp index ccc66c3..317b820 100644 --- a/river/Interface.cpp +++ b/river/Interface.cpp @@ -42,9 +42,10 @@ bool river::Interface::init(const std::string& _name, m_node->registerAsRemote(shared_from_this()); // Create convertion interface if (m_node->isInput() == true) { + m_process->setInputConfig(m_node->getInterfaceFormat()); // add all time the volume stage : std::shared_ptr algo = drain::Volume::create(); - algo->setInputFormat(m_node->getInterfaceFormat()); + //algo->setInputFormat(m_node->getInterfaceFormat()); algo->setName("volume"); m_process->pushBack(algo); RIVER_INFO("add basic volume stage (1)"); @@ -53,10 +54,12 @@ bool river::Interface::init(const std::string& _name, RIVER_INFO(" add volume for node"); algo->addVolumeStage(tmpVolume); } + m_process->setOutputConfig(drain::IOFormatInterface(m_map, m_format, m_freq)); } else { + m_process->setInputConfig(drain::IOFormatInterface(m_map, m_format, m_freq)); // add all time the volume stage : std::shared_ptr algo = drain::Volume::create(); - algo->setOutputFormat(m_node->getInterfaceFormat()); + //algo->setOutputFormat(m_node->getInterfaceFormat()); algo->setName("volume"); m_process->pushBack(algo); RIVER_INFO("add basic volume stage (2)"); @@ -65,6 +68,7 @@ bool river::Interface::init(const std::string& _name, RIVER_INFO(" add volume for node"); algo->addVolumeStage(tmpVolume); } + m_process->setOutputConfig(m_node->getInterfaceFormat()); } return true; } @@ -100,14 +104,12 @@ void river::Interface::setReadwrite() { if (m_node->isInput() == true) { m_process->removeIfLast(); std::shared_ptr algo = drain::EndPointRead::create(); - ///algo->setInputFormat(drain::IOFormatInterface(m_map, m_format, m_freq)); - algo->setOutputFormat(drain::IOFormatInterface(m_map, m_format, m_freq)); + //algo->setOutputFormat(drain::IOFormatInterface(m_map, m_format, m_freq)); m_process->pushBack(algo); } else { m_process->removeIfFirst(); std::shared_ptr algo = drain::EndPointWrite::create(); - algo->setInputFormat(drain::IOFormatInterface(m_map, m_format, m_freq)); - //algo->setOutputFormat(drain::IOFormatInterface(m_map, m_format, m_freq)); + //algo->setInputFormat(drain::IOFormatInterface(m_map, m_format, m_freq)); m_process->pushFront(algo); } } @@ -118,8 +120,7 @@ void river::Interface::setOutputCallback(size_t _chunkSize, drain::needDataFunct m_process->removeIfFirst(); std::shared_ptr algo = drain::EndPointCallback::create(_function); RIVER_INFO("set property: " << m_map << " " << m_format << " " << m_freq); - algo->setInputFormat(drain::IOFormatInterface(m_map, m_format, m_freq)); - //algo->setOutputFormat(drain::IOFormatInterface(m_map, m_format, m_freq)); + //algo->setInputFormat(drain::IOFormatInterface(m_map, m_format, m_freq)); m_process->pushFront(algo); } @@ -128,8 +129,7 @@ void river::Interface::setInputCallback(size_t _chunkSize, drain::haveNewDataFun m_process->removeAlgoDynamic(); m_process->removeIfLast(); std::shared_ptr algo = drain::EndPointCallback::create(_function); - //algo->setInputFormat(drain::IOFormatInterface(m_map, m_format, m_freq)); - algo->setOutputFormat(drain::IOFormatInterface(m_map, m_format, m_freq)); + //algo->setOutputFormat(drain::IOFormatInterface(m_map, m_format, m_freq)); m_process->pushBack(algo); } diff --git a/river/io/Node.cpp b/river/io/Node.cpp index 8edcce4..8a8b9cb 100644 --- a/river/io/Node.cpp +++ b/river/io/Node.cpp @@ -36,18 +36,17 @@ int32_t river::io::Node::rtAudioCallback(void* _outputBuffer, if (_outputBuffer != nullptr) { RIVER_VERBOSE("data Output"); std::vector output; - output.resize(_nBufferFrames*m_interfaceFormat.getMap().size(), 0); + output.resize(_nBufferFrames*m_process.getInputConfig().getMap().size(), 0); const int32_t* outputTmp = nullptr; std::vector outputTmp2; - outputTmp2.resize(sizeof(int32_t)*m_interfaceFormat.getMap().size()*_nBufferFrames, 0); + outputTmp2.resize(sizeof(int32_t)*m_process.getInputConfig().getMap().size()*_nBufferFrames, 0); for (auto &it : m_list) { if (it != nullptr) { // clear datas ... - memset(&outputTmp2[0], 0, sizeof(int32_t)*m_interfaceFormat.getMap().size()*_nBufferFrames); + memset(&outputTmp2[0], 0, sizeof(int32_t)*m_process.getInputConfig().getMap().size()*_nBufferFrames); RIVER_VERBOSE(" IO : " /* << std::distance(m_list.begin(), it)*/ << "/" << m_list.size() << " name="<< it->getName()); - it->systemNeedOutputData(ttime, &outputTmp2[0], _nBufferFrames, sizeof(int32_t)*m_interfaceFormat.getMap().size()); + it->systemNeedOutputData(ttime, &outputTmp2[0], _nBufferFrames, sizeof(int32_t)*m_process.getInputConfig().getMap().size()); outputTmp = reinterpret_cast(&outputTmp2[0]); - //it->systemNeedOutputData(ttime, _outputBuffer, _nBufferFrames, sizeof(int16_t)*m_map.size()); // Add data to the output tmp buffer : for (size_t kkk=0; kkk(_outputBuffer); - for (size_t kkk=0; kkk(std::min(std::max(INT16_MIN, output[kkk]), INT16_MAX)); - } + m_process.processIn(&outputTmp2[0], _nBufferFrames, _outputBuffer, _nBufferFrames); + // TODO : Call feedback ... } if (_inputBuffer != nullptr) { RIVER_INFO("data Input"); @@ -85,6 +82,8 @@ river::io::Node::Node(const std::string& _name, const std::shared_ptrgetVolumeGroup(volumeName); } - enum audio::format formatType = audio::format_int16; - if (type == "int16") { - formatType = audio::format_int16; - } else { - RIVER_WARNING("not managed type : '" << type << "'"); - } + enum audio::format formatType = audio::getFormatFromString(type); // TODO : MAP ... // intanciate specific API ... @@ -140,22 +134,22 @@ river::io::Node::Node(const std::string& _name, const std::shared_ptr float, int16 -> int16/int32, ... if (m_isInput == true) { // for input we just transfert audio with no transformation - m_interfaceFormat.set(map, audio::format_int16, frequency); + interfaceFormat.set(map, audio::format_int16, frequency); } else { // for output we will do a mix ... - m_interfaceFormat.set(map, audio::format_int16_on_int32, frequency); + interfaceFormat.set(map, audio::format_int16_on_int32, frequency); } // search device ID : RIVER_INFO("Open :"); RIVER_INFO(" m_streamName=" << streamName); - RIVER_INFO(" m_freq=" << m_hardwareFormat.getFrequency()); - RIVER_INFO(" m_map=" << m_hardwareFormat.getMap()); - RIVER_INFO(" m_format=" << m_hardwareFormat.getFormat()); + RIVER_INFO(" m_freq=" << hardwareFormat.getFrequency()); + RIVER_INFO(" m_map=" << hardwareFormat.getMap()); + RIVER_INFO(" m_format=" << hardwareFormat.getFormat()); RIVER_INFO(" m_isInput=" << m_isInput); int32_t deviceId = 0; RIVER_INFO("Device list:"); @@ -179,13 +173,16 @@ river::io::Node::Node(const std::string& _name, const std::shared_ptr m_interface; double m_phase; public: - testOutCallback(std::shared_ptr _manager) : + testOutCallback(std::shared_ptr _manager, const std::string& _io="speaker") : m_manager(_manager), m_phase(0) { //Set stereo output: @@ -166,7 +166,7 @@ class testOutCallback { m_interface = m_manager->createOutput(48000, channelMap, audio::format_int16, - "speaker", + _io, "WriteModeCallback"); // set callback mode ... m_interface->setOutputCallback(1024, @@ -211,7 +211,29 @@ TEST(TestALL, testOutputCallBack) { manager = river::Manager::create("testApplication"); APPL_INFO("test output (callback mode)"); - std::shared_ptr process = std::make_shared(manager); + std::shared_ptr process = std::make_shared(manager, "speaker"); + process->run(); + process.reset(); + usleep(500000); +} + +TEST(TestALL, testOutputCallBackPulse) { + std::shared_ptr manager; + manager = river::Manager::create("testApplication"); + + APPL_INFO("test output (callback mode)"); + std::shared_ptr process = std::make_shared(manager, "speaker-pulse"); + process->run(); + process.reset(); + usleep(500000); +} + +TEST(TestALL, testOutputCallBackJack) { + std::shared_ptr manager; + manager = river::Manager::create("testApplication"); + + APPL_INFO("test output (callback mode)"); + std::shared_ptr process = std::make_shared(manager, "speaker-jack"); process->run(); process.reset(); usleep(500000);