[DEV] better connection of default device

This commit is contained in:
Edouard DUPIN 2015-02-26 21:44:16 +01:00
parent e822d13209
commit ec75a59720
2 changed files with 23 additions and 40 deletions

View File

@ -231,24 +231,6 @@ void river::io::NodeAEC::stop() {
} }
} }
namespace std {
static std::ostream& operator <<(std::ostream& _os, const std11::chrono::system_clock::time_point& _obj) {
std11::chrono::nanoseconds ns = std11::chrono::duration_cast<std11::chrono::nanoseconds>(_obj.time_since_epoch());
int64_t totalSecond = ns.count()/1000000000;
int64_t millisecond = (ns.count()%1000000000)/1000000;
int64_t microsecond = (ns.count()%1000000)/1000;
int64_t nanosecond = ns.count()%1000;
//_os << totalSecond << "s " << millisecond << "ms " << microsecond << "µs " << nanosecond << "ns";
int32_t second = totalSecond % 60;
int32_t minute = (totalSecond/60)%60;
int32_t hour = (totalSecond/3600)%24;
int32_t day = (totalSecond/(24*3600))%365;
int32_t year = totalSecond/(24*3600*365);
_os << year << "y " << day << "d " << hour << "h" << minute << ":"<< second << "s " << millisecond << "ms " << microsecond << "µs " << nanosecond << "ns";
return _os;
}
}
#define SAVE_FILE_MACRO(type,fileName,dataPointer,nbElement) \ #define SAVE_FILE_MACRO(type,fileName,dataPointer,nbElement) \
do { \ do { \
static FILE *pointerOnFile = nullptr; \ static FILE *pointerOnFile = nullptr; \

View File

@ -23,15 +23,6 @@ static std::string asString(const std11::chrono::system_clock::time_point& tp) {
return ts; return ts;
} }
namespace std {
static std::ostream& operator <<(std::ostream& _os, const std11::chrono::system_clock::time_point& _obj) {
std11::chrono::microseconds us = std11::chrono::duration_cast<std11::chrono::microseconds>(_obj.time_since_epoch());
_os << us.count();
return _os;
}
}
int32_t river::io::NodeAirTAudio::duplexCallback(const void* _inputBuffer, int32_t river::io::NodeAirTAudio::duplexCallback(const void* _inputBuffer,
const std11::chrono::system_clock::time_point& _timeInput, const std11::chrono::system_clock::time_point& _timeInput,
void* _outputBuffer, void* _outputBuffer,
@ -118,30 +109,40 @@ river::io::NodeAirTAudio::NodeAirTAudio(const std::string& _name, const std11::s
RIVER_INFO(" m_map=" << hardwareFormat.getMap()); RIVER_INFO(" m_map=" << hardwareFormat.getMap());
RIVER_INFO(" m_format=" << hardwareFormat.getFormat()); RIVER_INFO(" m_format=" << hardwareFormat.getFormat());
RIVER_INFO(" m_isInput=" << m_isInput); RIVER_INFO(" m_isInput=" << m_isInput);
int32_t deviceId = 0; int32_t deviceId = -1;
// TODO : Remove this from here (create an extern interface ...)
RIVER_INFO("Device list:"); RIVER_INFO("Device list:");
for (int32_t iii=0; iii<m_adac.getDeviceCount(); ++iii) { for (int32_t iii=0; iii<m_adac.getDeviceCount(); ++iii) {
m_info = m_adac.getDeviceInfo(iii); m_info = m_adac.getDeviceInfo(iii);
RIVER_INFO(" " << iii << " name :" << m_info.name); RIVER_INFO(" " << iii << " name :" << m_info.name);
if (m_info.name == streamName) { m_info.display(2);
RIVER_INFO(" Select ..."); }
deviceId = iii; // special case for default IO:
if (streamName == "default") {
if (m_isInput == true) {
deviceId = m_adac.getDefaultInputDevice();
} else {
deviceId = m_adac.getDefaultOutputDevice();
} }
} else {
for (int32_t iii=0; iii<m_adac.getDeviceCount(); ++iii) {
m_info = m_adac.getDeviceInfo(iii);
if (m_info.name == streamName) {
RIVER_INFO(" Select ... id =" << iii);
deviceId = iii;
}
}
}
if (deviceId == -1) {
RIVER_ERROR("Can not find the " << streamName << " audio interface ... (use O default ...)");
deviceId = 0;
} }
// Open specific ID : // Open specific ID :
m_info = m_adac.getDeviceInfo(deviceId); m_info = m_adac.getDeviceInfo(deviceId);
// display property : // display property :
{ {
RIVER_INFO("Device " << deviceId << " property :"); RIVER_INFO("Device " << deviceId << " property :");
RIVER_INFO(" probe=" << m_info.probed); m_info.display();
RIVER_INFO(" name=" << m_info.name);
RIVER_INFO(" outputChannels=" << m_info.outputChannels);
RIVER_INFO(" inputChannels=" << m_info.inputChannels);
RIVER_INFO(" duplexChannels=" << m_info.duplexChannels);
RIVER_INFO(" isDefaultOutput=" << m_info.isDefaultOutput);
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) { if (etk::isIn(hardwareFormat.getFormat(), m_info.nativeFormats) == false) {
if (type == "auto") { if (type == "auto") {