[DEV] add basic tools and change some API
This commit is contained in:
@@ -55,7 +55,7 @@ namespace audio {
|
||||
void setName(const std::string& _name) {
|
||||
m_name = _name;
|
||||
}
|
||||
virtual audio::orchestra::type getCurrentApi() = 0;
|
||||
virtual const std::string& getCurrentApi() = 0;
|
||||
virtual uint32_t getDeviceCount() = 0;
|
||||
virtual audio::orchestra::DeviceInfo getDeviceInfo(uint32_t _device) = 0;
|
||||
// TODO : Check API ...
|
||||
@@ -173,9 +173,5 @@ namespace audio {
|
||||
};
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief Debug operator To display the curent element in a Human redeable information
|
||||
*/
|
||||
std::ostream& operator <<(std::ostream& _os, const audio::orchestra::type& _obj);
|
||||
|
||||
#endif
|
||||
|
@@ -13,8 +13,8 @@
|
||||
#undef __class__
|
||||
#define __class__ "Interface"
|
||||
|
||||
std::vector<enum audio::orchestra::type> audio::orchestra::Interface::getCompiledApi() {
|
||||
std::vector<enum audio::orchestra::type> apis;
|
||||
std::vector<std::string> audio::orchestra::Interface::getListApi() {
|
||||
std::vector<std::string> apis;
|
||||
// The order here will control the order of RtAudio's API search in
|
||||
// the constructor.
|
||||
for (size_t iii=0; iii<m_apiAvaillable.size(); ++iii) {
|
||||
@@ -25,7 +25,7 @@ std::vector<enum audio::orchestra::type> audio::orchestra::Interface::getCompile
|
||||
|
||||
|
||||
|
||||
void audio::orchestra::Interface::openRtApi(enum audio::orchestra::type _api) {
|
||||
void audio::orchestra::Interface::openApi(const std::string& _api) {
|
||||
delete m_rtapi;
|
||||
m_rtapi = nullptr;
|
||||
for (size_t iii=0; iii<m_apiAvaillable.size(); ++iii) {
|
||||
@@ -47,61 +47,62 @@ audio::orchestra::Interface::Interface() :
|
||||
m_rtapi(nullptr) {
|
||||
ATA_DEBUG("Add interface:");
|
||||
#if defined(ORCHESTRA_BUILD_JACK)
|
||||
ATA_DEBUG(" JACK");
|
||||
addInterface(audio::orchestra::type_jack, audio::orchestra::api::Jack::create);
|
||||
#endif
|
||||
#if defined(ORCHESTRA_BUILD_ALSA)
|
||||
ATA_DEBUG(" ALSA");
|
||||
addInterface(audio::orchestra::type_alsa, audio::orchestra::api::Alsa::create);
|
||||
#endif
|
||||
#if defined(ORCHESTRA_BUILD_PULSE)
|
||||
ATA_DEBUG(" PULSE");
|
||||
addInterface(audio::orchestra::type_pulse, audio::orchestra::api::Pulse::create);
|
||||
#endif
|
||||
#if defined(ORCHESTRA_BUILD_OSS)
|
||||
ATA_DEBUG(" OSS");
|
||||
addInterface(audio::orchestra::type_oss, audio::orchestra::api::Oss::create);
|
||||
#endif
|
||||
#if defined(ORCHESTRA_BUILD_ASIO)
|
||||
ATA_DEBUG(" ASIO");
|
||||
addInterface(audio::orchestra::type_asio, audio::orchestra::api::Asio::create);
|
||||
#endif
|
||||
#if defined(ORCHESTRA_BUILD_DS)
|
||||
ATA_DEBUG(" DS");
|
||||
addInterface(audio::orchestra::type_ds, audio::orchestra::api::Ds::create);
|
||||
#endif
|
||||
#if defined(ORCHESTRA_BUILD_MACOSX_CORE)
|
||||
ATA_DEBUG(" CORE OSX");
|
||||
addInterface(audio::orchestra::type_coreOSX, audio::orchestra::api::Core::create);
|
||||
#endif
|
||||
#if defined(ORCHESTRA_BUILD_IOS_CORE)
|
||||
ATA_DEBUG(" CORE IOS");
|
||||
addInterface(audio::orchestra::type_coreIOS, audio::orchestra::api::CoreIos::create);
|
||||
#endif
|
||||
#if defined(ORCHESTRA_BUILD_JAVA)
|
||||
ATA_DEBUG(" JAVA");
|
||||
addInterface(audio::orchestra::type_java, audio::orchestra::api::Android::create);
|
||||
#endif
|
||||
#if defined(ORCHESTRA_BUILD_DUMMY)
|
||||
ATA_DEBUG(" DUMMY");
|
||||
addInterface(audio::orchestra::type_dummy, audio::orchestra::api::Dummy::create);
|
||||
#endif
|
||||
}
|
||||
|
||||
void audio::orchestra::Interface::addInterface(enum audio::orchestra::type _api, Api* (*_callbackCreate)()) {
|
||||
m_apiAvaillable.push_back(std::pair<enum audio::orchestra::type, Api* (*)()>(_api, _callbackCreate));
|
||||
void audio::orchestra::Interface::addInterface(const std::string& _api, Api* (*_callbackCreate)()) {
|
||||
m_apiAvaillable.push_back(std::pair<std::string, Api* (*)()>(_api, _callbackCreate));
|
||||
}
|
||||
|
||||
enum audio::orchestra::error audio::orchestra::Interface::instanciate(enum audio::orchestra::type _api) {
|
||||
enum audio::orchestra::error audio::orchestra::Interface::clear() {
|
||||
ATA_INFO("Clear API ...");
|
||||
if (m_rtapi == nullptr) {
|
||||
ATA_WARNING("Interface NOT started!");
|
||||
return audio::orchestra::error_none;
|
||||
}
|
||||
delete m_rtapi;
|
||||
m_rtapi = nullptr;
|
||||
return audio::orchestra::error_none;
|
||||
}
|
||||
|
||||
enum audio::orchestra::error audio::orchestra::Interface::instanciate(const std::string& _api) {
|
||||
ATA_INFO("Instanciate API ...");
|
||||
if (m_rtapi != nullptr) {
|
||||
ATA_WARNING("Interface already started ...!");
|
||||
ATA_WARNING("Interface already started!");
|
||||
return audio::orchestra::error_none;
|
||||
}
|
||||
if (_api != audio::orchestra::type_undefined) {
|
||||
ATA_INFO("API specified : " << _api);
|
||||
// Attempt to open the specified API.
|
||||
openRtApi(_api);
|
||||
openApi(_api);
|
||||
if (m_rtapi != nullptr) {
|
||||
if (m_rtapi->getDeviceCount() != 0) {
|
||||
ATA_INFO(" ==> api open");
|
||||
@@ -116,11 +117,11 @@ enum audio::orchestra::error audio::orchestra::Interface::instanciate(enum audio
|
||||
ATA_INFO("Auto choice API :");
|
||||
// Iterate through the compiled APIs and return as soon as we find
|
||||
// one with at least one device or we reach the end of the list.
|
||||
std::vector<enum audio::orchestra::type> apis = getCompiledApi();
|
||||
std::vector<std::string> apis = getListApi();
|
||||
ATA_INFO(" find : " << apis.size() << " apis.");
|
||||
for (size_t iii=0; iii<apis.size(); ++iii) {
|
||||
ATA_INFO("try open ...");
|
||||
openRtApi(apis[iii]);
|
||||
openApi(apis[iii]);
|
||||
if(m_rtapi == nullptr) {
|
||||
ATA_ERROR(" ==> can not create ...");
|
||||
continue;
|
||||
|
@@ -38,7 +38,7 @@ namespace audio {
|
||||
*/
|
||||
class Interface {
|
||||
protected:
|
||||
std::vector<std::pair<enum audio::orchestra::type, Api* (*)()> > m_apiAvaillable;
|
||||
std::vector<std::pair<std::string, Api* (*)()> > m_apiAvaillable;
|
||||
protected:
|
||||
audio::orchestra::Api *m_rtapi;
|
||||
public:
|
||||
@@ -50,13 +50,16 @@ namespace audio {
|
||||
m_rtapi->setName(_name);
|
||||
}
|
||||
/**
|
||||
* @brief A static function to determine the available compiled audio APIs.
|
||||
*
|
||||
* The values returned in the std::vector can be compared against
|
||||
* the enumerated list values. Note that there can be more than one
|
||||
* API compiled for certain operating systems.
|
||||
* @brief Get the list of all availlable API in the system.
|
||||
* @return the list of all APIs
|
||||
*/
|
||||
std::vector<enum audio::orchestra::type> getCompiledApi();
|
||||
std::vector<std::string> getListApi();
|
||||
/**
|
||||
* @brief Add an interface of the Possible List.
|
||||
* @param[in] _api Type of the interface.
|
||||
* @param[in] _callbackCreate API creation callback.
|
||||
*/
|
||||
void addInterface(const std::string& _api, Api* (*_callbackCreate)());
|
||||
/**
|
||||
* @brief The class constructor.
|
||||
* @note the creating of the basic instance is done by Instanciate
|
||||
@@ -70,19 +73,17 @@ namespace audio {
|
||||
*/
|
||||
virtual ~Interface();
|
||||
/**
|
||||
* @brief Add an interface of the Possible List.
|
||||
* @param[in] _api Type of the interface.
|
||||
* @param[in] _callbackCreate API creation callback.
|
||||
* @brief Clear the current Interface
|
||||
*/
|
||||
void addInterface(enum audio::orchestra::type _api, Api* (*_callbackCreate)());
|
||||
enum audio::orchestra::error clear();
|
||||
/**
|
||||
* @brief Create an interface instance
|
||||
*/
|
||||
enum audio::orchestra::error instanciate(enum audio::orchestra::type _api = audio::orchestra::type_undefined);
|
||||
enum audio::orchestra::error instanciate(const std::string& _api = audio::orchestra::type_undefined);
|
||||
/**
|
||||
* @return the audio API specifier for the current instance of airtaudio.
|
||||
*/
|
||||
enum audio::orchestra::type getCurrentApi() {
|
||||
const std::string& getCurrentApi() {
|
||||
if (m_rtapi == nullptr) {
|
||||
return audio::orchestra::type_undefined;
|
||||
}
|
||||
@@ -312,7 +313,7 @@ namespace audio {
|
||||
}
|
||||
bool isMasterOf(audio::orchestra::Interface& _interface);
|
||||
protected:
|
||||
void openRtApi(enum audio::orchestra::type _api);
|
||||
void openApi(const std::string& _api);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -18,7 +18,7 @@ namespace audio {
|
||||
public:
|
||||
Alsa();
|
||||
virtual ~Alsa();
|
||||
enum audio::orchestra::type getCurrentApi() {
|
||||
const std::string& getCurrentApi() {
|
||||
return audio::orchestra::type_alsa;
|
||||
}
|
||||
uint32_t getDeviceCount();
|
||||
|
@@ -17,7 +17,7 @@ namespace audio {
|
||||
public:
|
||||
Android();
|
||||
virtual ~Android();
|
||||
enum audio::orchestra::type getCurrentApi() {
|
||||
const std::string& getCurrentApi() {
|
||||
return audio::orchestra::type_java;
|
||||
}
|
||||
uint32_t getDeviceCount();
|
||||
|
@@ -18,7 +18,7 @@ namespace audio {
|
||||
public:
|
||||
Asio();
|
||||
virtual ~Asio();
|
||||
enum audio::orchestra::type getCurrentApi() {
|
||||
const std::string& getCurrentApi() {
|
||||
return audio::orchestra::WINDOWS_ASIO;
|
||||
}
|
||||
uint32_t getDeviceCount();
|
||||
|
@@ -21,7 +21,7 @@ namespace audio {
|
||||
public:
|
||||
Core();
|
||||
virtual ~Core();
|
||||
enum audio::orchestra::type getCurrentApi() {
|
||||
const std::string& getCurrentApi() {
|
||||
return audio::orchestra::type_coreOSX;
|
||||
}
|
||||
uint32_t getDeviceCount();
|
||||
|
@@ -19,7 +19,7 @@ namespace audio {
|
||||
public:
|
||||
CoreIos();
|
||||
virtual ~CoreIos();
|
||||
enum audio::orchestra::type getCurrentApi() {
|
||||
const std::string& getCurrentApi() {
|
||||
return audio::orchestra::type_coreIOS;
|
||||
}
|
||||
uint32_t getDeviceCount();
|
||||
|
@@ -19,7 +19,7 @@ namespace audio {
|
||||
public:
|
||||
Ds();
|
||||
virtual ~Ds();
|
||||
enum audio::orchestra::type getCurrentApi() {
|
||||
const std::string& getCurrentApi() {
|
||||
return audio::orchestra::type_ds;
|
||||
}
|
||||
uint32_t getDeviceCount();
|
||||
|
@@ -19,7 +19,7 @@ namespace audio {
|
||||
static audio::orchestra::Api* create();
|
||||
public:
|
||||
Dummy();
|
||||
enum audio::orchestra::type getCurrentApi() {
|
||||
const std::string& getCurrentApi() {
|
||||
return audio::orchestra::type_dummy;
|
||||
}
|
||||
uint32_t getDeviceCount();
|
||||
|
@@ -20,7 +20,7 @@ namespace audio {
|
||||
public:
|
||||
Jack();
|
||||
virtual ~Jack();
|
||||
enum audio::orchestra::type getCurrentApi() {
|
||||
const std::string& getCurrentApi() {
|
||||
return audio::orchestra::type_jack;
|
||||
}
|
||||
uint32_t getDeviceCount();
|
||||
|
@@ -19,7 +19,7 @@ namespace audio {
|
||||
public:
|
||||
Oss();
|
||||
virtual ~Oss();
|
||||
enum audio::orchestra::type getCurrentApi() {
|
||||
const std::string& getCurrentApi() {
|
||||
return audio::orchestra::type_oss;
|
||||
}
|
||||
uint32_t getDeviceCount();
|
||||
|
@@ -19,7 +19,7 @@ namespace audio {
|
||||
public:
|
||||
Pulse();
|
||||
virtual ~Pulse();
|
||||
enum audio::orchestra::type getCurrentApi() {
|
||||
const std::string& getCurrentApi() {
|
||||
return audio::orchestra::type_pulse;
|
||||
}
|
||||
uint32_t getDeviceCount();
|
||||
|
@@ -15,59 +15,14 @@
|
||||
#undef __class__
|
||||
#define __class__ "type"
|
||||
|
||||
static const char* listType[] = {
|
||||
"undefined",
|
||||
"alsa",
|
||||
"pulse",
|
||||
"oss",
|
||||
"jack",
|
||||
"coreOSX",
|
||||
"corIOS",
|
||||
"asio",
|
||||
"ds",
|
||||
"java",
|
||||
"dummy",
|
||||
"user1",
|
||||
"user2",
|
||||
"user3",
|
||||
"user4"
|
||||
};
|
||||
static int32_t listTypeSize = sizeof(listType)/sizeof(char*);
|
||||
|
||||
|
||||
std::ostream& audio::orchestra::operator <<(std::ostream& _os, const enum audio::orchestra::type& _obj) {
|
||||
_os << listType[_obj];
|
||||
return _os;
|
||||
}
|
||||
|
||||
std::ostream& audio::orchestra::operator <<(std::ostream& _os, const std::vector<enum audio::orchestra::type>& _obj) {
|
||||
_os << std::string("{");
|
||||
for (size_t iii=0; iii<_obj.size(); ++iii) {
|
||||
if (iii!=0) {
|
||||
_os << std::string(";");
|
||||
}
|
||||
_os << _obj[iii];
|
||||
}
|
||||
_os << std::string("}");
|
||||
return _os;
|
||||
}
|
||||
/*
|
||||
template <enum audio::format> std::string to_string(const enum audio::format& _variable) {
|
||||
return listType[_value];
|
||||
}
|
||||
*/
|
||||
std::string audio::orchestra::getTypeString(enum audio::orchestra::type _value) {
|
||||
return listType[_value];
|
||||
}
|
||||
|
||||
enum audio::orchestra::type audio::orchestra::getTypeFromString(const std::string& _value) {
|
||||
for (int32_t iii=0; iii<listTypeSize; ++iii) {
|
||||
if (_value == listType[iii]) {
|
||||
return static_cast<enum audio::orchestra::type>(iii);
|
||||
}
|
||||
}
|
||||
if (_value == "auto") {
|
||||
return audio::orchestra::type_undefined;
|
||||
}
|
||||
return audio::orchestra::type_undefined;
|
||||
}
|
||||
const std::string audio::orchestra::type_undefined = "undefined";
|
||||
const std::string audio::orchestra::type_alsa = "alsa";
|
||||
const std::string audio::orchestra::type_pulse = "pulse";
|
||||
const std::string audio::orchestra::type_oss = "oss";
|
||||
const std::string audio::orchestra::type_jack = "jack";
|
||||
const std::string audio::orchestra::type_coreOSX = "coreOSX";
|
||||
const std::string audio::orchestra::type_coreIOS = "coreIOS";
|
||||
const std::string audio::orchestra::type_asio = "asio";
|
||||
const std::string audio::orchestra::type_ds = "ds";
|
||||
const std::string audio::orchestra::type_java = "java";
|
||||
const std::string audio::orchestra::type_dummy = "dummy";
|
||||
|
@@ -17,27 +17,17 @@ namespace audio {
|
||||
/**
|
||||
* @brief Audio API specifier arguments.
|
||||
*/
|
||||
enum type {
|
||||
type_undefined, //!< Error API.
|
||||
type_alsa, //!< LINUX The Advanced Linux Sound Architecture.
|
||||
type_pulse, //!< LINUX The Linux PulseAudio.
|
||||
type_oss, //!< LINUX The Linux Open Sound System.
|
||||
type_jack, //!< UNIX The Jack Low-Latency Audio Server.
|
||||
type_coreOSX, //!< Macintosh OSX Core Audio.
|
||||
type_coreIOS, //!< Macintosh iOS Core Audio.
|
||||
type_asio, //!< WINDOWS The Steinberg Audio Stream I/O.
|
||||
type_ds, //!< WINDOWS The Microsoft Direct Sound.
|
||||
type_java, //!< ANDROID Interface.
|
||||
type_dummy, //!< Empty wrapper (non-functional).
|
||||
type_user1, //!< User interface 1.
|
||||
type_user2, //!< User interface 2.
|
||||
type_user3, //!< User interface 3.
|
||||
type_user4, //!< User interface 4.
|
||||
};
|
||||
std::ostream& operator <<(std::ostream& _os, const enum audio::orchestra::type& _obj);
|
||||
std::ostream& operator <<(std::ostream& _os, const std::vector<enum audio::orchestra::type>& _obj);
|
||||
std::string getTypeString(enum audio::orchestra::type _value);
|
||||
enum audio::orchestra::type getTypeFromString(const std::string& _value);
|
||||
extern const std::string type_undefined; //!< Error API.
|
||||
extern const std::string type_alsa; //!< LINUX The Advanced Linux Sound Architecture.
|
||||
extern const std::string type_pulse; //!< LINUX The Linux PulseAudio.
|
||||
extern const std::string type_oss; //!< LINUX The Linux Open Sound System.
|
||||
extern const std::string type_jack; //!< UNIX The Jack Low-Latency Audio Server.
|
||||
extern const std::string type_coreOSX; //!< Macintosh OSX Core Audio.
|
||||
extern const std::string type_coreIOS; //!< Macintosh iOS Core Audio.
|
||||
extern const std::string type_asio; //!< WINDOWS The Steinberg Audio Stream I/O.
|
||||
extern const std::string type_ds; //!< WINDOWS The Microsoft Direct Sound.
|
||||
extern const std::string type_java; //!< ANDROID Interface.
|
||||
extern const std::string type_dummy; //!< Empty wrapper (non-functional).
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user