diff --git a/audio/orchestra/Api.h b/audio/orchestra/Api.h index 06f44b2..4032f7a 100644 --- a/audio/orchestra/Api.h +++ b/audio/orchestra/Api.h @@ -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 diff --git a/audio/orchestra/Interface.cpp b/audio/orchestra/Interface.cpp index 2cb5204..d57158a 100644 --- a/audio/orchestra/Interface.cpp +++ b/audio/orchestra/Interface.cpp @@ -13,8 +13,8 @@ #undef __class__ #define __class__ "Interface" -std::vector audio::orchestra::Interface::getCompiledApi() { - std::vector apis; +std::vector audio::orchestra::Interface::getListApi() { + std::vector apis; // The order here will control the order of RtAudio's API search in // the constructor. for (size_t iii=0; iii 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(_api, _callbackCreate)); +void audio::orchestra::Interface::addInterface(const std::string& _api, Api* (*_callbackCreate)()) { + m_apiAvaillable.push_back(std::pair(_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 apis = getCompiledApi(); + std::vector apis = getListApi(); ATA_INFO(" find : " << apis.size() << " apis."); for (size_t iii=0; iii can not create ..."); continue; diff --git a/audio/orchestra/Interface.h b/audio/orchestra/Interface.h index b1b84ec..6a7f0eb 100644 --- a/audio/orchestra/Interface.h +++ b/audio/orchestra/Interface.h @@ -38,7 +38,7 @@ namespace audio { */ class Interface { protected: - std::vector > m_apiAvaillable; + std::vector > 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 getCompiledApi(); + std::vector 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); }; } } diff --git a/audio/orchestra/api/Alsa.h b/audio/orchestra/api/Alsa.h index df06c72..a1380c1 100644 --- a/audio/orchestra/api/Alsa.h +++ b/audio/orchestra/api/Alsa.h @@ -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(); diff --git a/audio/orchestra/api/Android.h b/audio/orchestra/api/Android.h index 756f58f..b390d73 100644 --- a/audio/orchestra/api/Android.h +++ b/audio/orchestra/api/Android.h @@ -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(); diff --git a/audio/orchestra/api/Asio.h b/audio/orchestra/api/Asio.h index cebc2bf..f42526d 100644 --- a/audio/orchestra/api/Asio.h +++ b/audio/orchestra/api/Asio.h @@ -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(); diff --git a/audio/orchestra/api/Core.h b/audio/orchestra/api/Core.h index 5ed4bd9..7791d61 100644 --- a/audio/orchestra/api/Core.h +++ b/audio/orchestra/api/Core.h @@ -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(); diff --git a/audio/orchestra/api/CoreIos.h b/audio/orchestra/api/CoreIos.h index 2b5142c..3c16b70 100644 --- a/audio/orchestra/api/CoreIos.h +++ b/audio/orchestra/api/CoreIos.h @@ -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(); diff --git a/audio/orchestra/api/Ds.h b/audio/orchestra/api/Ds.h index 155a88c..e2bd8e1 100644 --- a/audio/orchestra/api/Ds.h +++ b/audio/orchestra/api/Ds.h @@ -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(); diff --git a/audio/orchestra/api/Dummy.h b/audio/orchestra/api/Dummy.h index e83f756..79f22bf 100644 --- a/audio/orchestra/api/Dummy.h +++ b/audio/orchestra/api/Dummy.h @@ -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(); diff --git a/audio/orchestra/api/Jack.h b/audio/orchestra/api/Jack.h index 3f0683a..ea250c2 100644 --- a/audio/orchestra/api/Jack.h +++ b/audio/orchestra/api/Jack.h @@ -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(); diff --git a/audio/orchestra/api/Oss.h b/audio/orchestra/api/Oss.h index cf7f00d..aef3821 100644 --- a/audio/orchestra/api/Oss.h +++ b/audio/orchestra/api/Oss.h @@ -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(); diff --git a/audio/orchestra/api/Pulse.h b/audio/orchestra/api/Pulse.h index 7748175..857a78b 100644 --- a/audio/orchestra/api/Pulse.h +++ b/audio/orchestra/api/Pulse.h @@ -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(); diff --git a/audio/orchestra/type.cpp b/audio/orchestra/type.cpp index 1fe33f9..1b9bfb7 100644 --- a/audio/orchestra/type.cpp +++ b/audio/orchestra/type.cpp @@ -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& _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 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(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"; diff --git a/audio/orchestra/type.h b/audio/orchestra/type.h index 31cfa6c..8f04ff2 100644 --- a/audio/orchestra/type.h +++ b/audio/orchestra/type.h @@ -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& _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). } } diff --git a/lutin_audio_orchestra.py b/lutin_audio_orchestra.py index ab6b2a3..19b4ffa 100644 --- a/lutin_audio_orchestra.py +++ b/lutin_audio_orchestra.py @@ -4,7 +4,7 @@ import lutin.tools as tools import lutin.debug as debug def get_desc(): - return "audio_orchestra : Generic wrapper on all audio interface" + return "Generic wrapper on all audio interface" def create(target): @@ -71,7 +71,6 @@ def create(target): myModule.add_export_path(tools.get_current_path(__file__)) - # add the currrent module at the return myModule diff --git a/tools/lutin_orchestra-in.py b/tools/lutin_orchestra-in.py new file mode 100644 index 0000000..dbb8828 --- /dev/null +++ b/tools/lutin_orchestra-in.py @@ -0,0 +1,19 @@ +#!/usr/bin/python +import lutin.module as module +import lutin.tools as tools +import lutin.debug as debug + +def get_desc(): + return "'in' tool for orchestra" + + +def create(target): + myModule = module.Module(__file__, 'orchestra-in', 'BINARY') + + myModule.add_src_file([ + 'orchestra-in.cpp' + ]) + myModule.add_module_depend(['audio_orchestra', 'test-debug']) + return myModule + + diff --git a/tools/lutin_orchestra-list.py b/tools/lutin_orchestra-list.py new file mode 100644 index 0000000..540643e --- /dev/null +++ b/tools/lutin_orchestra-list.py @@ -0,0 +1,19 @@ +#!/usr/bin/python +import lutin.module as module +import lutin.tools as tools +import lutin.debug as debug + +def get_desc(): + return "'list' i/o tool for orchestra" + + +def create(target): + myModule = module.Module(__file__, 'orchestra-list', 'BINARY') + + myModule.add_src_file([ + 'orchestra-list.cpp' + ]) + myModule.add_module_depend(['audio_orchestra', 'test-debug']) + return myModule + + diff --git a/tools/lutin_orchestra-out.py b/tools/lutin_orchestra-out.py new file mode 100644 index 0000000..247b8a7 --- /dev/null +++ b/tools/lutin_orchestra-out.py @@ -0,0 +1,19 @@ +#!/usr/bin/python +import lutin.module as module +import lutin.tools as tools +import lutin.debug as debug + +def get_desc(): + return "'out' tool for orchestra" + + +def create(target): + myModule = module.Module(__file__, 'orchestra-out', 'BINARY') + + myModule.add_src_file([ + 'orchestra-out.cpp' + ]) + myModule.add_module_depend(['audio_orchestra', 'test-debug']) + return myModule + + diff --git a/tools/orchestra-in.cpp b/tools/orchestra-in.cpp new file mode 100644 index 0000000..e69de29 diff --git a/tools/orchestra-list.cpp b/tools/orchestra-list.cpp new file mode 100644 index 0000000..5dbb010 --- /dev/null +++ b/tools/orchestra-list.cpp @@ -0,0 +1,39 @@ +/** @file + * @author Edouard DUPIN + * @copyright 2015, Edouard DUPIN, all right reserved + * @license APACHE v2.0 (see license file) + */ + +#include +#include +#include +#include