[DEV] add default file json
This commit is contained in:
parent
4879bd00fb
commit
bc37e70e1e
@ -16,6 +16,23 @@
|
||||
#undef __class__
|
||||
#define __class__ "Manager"
|
||||
|
||||
static std::string basicAutoConfig =
|
||||
"{\n"
|
||||
" microphone:{\n"
|
||||
" io:'input',\n"
|
||||
" map-on:'microphone',\n"
|
||||
" resampling-type:'speexdsp',\n"
|
||||
" resampling-option:'quality=10'\n"
|
||||
" },\n"
|
||||
" speaker:{\n"
|
||||
" io:'output',\n"
|
||||
" map-on:'speaker',\n"
|
||||
" resampling-type:'speexdsp',\n"
|
||||
" resampling-option:'quality=10'\n"
|
||||
" }\n"
|
||||
"}\n";
|
||||
|
||||
|
||||
std::shared_ptr<river::Manager> river::Manager::create(const std::string& _applicationUniqueId) {
|
||||
return std::shared_ptr<river::Manager>(new river::Manager(_applicationUniqueId));
|
||||
}
|
||||
@ -25,7 +42,8 @@ river::Manager::Manager(const std::string& _applicationUniqueId) :
|
||||
m_listOpenInterface() {
|
||||
// TODO : Maybe create a single interface property (and all get the same ...)
|
||||
if (m_config.load("DATA:virtual.json") == false) {
|
||||
RIVER_ERROR("you must set a basic configuration file for virtual configuration: DATA:virtual.json");
|
||||
RIVER_WARNING("you must set a basic configuration file for virtual configuration: DATA:virtual.json (load default interface)");
|
||||
m_config.parse(basicAutoConfig);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,9 +12,44 @@
|
||||
#undef __class__
|
||||
#define __class__ "io::Manager"
|
||||
|
||||
|
||||
static std::string basicAutoConfig =
|
||||
"{\n"
|
||||
" microphone:{\n"
|
||||
" io:'input',\n"
|
||||
" map-on:{\n"
|
||||
" interface:'auto',\n"
|
||||
" name:'default',\n"
|
||||
" },\n"
|
||||
" frequency:0,\n"
|
||||
" channel-map:[\n"
|
||||
" 'front-left', 'front-right'\n"
|
||||
" ],\n"
|
||||
" type:'auto',\n"
|
||||
" nb-chunk:1024\n"
|
||||
" },\n"
|
||||
" speaker:{\n"
|
||||
" io:'output',\n"
|
||||
" map-on:{\n"
|
||||
" interface:'auto',\n"
|
||||
" name:'default',\n"
|
||||
" },\n"
|
||||
" frequency:0,\n"
|
||||
" channel-map:[\n"
|
||||
" 'front-left', 'front-right',\n"
|
||||
" ],\n"
|
||||
" type:'auto',\n"
|
||||
" nb-chunk:1024,\n"
|
||||
" volume-name:'MASTER'\n"
|
||||
" }\n"
|
||||
"}\n";
|
||||
|
||||
|
||||
|
||||
river::io::Manager::Manager() {
|
||||
if (m_config.load("DATA:hardware.json") == false) {
|
||||
RIVER_ERROR("you must set a basic configuration file for harware configuration: DATA:hardware.json");
|
||||
RIVER_WARNING("you must set a basic configuration file for harware configuration: DATA:hardware.json (load default interface)");
|
||||
m_config.parse(basicAutoConfig);
|
||||
}
|
||||
// TODO : Load virtual.json and check if all is correct ...
|
||||
};
|
||||
|
@ -150,13 +150,13 @@ river::io::Node::Node(const std::string& _name, const std::shared_ptr<const ejso
|
||||
std::string streamName = "default";
|
||||
const std::shared_ptr<const ejson::Object> tmpObject = m_config->getObject("map-on");
|
||||
if (tmpObject == nullptr) {
|
||||
RIVER_WARNING("missing node : 'map-on' ==> auto map : 'alsa:default'");
|
||||
RIVER_WARNING("missing node : 'map-on' ==> auto map : 'auto:default'");
|
||||
} else {
|
||||
std::string value = tmpObject->getStringValue("interface", "default");
|
||||
typeInterface = airtaudio::getTypeFromString(value);
|
||||
streamName = tmpObject->getStringValue("name", "default");
|
||||
}
|
||||
int32_t frequency = m_config->getNumberValue("frequency", 48000);
|
||||
int32_t frequency = m_config->getNumberValue("frequency", 1);
|
||||
std::string type = m_config->getStringValue("type", "int16");
|
||||
int32_t nbChunk = m_config->getNumberValue("nb-chunk", 1024);
|
||||
std::string volumeName = m_config->getStringValue("volume-name", "");
|
||||
@ -222,13 +222,57 @@ river::io::Node::Node(const std::string& _name, const std::shared_ptr<const ejso
|
||||
RIVER_INFO(" isDefaultInput=" << m_info.isDefaultInput);
|
||||
RIVER_INFO(" rates=" << m_info.sampleRates);
|
||||
RIVER_INFO(" native Format: " << m_info.nativeFormats);
|
||||
|
||||
if (etk::isIn(hardwareFormat.getFormat(), m_info.nativeFormats) == false) {
|
||||
RIVER_CRITICAL("Can not manage input transforamtion: " << hardwareFormat.getFormat() << " not in " << m_info.nativeFormats);
|
||||
// TODO : Manage this
|
||||
if (type == "auto") {
|
||||
if (etk::isIn(audio::format_int16, m_info.nativeFormats) == true) {
|
||||
hardwareFormat.setFormat(audio::format_int16);
|
||||
RIVER_INFO("auto set format: " << hardwareFormat.getFormat());
|
||||
} else if (etk::isIn(audio::format_float, m_info.nativeFormats) == true) {
|
||||
hardwareFormat.setFormat(audio::format_float);
|
||||
RIVER_INFO("auto set format: " << hardwareFormat.getFormat());
|
||||
} else if (etk::isIn(audio::format_int16_on_int32, m_info.nativeFormats) == true) {
|
||||
hardwareFormat.setFormat(audio::format_int16_on_int32);
|
||||
RIVER_INFO("auto set format: " << hardwareFormat.getFormat());
|
||||
} else if (etk::isIn(audio::format_int24, m_info.nativeFormats) == true) {
|
||||
hardwareFormat.setFormat(audio::format_int24);
|
||||
RIVER_INFO("auto set format: " << hardwareFormat.getFormat());
|
||||
} else if (m_info.nativeFormats.size() != 0) {
|
||||
hardwareFormat.setFormat(m_info.nativeFormats[0]);
|
||||
RIVER_INFO("auto set format: " << hardwareFormat.getFormat());
|
||||
} else {
|
||||
RIVER_CRITICAL("auto set format no element in the configuration: " << m_info.nativeFormats);
|
||||
}
|
||||
} else {
|
||||
RIVER_CRITICAL("Can not manage input transforamtion: " << hardwareFormat.getFormat() << " not in " << m_info.nativeFormats);
|
||||
}
|
||||
}
|
||||
if (etk::isIn(hardwareFormat.getFrequency(), m_info.sampleRates) == false) {
|
||||
RIVER_CRITICAL("Can not manage input transforamtion:" << hardwareFormat.getFrequency() << " not in " << m_info.sampleRates);
|
||||
// TODO : Manage this
|
||||
if (etk::isIn(48000, m_info.sampleRates) == true) {
|
||||
hardwareFormat.setFrequency(48000);
|
||||
RIVER_INFO("auto set frequency: " << hardwareFormat.getFrequency());
|
||||
} else if (etk::isIn(44100, m_info.sampleRates) == true) {
|
||||
hardwareFormat.setFrequency(44100);
|
||||
RIVER_INFO("auto set frequency: " << hardwareFormat.getFrequency());
|
||||
} else if (etk::isIn(32000, m_info.sampleRates) == true) {
|
||||
hardwareFormat.setFrequency(32000);
|
||||
RIVER_INFO("auto set frequency: " << hardwareFormat.getFrequency());
|
||||
} else if (etk::isIn(16000, m_info.sampleRates) == true) {
|
||||
hardwareFormat.setFrequency(16000);
|
||||
RIVER_INFO("auto set frequency: " << hardwareFormat.getFrequency());
|
||||
} else if (etk::isIn(8000, m_info.sampleRates) == true) {
|
||||
hardwareFormat.setFrequency(8000);
|
||||
RIVER_INFO("auto set frequency: " << hardwareFormat.getFrequency());
|
||||
} else if (etk::isIn(96000, m_info.sampleRates) == true) {
|
||||
hardwareFormat.setFrequency(96000);
|
||||
RIVER_INFO("auto set frequency: " << hardwareFormat.getFrequency());
|
||||
} else if (m_info.sampleRates.size() != 0) {
|
||||
hardwareFormat.setFrequency(m_info.sampleRates[0]);
|
||||
RIVER_INFO("auto set frequency: " << hardwareFormat.getFrequency() << "(first element in list) in " << m_info.sampleRates);
|
||||
} else {
|
||||
RIVER_CRITICAL("Can not manage input transforamtion:" << hardwareFormat.getFrequency() << " not in " << m_info.sampleRates);
|
||||
}
|
||||
interfaceFormat.setFrequency(hardwareFormat.getFrequency());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user