[DEV] add dependency of audio base format

This commit is contained in:
Edouard DUPIN 2015-02-04 22:39:05 +01:00
parent fb500717f8
commit e0e9b1670d
9 changed files with 107 additions and 107 deletions

View File

@ -20,7 +20,7 @@ airtio::Interface::Interface(void) :
m_node(nullptr), m_node(nullptr),
m_freq(8000), m_freq(8000),
m_map(), m_map(),
m_format(airtalgo::format_int16), m_format(audio::format_int16),
m_name(""), m_name(""),
m_volume(0.0f) { m_volume(0.0f) {
@ -28,8 +28,8 @@ airtio::Interface::Interface(void) :
bool airtio::Interface::init(const std::string& _name, bool airtio::Interface::init(const std::string& _name,
float _freq, float _freq,
const std::vector<airtalgo::channel>& _map, const std::vector<audio::channel>& _map,
airtalgo::format _format, audio::format _format,
const std::shared_ptr<airtio::io::Node>& _node) { const std::shared_ptr<airtio::io::Node>& _node) {
m_name = _name; m_name = _name;
m_node = _node; m_node = _node;
@ -71,8 +71,8 @@ bool airtio::Interface::init(const std::string& _name,
std::shared_ptr<airtio::Interface> airtio::Interface::create(const std::string& _name, std::shared_ptr<airtio::Interface> airtio::Interface::create(const std::string& _name,
float _freq, float _freq,
const std::vector<airtalgo::channel>& _map, const std::vector<audio::channel>& _map,
airtalgo::format _format, audio::format _format,
const std::shared_ptr<airtio::io::Node>& _node) { const std::shared_ptr<airtio::io::Node>& _node) {
std::shared_ptr<airtio::Interface> out = std::shared_ptr<airtio::Interface>(new airtio::Interface()); std::shared_ptr<airtio::Interface> out = std::shared_ptr<airtio::Interface>(new airtio::Interface());
out->init(_name, _freq, _map, _format, _node); out->init(_name, _freq, _map, _format, _node);

View File

@ -13,8 +13,8 @@
#include <chrono> #include <chrono>
#include <functional> #include <functional>
#include <mutex> #include <mutex>
#include <airtalgo/format.h> #include <audio/format.h>
#include <airtalgo/channel.h> #include <audio/channel.h>
#include <airtalgo/Process.h> #include <airtalgo/Process.h>
#include <airtalgo/EndPointCallback.h> #include <airtalgo/EndPointCallback.h>
#include <airtalgo/EndPointWrite.h> #include <airtalgo/EndPointWrite.h>
@ -32,8 +32,8 @@ namespace airtio {
protected: protected:
std::shared_ptr<airtio::io::Node> m_node; std::shared_ptr<airtio::io::Node> m_node;
float m_freq; float m_freq;
std::vector<airtalgo::channel> m_map; std::vector<audio::channel> m_map;
airtalgo::format m_format; audio::format m_format;
std::shared_ptr<airtalgo::Process> m_process; std::shared_ptr<airtalgo::Process> m_process;
protected: protected:
std::string m_name; std::string m_name;
@ -48,8 +48,8 @@ namespace airtio {
Interface(); Interface();
bool init(const std::string& _name, bool init(const std::string& _name,
float _freq, float _freq,
const std::vector<airtalgo::channel>& _map, const std::vector<audio::channel>& _map,
airtalgo::format _format, audio::format _format,
const std::shared_ptr<airtio::io::Node>& _node); const std::shared_ptr<airtio::io::Node>& _node);
public: public:
/** /**
@ -58,8 +58,8 @@ namespace airtio {
virtual ~Interface(); virtual ~Interface();
static std::shared_ptr<Interface> create(const std::string& _name, static std::shared_ptr<Interface> create(const std::string& _name,
float _freq, float _freq,
const std::vector<airtalgo::channel>& _map, const std::vector<audio::channel>& _map,
airtalgo::format _format, audio::format _format,
const std::shared_ptr<airtio::io::Node>& _node); const std::shared_ptr<airtio::io::Node>& _node);
/** /**
* @brief set the read/write mode enable. * @brief set the read/write mode enable.

View File

@ -57,8 +57,8 @@ std::pair<float,float> airtio::Manager::getVolumeRange(const std::string& _volum
} }
std::shared_ptr<airtio::Interface> airtio::Manager::createOutput(float _freq, std::shared_ptr<airtio::Interface> airtio::Manager::createOutput(float _freq,
const std::vector<airtalgo::channel>& _map, const std::vector<audio::channel>& _map,
airtalgo::format _format, audio::format _format,
const std::string& _streamName, const std::string& _streamName,
const std::string& _name) { const std::string& _name) {
// get global hardware interface: // get global hardware interface:
@ -74,8 +74,8 @@ std::shared_ptr<airtio::Interface> airtio::Manager::createOutput(float _freq,
} }
std::shared_ptr<airtio::Interface> airtio::Manager::createInput(float _freq, std::shared_ptr<airtio::Interface> airtio::Manager::createInput(float _freq,
const std::vector<airtalgo::channel>& _map, const std::vector<audio::channel>& _map,
airtalgo::format _format, audio::format _format,
const std::string& _streamName, const std::string& _streamName,
const std::string& _name) { const std::string& _name) {
// get global hardware interface: // get global hardware interface:

View File

@ -11,8 +11,8 @@
#include <stdint.h> #include <stdint.h>
#include <memory> #include <memory>
#include <airtio/Interface.h> #include <airtio/Interface.h>
#include <airtalgo/format.h> #include <audio/format.h>
#include <airtalgo/channel.h> #include <audio/channel.h>
namespace airtio { namespace airtio {
/** /**
@ -79,8 +79,8 @@ namespace airtio {
* @return a pointer on the interface * @return a pointer on the interface
*/ */
virtual std::shared_ptr<Interface> createOutput(float _freq, virtual std::shared_ptr<Interface> createOutput(float _freq,
const std::vector<airtalgo::channel>& _map, const std::vector<audio::channel>& _map,
airtalgo::format _format, audio::format _format,
const std::string& _streamName = "", const std::string& _streamName = "",
const std::string& _name = ""); const std::string& _name = "");
/** /**
@ -93,8 +93,8 @@ namespace airtio {
* @return a pointer on the interface * @return a pointer on the interface
*/ */
virtual std::shared_ptr<Interface> createInput(float _freq, virtual std::shared_ptr<Interface> createInput(float _freq,
const std::vector<airtalgo::channel>& _map, const std::vector<audio::channel>& _map,
airtalgo::format _format, audio::format _format,
const std::string& _streamName = "", const std::string& _streamName = "",
const std::string& _name = ""); const std::string& _name = "");
}; };

View File

@ -65,10 +65,14 @@ std::shared_ptr<airtalgo::VolumeElement> airtio::io::Manager::getVolumeGroup(con
bool airtio::io::Manager::setVolume(const std::string& _volumeName, float _valuedB) { bool airtio::io::Manager::setVolume(const std::string& _volumeName, float _valuedB) {
std::shared_ptr<airtalgo::VolumeElement> volume = getVolumeGroup(_volumeName); std::shared_ptr<airtalgo::VolumeElement> volume = getVolumeGroup(_volumeName);
if (volume == nullptr) { if (volume == nullptr) {
AIRTIO_ERROR("Can not get volume ... : '" << _volumeName << "'"); AIRTIO_ERROR("Can not set volume ... : '" << _volumeName << "'");
return false;
}
if ( _valuedB < -300
|| _valuedB > 300) {
AIRTIO_ERROR("Can not set volume ... : '" << _volumeName << "' out of range : [-300..300]");
return false; return false;
} }
// TODO : Check range ...
volume->setVolume(_valuedB); volume->setVolume(_valuedB);
for (auto &it2 : m_list) { for (auto &it2 : m_list) {
std::shared_ptr<airtio::io::Node> val = it2.lock(); std::shared_ptr<airtio::io::Node> val = it2.lock();

View File

@ -13,8 +13,8 @@
#include <stdint.h> #include <stdint.h>
#include <chrono> #include <chrono>
#include <functional> #include <functional>
#include <airtalgo/format.h> #include <audio/format.h>
#include <airtalgo/channel.h> #include <audio/channel.h>
#include <ejson/ejson.h> #include <ejson/ejson.h>
#include <memory> #include <memory>
#include <airtalgo/Volume.h> #include <airtalgo/Volume.h>

View File

@ -150,9 +150,9 @@ airtio::io::Node::Node(const std::string& _name, const std::shared_ptr<const ejs
m_volume = airtio::io::Manager::getInstance()->getVolumeGroup(volumeName); m_volume = airtio::io::Manager::getInstance()->getVolumeGroup(volumeName);
} }
enum airtalgo::format formatType = airtalgo::format_int16; enum audio::format formatType = audio::format_int16;
if (type == "int16") { if (type == "int16") {
formatType = airtalgo::format_int16; formatType = audio::format_int16;
} else { } else {
AIRTIO_WARNING("not managed type : '" << type << "'"); AIRTIO_WARNING("not managed type : '" << type << "'");
} }
@ -165,19 +165,19 @@ airtio::io::Node::Node(const std::string& _name, const std::shared_ptr<const ejs
if (streamName == "") { if (streamName == "") {
streamName = "default"; streamName = "default";
} }
std::vector<airtalgo::channel> map; std::vector<audio::channel> map;
// set default channel property : // set default channel property :
map.push_back(airtalgo::channel_frontLeft); map.push_back(audio::channel_frontLeft);
map.push_back(airtalgo::channel_frontRight); map.push_back(audio::channel_frontRight);
m_hardwareFormat.set(map, formatType, frequency); m_hardwareFormat.set(map, formatType, frequency);
// TODO : Better view of interface type float -> float, int16 -> int16/int32, ... // TODO : Better view of interface type float -> float, int16 -> int16/int32, ...
if (m_isInput == true) { if (m_isInput == true) {
// for input we just transfert audio with no transformation // for input we just transfert audio with no transformation
m_interfaceFormat.set(map, airtalgo::format_int16, frequency); m_interfaceFormat.set(map, audio::format_int16, frequency);
} else { } else {
// for output we will do a mix ... // for output we will do a mix ...
m_interfaceFormat.set(map, airtalgo::format_int16_on_int32, frequency); m_interfaceFormat.set(map, audio::format_int16_on_int32, frequency);
} }
// search device ID : // search device ID :

View File

@ -13,8 +13,8 @@
#include <stdint.h> #include <stdint.h>
#include <chrono> #include <chrono>
#include <functional> #include <functional>
#include <airtalgo/format.h> #include <audio/format.h>
#include <airtalgo/channel.h> #include <audio/channel.h>
#include "Manager.h" #include "Manager.h"
#include <memory> #include <memory>
#include <airtio/Interface.h> #include <airtio/Interface.h>
@ -59,7 +59,7 @@ namespace airtio {
double _streamTime, double _streamTime,
airtaudio::streamStatus _status); airtaudio::streamStatus _status);
private: private:
std::string m_name; std::string m_name; //!< Harware.json configuration name
public: public:
const std::string& getName() { const std::string& getName() {
return m_name; return m_name;

View File

@ -18,18 +18,18 @@
class testOutWrite { class testOutWrite {
private: private:
std::vector<airtalgo::channel> m_channelMap; std::vector<audio::channel> m_channelMap;
std::shared_ptr<airtio::Manager> m_manager; std::shared_ptr<airtio::Manager> m_manager;
std::shared_ptr<airtio::Interface> m_interface; std::shared_ptr<airtio::Interface> m_interface;
public: public:
testOutWrite(std::shared_ptr<airtio::Manager> _manager) : testOutWrite(std::shared_ptr<airtio::Manager> _manager) :
m_manager(_manager) { m_manager(_manager) {
//Set stereo output: //Set stereo output:
m_channelMap.push_back(airtalgo::channel_frontLeft); m_channelMap.push_back(audio::channel_frontLeft);
m_channelMap.push_back(airtalgo::channel_frontRight); m_channelMap.push_back(audio::channel_frontRight);
m_interface = m_manager->createOutput(48000, m_interface = m_manager->createOutput(48000,
m_channelMap, m_channelMap,
airtalgo::format_int16, audio::format_int16,
"speaker", "speaker",
"WriteMode"); "WriteMode");
m_interface->setReadwrite(); m_interface->setReadwrite();
@ -92,13 +92,13 @@ class testOutWriteCallback {
testOutWriteCallback(std::shared_ptr<airtio::Manager> _manager) : testOutWriteCallback(std::shared_ptr<airtio::Manager> _manager) :
m_manager(_manager), m_manager(_manager),
m_phase(0) { m_phase(0) {
std::vector<airtalgo::channel> channelMap; std::vector<audio::channel> channelMap;
//Set stereo output: //Set stereo output:
channelMap.push_back(airtalgo::channel_frontLeft); channelMap.push_back(audio::channel_frontLeft);
channelMap.push_back(airtalgo::channel_frontRight); channelMap.push_back(audio::channel_frontRight);
m_interface = m_manager->createOutput(48000, m_interface = m_manager->createOutput(48000,
channelMap, channelMap,
airtalgo::format_int16, audio::format_int16,
"speaker", "speaker",
"WriteMode+Callback"); "WriteMode+Callback");
m_interface->setReadwrite(); m_interface->setReadwrite();
@ -111,9 +111,9 @@ class testOutWriteCallback {
} }
void onDataNeeded(const std::chrono::system_clock::time_point& _playTime, void onDataNeeded(const std::chrono::system_clock::time_point& _playTime,
const size_t& _nbChunk, const size_t& _nbChunk,
const std::vector<airtalgo::channel>& _map, const std::vector<audio::channel>& _map,
enum airtalgo::format _type) { enum audio::format _type) {
if (_type != airtalgo::format_int16) { if (_type != audio::format_int16) {
APPL_ERROR("call wrong type ... (need int16_t)"); APPL_ERROR("call wrong type ... (need int16_t)");
} }
std::vector<int16_t> data; std::vector<int16_t> data;
@ -160,12 +160,12 @@ class testOutCallback {
m_manager(_manager), m_manager(_manager),
m_phase(0) { m_phase(0) {
//Set stereo output: //Set stereo output:
std::vector<airtalgo::channel> channelMap; std::vector<audio::channel> channelMap;
channelMap.push_back(airtalgo::channel_frontLeft); channelMap.push_back(audio::channel_frontLeft);
channelMap.push_back(airtalgo::channel_frontRight); channelMap.push_back(audio::channel_frontRight);
m_interface = m_manager->createOutput(48000, m_interface = m_manager->createOutput(48000,
channelMap, channelMap,
airtalgo::format_int16, audio::format_int16,
"speaker", "speaker",
"WriteModeCallback"); "WriteModeCallback");
// set callback mode ... // set callback mode ...
@ -180,10 +180,10 @@ class testOutCallback {
} }
void onDataNeeded(const std::chrono::system_clock::time_point& _playTime, void onDataNeeded(const std::chrono::system_clock::time_point& _playTime,
const size_t& _nbChunk, const size_t& _nbChunk,
const std::vector<airtalgo::channel>& _map, const std::vector<audio::channel>& _map,
void* _data, void* _data,
enum airtalgo::format _type) { enum audio::format _type) {
if (_type != airtalgo::format_int16) { if (_type != audio::format_int16) {
APPL_ERROR("call wrong type ... (need int16_t)"); APPL_ERROR("call wrong type ... (need int16_t)");
} }
int16_t* data = static_cast<int16_t*>(_data); int16_t* data = static_cast<int16_t*>(_data);
@ -220,18 +220,18 @@ TEST(TestALL, testOutputCallBack) {
/* /*
class testInRead { class testInRead {
private: private:
std::vector<airtalgo::channel> m_channelMap; std::vector<audio::channel> m_channelMap;
std::shared_ptr<airtio::Manager> m_manager; std::shared_ptr<airtio::Manager> m_manager;
std::shared_ptr<airtio::Interface> m_interface; std::shared_ptr<airtio::Interface> m_interface;
public: public:
testInRead(std::shared_ptr<airtio::Manager> _manager) : testInRead(std::shared_ptr<airtio::Manager> _manager) :
m_manager(_manager){ m_manager(_manager){
//Set stereo output: //Set stereo output:
m_channelMap.push_back(airtalgo::channel_frontLeft); m_channelMap.push_back(audio::channel_frontLeft);
m_channelMap.push_back(airtalgo::channel_frontRight); m_channelMap.push_back(audio::channel_frontRight);
m_interface = m_manager->createInput(48000, m_interface = m_manager->createInput(48000,
m_channelMap, m_channelMap,
airtalgo::format_int16, audio::format_int16,
"microphone", "microphone",
"WriteMode"); "WriteMode");
m_interface->setReadwrite(); m_interface->setReadwrite();
@ -273,12 +273,12 @@ class testInCallback {
m_manager(_manager), m_manager(_manager),
m_phase(0) { m_phase(0) {
//Set stereo output: //Set stereo output:
std::vector<airtalgo::channel> channelMap; std::vector<audio::channel> channelMap;
channelMap.push_back(airtalgo::channel_frontLeft); channelMap.push_back(audio::channel_frontLeft);
channelMap.push_back(airtalgo::channel_frontRight); channelMap.push_back(audio::channel_frontRight);
m_interface = m_manager->createInput(48000, m_interface = m_manager->createInput(48000,
channelMap, channelMap,
airtalgo::format_int16, audio::format_int16,
"microphone", "microphone",
"WriteModeCallback"); "WriteModeCallback");
// set callback mode ... // set callback mode ...
@ -293,10 +293,10 @@ class testInCallback {
} }
void onDataReceived(const std::chrono::system_clock::time_point& _readTime, void onDataReceived(const std::chrono::system_clock::time_point& _readTime,
size_t _nbChunk, size_t _nbChunk,
const std::vector<airtalgo::channel>& _map, const std::vector<audio::channel>& _map,
const void* _data, const void* _data,
enum airtalgo::format _type) { enum audio::format _type) {
if (_type != airtalgo::format_int16) { if (_type != audio::format_int16) {
APPL_ERROR("call wrong type ... (need int16_t)"); APPL_ERROR("call wrong type ... (need int16_t)");
} }
const int16_t* data = static_cast<const int16_t*>(_data); const int16_t* data = static_cast<const int16_t*>(_data);
@ -339,24 +339,24 @@ class testOutCallbackType {
testOutCallbackType(const std::shared_ptr<airtio::Manager>& _manager, testOutCallbackType(const std::shared_ptr<airtio::Manager>& _manager,
float _freq=48000.0f, float _freq=48000.0f,
int32_t _nbChannels=2, int32_t _nbChannels=2,
airtalgo::format _format=airtalgo::format_int16) : audio::format _format=audio::format_int16) :
m_manager(_manager), m_manager(_manager),
m_phase(0), m_phase(0),
m_freq(_freq), m_freq(_freq),
m_nbChannels(_nbChannels), m_nbChannels(_nbChannels),
m_generateFreq(550.0f) { m_generateFreq(550.0f) {
//Set stereo output: //Set stereo output:
std::vector<airtalgo::channel> channelMap; std::vector<audio::channel> channelMap;
if (m_nbChannels == 1) { if (m_nbChannels == 1) {
channelMap.push_back(airtalgo::channel_frontCenter); channelMap.push_back(audio::channel_frontCenter);
} else if (m_nbChannels == 2) { } else if (m_nbChannels == 2) {
channelMap.push_back(airtalgo::channel_frontLeft); channelMap.push_back(audio::channel_frontLeft);
channelMap.push_back(airtalgo::channel_frontRight); channelMap.push_back(audio::channel_frontRight);
} else if (m_nbChannels == 4) { } else if (m_nbChannels == 4) {
channelMap.push_back(airtalgo::channel_frontLeft); channelMap.push_back(audio::channel_frontLeft);
channelMap.push_back(airtalgo::channel_frontRight); channelMap.push_back(audio::channel_frontRight);
channelMap.push_back(airtalgo::channel_rearLeft); channelMap.push_back(audio::channel_rearLeft);
channelMap.push_back(airtalgo::channel_rearRight); channelMap.push_back(audio::channel_rearRight);
} else { } else {
APPL_ERROR("Can not generate with channel != 1,2,4"); APPL_ERROR("Can not generate with channel != 1,2,4");
return; return;
@ -378,12 +378,12 @@ class testOutCallbackType {
} }
void onDataNeeded(const std::chrono::system_clock::time_point& _playTime, void onDataNeeded(const std::chrono::system_clock::time_point& _playTime,
const size_t& _nbChunk, const size_t& _nbChunk,
const std::vector<airtalgo::channel>& _map, const std::vector<audio::channel>& _map,
void* _data, void* _data,
enum airtalgo::format _type) { enum audio::format _type) {
//APPL_DEBUG("Get data ... " << _type << " map=" << _map << " chunk=" << _nbChunk); //APPL_DEBUG("Get data ... " << _type << " map=" << _map << " chunk=" << _nbChunk);
double baseCycle = 2.0*M_PI/double(m_freq) * double(m_generateFreq); double baseCycle = 2.0*M_PI/double(m_freq) * double(m_generateFreq);
if (_type == airtalgo::format_int16) { if (_type == audio::format_int16) {
int16_t* data = static_cast<int16_t*>(_data); int16_t* data = static_cast<int16_t*>(_data);
for (int32_t iii=0; iii<_nbChunk; iii++) { for (int32_t iii=0; iii<_nbChunk; iii++) {
for (int32_t jjj=0; jjj<_map.size(); jjj++) { for (int32_t jjj=0; jjj<_map.size(); jjj++) {
@ -394,7 +394,7 @@ class testOutCallbackType {
m_phase -= 2*M_PI; m_phase -= 2*M_PI;
} }
} }
} else if (_type == airtalgo::format_int16_on_int32) { } else if (_type == audio::format_int16_on_int32) {
int32_t* data = static_cast<int32_t*>(_data); int32_t* data = static_cast<int32_t*>(_data);
for (int32_t iii=0; iii<_nbChunk; iii++) { for (int32_t iii=0; iii<_nbChunk; iii++) {
for (int32_t jjj=0; jjj<_map.size(); jjj++) { for (int32_t jjj=0; jjj<_map.size(); jjj++) {
@ -405,7 +405,7 @@ class testOutCallbackType {
m_phase -= 2*M_PI; m_phase -= 2*M_PI;
} }
} }
} else if (_type == airtalgo::format_int32) { } else if (_type == audio::format_int32) {
int32_t* data = static_cast<int32_t*>(_data); int32_t* data = static_cast<int32_t*>(_data);
for (int32_t iii=0; iii<_nbChunk; iii++) { for (int32_t iii=0; iii<_nbChunk; iii++) {
for (int32_t jjj=0; jjj<_map.size(); jjj++) { for (int32_t jjj=0; jjj<_map.size(); jjj++) {
@ -416,7 +416,7 @@ class testOutCallbackType {
m_phase -= 2*M_PI; m_phase -= 2*M_PI;
} }
} }
} else if (_type == airtalgo::format_float) { } else if (_type == audio::format_float) {
float* data = static_cast<float*>(_data); float* data = static_cast<float*>(_data);
for (int32_t iii=0; iii<_nbChunk; iii++) { for (int32_t iii=0; iii<_nbChunk; iii++) {
for (int32_t jjj=0; jjj<_map.size(); jjj++) { for (int32_t jjj=0; jjj<_map.size(); jjj++) {
@ -447,7 +447,7 @@ class testResampling : public ::testing::TestWithParam<float> {};
TEST_P(testResampling, base) { TEST_P(testResampling, base) {
std::shared_ptr<airtio::Manager> manager; std::shared_ptr<airtio::Manager> manager;
manager = airtio::Manager::create("testApplication"); manager = airtio::Manager::create("testApplication");
std::shared_ptr<testOutCallbackType> process = std::make_shared<testOutCallbackType>(manager, GetParam(), 2, airtalgo::format_int16); std::shared_ptr<testOutCallbackType> process = std::make_shared<testOutCallbackType>(manager, GetParam(), 2, audio::format_int16);
process->run(); process->run();
process.reset(); process.reset();
usleep(500000); usleep(500000);
@ -458,7 +458,7 @@ INSTANTIATE_TEST_CASE_P(InstantiationName,
::testing::Values(4000, 8000, 16000, 32000, 48000, 48001, 64000, 96000, 11250, 2250, 44100, 88200)); ::testing::Values(4000, 8000, 16000, 32000, 48000, 48001, 64000, 96000, 11250, 2250, 44100, 88200));
class testFormat : public ::testing::TestWithParam<airtalgo::format> {}; class testFormat : public ::testing::TestWithParam<audio::format> {};
TEST_P(testFormat, base) { TEST_P(testFormat, base) {
std::shared_ptr<airtio::Manager> manager; std::shared_ptr<airtio::Manager> manager;
manager = airtio::Manager::create("testApplication"); manager = airtio::Manager::create("testApplication");
@ -469,14 +469,14 @@ TEST_P(testFormat, base) {
} }
INSTANTIATE_TEST_CASE_P(InstantiationName, INSTANTIATE_TEST_CASE_P(InstantiationName,
testFormat, testFormat,
::testing::Values(airtalgo::format_int16, airtalgo::format_int16_on_int32, airtalgo::format_int32, airtalgo::format_float)); ::testing::Values(audio::format_int16, audio::format_int16_on_int32, audio::format_int32, audio::format_float));
class testChannels : public ::testing::TestWithParam<int32_t> {}; class testChannels : public ::testing::TestWithParam<int32_t> {};
TEST_P(testChannels, base) { TEST_P(testChannels, base) {
std::shared_ptr<airtio::Manager> manager; std::shared_ptr<airtio::Manager> manager;
manager = airtio::Manager::create("testApplication"); manager = airtio::Manager::create("testApplication");
std::shared_ptr<testOutCallbackType> process = std::make_shared<testOutCallbackType>(manager, 48000, GetParam(), airtalgo::format_int16); std::shared_ptr<testOutCallbackType> process = std::make_shared<testOutCallbackType>(manager, 48000, GetParam(), audio::format_int16);
process->run(); process->run();
process.reset(); process.reset();
usleep(500000); usleep(500000);
@ -497,12 +497,12 @@ class testCallbackVolume {
m_manager(_manager), m_manager(_manager),
m_phase(0) { m_phase(0) {
//Set stereo output: //Set stereo output:
std::vector<airtalgo::channel> channelMap; std::vector<audio::channel> channelMap;
channelMap.push_back(airtalgo::channel_frontLeft); channelMap.push_back(audio::channel_frontLeft);
channelMap.push_back(airtalgo::channel_frontRight); channelMap.push_back(audio::channel_frontRight);
m_interface = m_manager->createOutput(48000, m_interface = m_manager->createOutput(48000,
channelMap, channelMap,
airtalgo::format_int16, audio::format_int16,
"speaker", "speaker",
"WriteModeCallback"); "WriteModeCallback");
// set callback mode ... // set callback mode ...
@ -519,10 +519,10 @@ class testCallbackVolume {
} }
void onDataNeeded(const std::chrono::system_clock::time_point& _playTime, void onDataNeeded(const std::chrono::system_clock::time_point& _playTime,
const size_t& _nbChunk, const size_t& _nbChunk,
const std::vector<airtalgo::channel>& _map, const std::vector<audio::channel>& _map,
void* _data, void* _data,
enum airtalgo::format _type) { enum audio::format _type) {
if (_type != airtalgo::format_int16) { if (_type != audio::format_int16) {
APPL_ERROR("call wrong type ... (need int16_t)"); APPL_ERROR("call wrong type ... (need int16_t)");
} }
int16_t* data = static_cast<int16_t*>(_data); int16_t* data = static_cast<int16_t*>(_data);
@ -543,7 +543,6 @@ class testCallbackVolume {
m_interface->setParameter("volume", "FLOW", "-3dB"); m_interface->setParameter("volume", "FLOW", "-3dB");
APPL_INFO(" get volume : " << m_interface->getParameter("volume", "FLOW") ); APPL_INFO(" get volume : " << m_interface->getParameter("volume", "FLOW") );
usleep(500000); usleep(500000);
/*
m_interface->setParameter("volume", "FLOW", "-6dB"); m_interface->setParameter("volume", "FLOW", "-6dB");
APPL_INFO(" get volume : " << m_interface->getParameter("volume", "FLOW") ); APPL_INFO(" get volume : " << m_interface->getParameter("volume", "FLOW") );
usleep(500000); usleep(500000);
@ -556,14 +555,6 @@ class testCallbackVolume {
m_interface->setParameter("volume", "FLOW", "-3dB"); m_interface->setParameter("volume", "FLOW", "-3dB");
APPL_INFO(" get volume : " << m_interface->getParameter("volume", "FLOW") ); APPL_INFO(" get volume : " << m_interface->getParameter("volume", "FLOW") );
usleep(500000); usleep(500000);
*/
m_manager->setVolume("MASTER", -3.0f);
APPL_INFO("get volume MASTER: " << m_manager->getVolume("MASTER") );
usleep(500000);
m_manager->setVolume("MEDIA", -3.0f);
APPL_INFO("get volume MEDIA: " << m_manager->getVolume("MEDIA") );
usleep(500000);
/*
m_interface->setParameter("volume", "FLOW", "3dB"); m_interface->setParameter("volume", "FLOW", "3dB");
APPL_INFO(" get volume : " << m_interface->getParameter("volume", "FLOW") ); APPL_INFO(" get volume : " << m_interface->getParameter("volume", "FLOW") );
usleep(500000); usleep(500000);
@ -575,8 +566,13 @@ class testCallbackVolume {
usleep(500000); usleep(500000);
m_interface->setParameter("volume", "FLOW", "0dB"); m_interface->setParameter("volume", "FLOW", "0dB");
APPL_INFO(" get volume : " << m_interface->getParameter("volume", "FLOW") ); APPL_INFO(" get volume : " << m_interface->getParameter("volume", "FLOW") );
usleep(500000);
m_manager->setVolume("MASTER", -3.0f);
APPL_INFO("get volume MASTER: " << m_manager->getVolume("MASTER") );
usleep(500000);
m_manager->setVolume("MEDIA", -3.0f);
APPL_INFO("get volume MEDIA: " << m_manager->getVolume("MEDIA") );
usleep(1000000); usleep(1000000);
*/
m_interface->stop(); m_interface->stop();
} }
}; };
@ -612,11 +608,11 @@ TEST(TestALL, testChannelsFormatResampling) {
listChannel.push_back(1); listChannel.push_back(1);
listChannel.push_back(2); listChannel.push_back(2);
listChannel.push_back(4); listChannel.push_back(4);
std::vector<airtalgo::format> listFormat; std::vector<audio::format> listFormat;
listFormat.push_back(airtalgo::format_int16); listFormat.push_back(audio::format_int16);
listFormat.push_back(airtalgo::format_int16_on_int32); listFormat.push_back(audio::format_int16_on_int32);
listFormat.push_back(airtalgo::format_int32); listFormat.push_back(audio::format_int32);
listFormat.push_back(airtalgo::format_float); listFormat.push_back(audio::format_float);
for (auto &itFreq : listFreq) { for (auto &itFreq : listFreq) {
for (auto &itChannel : listChannel) { for (auto &itChannel : listChannel) {
for (auto &itFormat : listFormat) { for (auto &itFormat : listFormat) {