[DEV] start compleate rework
This commit is contained in:
parent
3629886590
commit
7c6a495d86
@ -17,32 +17,32 @@
|
|||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "api"
|
#define __class__ "api"
|
||||||
|
|
||||||
|
static const char* listType[] {
|
||||||
|
"undefined",
|
||||||
|
"alsa",
|
||||||
|
"pulse",
|
||||||
|
"oss",
|
||||||
|
"jack",
|
||||||
|
"coreOSX",
|
||||||
|
"corIOS",
|
||||||
|
"asio",
|
||||||
|
"ds",
|
||||||
|
"java",
|
||||||
|
"dummy",
|
||||||
|
"user1",
|
||||||
|
"user2",
|
||||||
|
"user3",
|
||||||
|
"user4"
|
||||||
|
};
|
||||||
|
|
||||||
std::ostream& operator <<(std::ostream& _os, const airtaudio::api::type& _obj){
|
std::ostream& operator <<(std::ostream& _os, const airtaudio::type& _obj){
|
||||||
switch (_obj) {
|
_os << listType[_obj];
|
||||||
default:
|
|
||||||
case airtaudio::api::UNSPECIFIED: _os << "UNSPECIFIED"; break;
|
|
||||||
case airtaudio::api::LINUX_ALSA: _os << "LINUX_ALSA"; break;
|
|
||||||
case airtaudio::api::LINUX_PULSE: _os << "LINUX_PULSE"; break;
|
|
||||||
case airtaudio::api::LINUX_OSS: _os << "LINUX_OSS"; break;
|
|
||||||
case airtaudio::api::UNIX_JACK: _os << "UNIX_JACK"; break;
|
|
||||||
case airtaudio::api::MACOSX_CORE: _os << "MACOSX_CORE"; break;
|
|
||||||
case airtaudio::api::IOS_CORE: _os << "IOS_CORE"; break;
|
|
||||||
case airtaudio::api::WINDOWS_ASIO: _os << "WINDOWS_ASIO"; break;
|
|
||||||
case airtaudio::api::WINDOWS_DS: _os << "WINDOWS_DS"; break;
|
|
||||||
case airtaudio::api::RTAUDIO_DUMMY: _os << "RTAUDIO_DUMMY"; break;
|
|
||||||
case airtaudio::api::ANDROID_JAVA: _os << "ANDROID_JAVA"; break;
|
|
||||||
case airtaudio::api::USER_INTERFACE_1: _os << "USER_INTERFACE_1"; break;
|
|
||||||
case airtaudio::api::USER_INTERFACE_2: _os << "USER_INTERFACE_2"; break;
|
|
||||||
case airtaudio::api::USER_INTERFACE_3: _os << "USER_INTERFACE_3"; break;
|
|
||||||
case airtaudio::api::USER_INTERFACE_4: _os << "USER_INTERFACE_4"; break;
|
|
||||||
}
|
|
||||||
return _os;
|
return _os;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Static variable definitions.
|
// Static variable definitions.
|
||||||
const uint32_t airtaudio::api::MAX_SAMPLE_RATES = 14;
|
static const uint32_t MAX_SAMPLE_RATES = 14;
|
||||||
const uint32_t airtaudio::api::SAMPLE_RATES[] = {
|
static const uint32_t SAMPLE_RATES[] = {
|
||||||
4000,
|
4000,
|
||||||
5512,
|
5512,
|
||||||
8000,
|
8000,
|
||||||
@ -61,8 +61,8 @@ const uint32_t airtaudio::api::SAMPLE_RATES[] = {
|
|||||||
|
|
||||||
|
|
||||||
airtaudio::Api::Api() {
|
airtaudio::Api::Api() {
|
||||||
m_stream.state = airtaudio::api::STREAM_CLOSED;
|
m_stream.state = airtaudio::state_closed;
|
||||||
m_stream.mode = airtaudio::api::UNINITIALIZED;
|
m_stream.mode = airtaudio::mode_unknow;
|
||||||
m_stream.apiHandle = 0;
|
m_stream.apiHandle = 0;
|
||||||
m_stream.userBuffer[0] = 0;
|
m_stream.userBuffer[0] = 0;
|
||||||
m_stream.userBuffer[1] = 0;
|
m_stream.userBuffer[1] = 0;
|
||||||
@ -74,7 +74,7 @@ airtaudio::Api::~Api() {
|
|||||||
|
|
||||||
enum airtaudio::errorType airtaudio::Api::openStream(airtaudio::StreamParameters *oParams,
|
enum airtaudio::errorType airtaudio::Api::openStream(airtaudio::StreamParameters *oParams,
|
||||||
airtaudio::StreamParameters *iParams,
|
airtaudio::StreamParameters *iParams,
|
||||||
audio::format format,
|
enum audio::format format,
|
||||||
uint32_t sampleRate,
|
uint32_t sampleRate,
|
||||||
uint32_t *bufferFrames,
|
uint32_t *bufferFrames,
|
||||||
airtaudio::AirTAudioCallback callback,
|
airtaudio::AirTAudioCallback callback,
|
||||||
|
133
airtaudio/Api.h
133
airtaudio/Api.h
@ -13,61 +13,58 @@
|
|||||||
#include <airtaudio/debug.h>
|
#include <airtaudio/debug.h>
|
||||||
|
|
||||||
namespace airtaudio {
|
namespace airtaudio {
|
||||||
namespace api {
|
/**
|
||||||
/**
|
* @brief Audio API specifier arguments.
|
||||||
* @brief Audio API specifier arguments.
|
*/
|
||||||
*/
|
enum type {
|
||||||
enum type {
|
type_undefined, //!< Error API.
|
||||||
UNSPECIFIED, //!< Search for a working compiled API.
|
type_alsa, //!< LINUX The Advanced Linux Sound Architecture.
|
||||||
LINUX_ALSA, //!< The Advanced Linux Sound Architecture API.
|
type_pulse, //!< LINUX The Linux PulseAudio.
|
||||||
LINUX_PULSE, //!< The Linux PulseAudio API.
|
type_oss, //!< LINUX The Linux Open Sound System.
|
||||||
LINUX_OSS, //!< The Linux Open Sound System API.
|
type_jack, //!< UNIX The Jack Low-Latency Audio Server.
|
||||||
UNIX_JACK, //!< The Jack Low-Latency Audio Server API.
|
type_coreOSX, //!< Macintosh OSX Core Audio.
|
||||||
MACOSX_CORE, //!< Macintosh OS-X Core Audio API.
|
type_coreIOS, //!< Macintosh iOS Core Audio.
|
||||||
IOS_CORE, //!< Macintosh OS-X Core Audio API.
|
type_asio, //!< WINDOWS The Steinberg Audio Stream I/O.
|
||||||
WINDOWS_ASIO, //!< The Steinberg Audio Stream I/O API.
|
type_ds, //!< WINDOWS The Microsoft Direct Sound.
|
||||||
WINDOWS_DS, //!< The Microsoft Direct Sound API.
|
type_java, //!< ANDROID Interface.
|
||||||
RTAUDIO_DUMMY, //!< A compilable but non-functional API.
|
type_dummy, //!< Empty wrapper (non-functional).
|
||||||
ANDROID_JAVA, //!< Android Interface.
|
type_user1, //!< User interface 1.
|
||||||
USER_INTERFACE_1, //!< User interface 1.
|
type_user2, //!< User interface 2.
|
||||||
USER_INTERFACE_2, //!< User interface 2.
|
type_user3, //!< User interface 3.
|
||||||
USER_INTERFACE_3, //!< User interface 3.
|
type_user4, //!< User interface 4.
|
||||||
USER_INTERFACE_4, //!< User interface 4.
|
};
|
||||||
};
|
enum state {
|
||||||
|
state_closed,
|
||||||
extern const uint32_t MAX_SAMPLE_RATES;
|
state_stopped,
|
||||||
extern const uint32_t SAMPLE_RATES[];
|
state_stopping,
|
||||||
|
state_running
|
||||||
enum StreamState {
|
};
|
||||||
STREAM_STOPPED,
|
enum mode {
|
||||||
STREAM_STOPPING,
|
mode_unknow,
|
||||||
STREAM_RUNNING,
|
mode_output,
|
||||||
STREAM_CLOSED = -50
|
mode_input,
|
||||||
};
|
mode_duplex
|
||||||
|
};
|
||||||
enum StreamMode {
|
// A protected structure used for buffer conversion.
|
||||||
OUTPUT,
|
class ConvertInfo {
|
||||||
INPUT,
|
public:
|
||||||
DUPLEX,
|
|
||||||
UNINITIALIZED = -75
|
|
||||||
};
|
|
||||||
|
|
||||||
// A protected structure used for buffer conversion.
|
|
||||||
struct ConvertInfo {
|
|
||||||
int32_t channels;
|
int32_t channels;
|
||||||
int32_t inJump, outJump;
|
int32_t inJump;
|
||||||
audio::format inFormat, outFormat;
|
int32_t outJump;
|
||||||
|
enum audio::format inFormat;
|
||||||
|
enum audio::format outFormat;
|
||||||
std::vector<int> inOffset;
|
std::vector<int> inOffset;
|
||||||
std::vector<int> outOffset;
|
std::vector<int> outOffset;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace api {
|
||||||
// A protected structure for audio streams.
|
// A protected structure for audio streams.
|
||||||
class Stream {
|
class Stream {
|
||||||
public:
|
public:
|
||||||
uint32_t device[2]; // Playback and record, respectively.
|
uint32_t device[2]; // Playback and record, respectively.
|
||||||
void *apiHandle; // void pointer for API specific stream handle information
|
void *apiHandle; // void pointer for API specific stream handle information
|
||||||
airtaudio::api::StreamMode mode; // OUTPUT, INPUT, or DUPLEX.
|
enum airtaudio::mode mode; // OUTPUT, INPUT, or DUPLEX.
|
||||||
airtaudio::api::StreamState state; // STOPPED, RUNNING, or CLOSED
|
enum airtaudio::state state; // STOPPED, RUNNING, or CLOSED
|
||||||
char *userBuffer[2]; // Playback and record, respectively.
|
char *userBuffer[2]; // Playback and record, respectively.
|
||||||
char *deviceBuffer;
|
char *deviceBuffer;
|
||||||
bool doConvertBuffer[2]; // Playback and record, respectively.
|
bool doConvertBuffer[2]; // Playback and record, respectively.
|
||||||
@ -81,11 +78,11 @@ namespace airtaudio {
|
|||||||
uint32_t nDeviceChannels[2]; // Playback and record channels, respectively.
|
uint32_t nDeviceChannels[2]; // Playback and record channels, respectively.
|
||||||
uint32_t channelOffset[2]; // Playback and record, respectively.
|
uint32_t channelOffset[2]; // Playback and record, respectively.
|
||||||
uint64_t latency[2]; // Playback and record, respectively.
|
uint64_t latency[2]; // Playback and record, respectively.
|
||||||
audio::format userFormat;
|
enum audio::format userFormat;
|
||||||
audio::format deviceFormat[2]; // Playback and record, respectively.
|
enum audio::format deviceFormat[2]; // Playback and record, respectively.
|
||||||
std::mutex mutex;
|
std::mutex mutex;
|
||||||
airtaudio::CallbackInfo callbackInfo;
|
airtaudio::CallbackInfo callbackInfo;
|
||||||
airtaudio::api::ConvertInfo convertInfo[2];
|
airtaudio::ConvertInfo convertInfo[2];
|
||||||
double streamTime; // Number of elapsed seconds since the stream started.
|
double streamTime; // Number of elapsed seconds since the stream started.
|
||||||
|
|
||||||
#if defined(HAVE_GETTIMEOFDAY)
|
#if defined(HAVE_GETTIMEOFDAY)
|
||||||
@ -93,29 +90,18 @@ namespace airtaudio {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
Stream() :
|
Stream() :
|
||||||
apiHandle(0),
|
apiHandle(nullptr),
|
||||||
deviceBuffer(0) {
|
deviceBuffer(nullptr) {
|
||||||
device[0] = 11111;
|
device[0] = 11111;
|
||||||
device[1] = 11111;
|
device[1] = 11111;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
/**
|
|
||||||
* RtApi class declaration.
|
|
||||||
*
|
|
||||||
* Subclasses of RtApi contain all API- and OS-specific code necessary
|
|
||||||
* to fully implement the RtAudio API.
|
|
||||||
*
|
|
||||||
* Note that RtApi is an abstract base class and cannot be
|
|
||||||
* explicitly instantiated. The class RtAudio will create an
|
|
||||||
* instance of an RtApi subclass (RtApiOss, RtApiAlsa,
|
|
||||||
* RtApiJack, RtApiCore, RtApiDs, or RtApiAsio).
|
|
||||||
*/
|
|
||||||
class Api {
|
class Api {
|
||||||
public:
|
public:
|
||||||
Api();
|
Api();
|
||||||
virtual ~Api();
|
virtual ~Api();
|
||||||
virtual airtaudio::api::type getCurrentApi() = 0;
|
virtual airtaudio::type getCurrentApi() = 0;
|
||||||
virtual uint32_t getDeviceCount() = 0;
|
virtual uint32_t getDeviceCount() = 0;
|
||||||
virtual airtaudio::DeviceInfo getDeviceInfo(uint32_t _device) = 0;
|
virtual airtaudio::DeviceInfo getDeviceInfo(uint32_t _device) = 0;
|
||||||
virtual uint32_t getDefaultInputDevice();
|
virtual uint32_t getDefaultInputDevice();
|
||||||
@ -135,10 +121,10 @@ namespace airtaudio {
|
|||||||
uint32_t getStreamSampleRate();
|
uint32_t getStreamSampleRate();
|
||||||
virtual double getStreamTime();
|
virtual double getStreamTime();
|
||||||
bool isStreamOpen() const {
|
bool isStreamOpen() const {
|
||||||
return m_stream.state != airtaudio::api::STREAM_CLOSED;
|
return m_stream.state != airtaudio::state_closed;
|
||||||
}
|
}
|
||||||
bool isStreamRunning() const {
|
bool isStreamRunning() const {
|
||||||
return m_stream.state == airtaudio::api::STREAM_RUNNING;
|
return m_stream.state == airtaudio::state_running;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -152,11 +138,11 @@ namespace airtaudio {
|
|||||||
successful probe is indicated by a return value of true.
|
successful probe is indicated by a return value of true.
|
||||||
*/
|
*/
|
||||||
virtual bool probeDeviceOpen(uint32_t _device,
|
virtual bool probeDeviceOpen(uint32_t _device,
|
||||||
airtaudio::api::StreamMode _mode,
|
enum airtaudio::mode _mode,
|
||||||
uint32_t _channels,
|
uint32_t _channels,
|
||||||
uint32_t _firstChannel,
|
uint32_t _firstChannel,
|
||||||
uint32_t _sampleRate,
|
uint32_t _sampleRate,
|
||||||
audio::format _format,
|
enum audio::format _format,
|
||||||
uint32_t *_bufferSize,
|
uint32_t *_bufferSize,
|
||||||
airtaudio::StreamOptions *_options);
|
airtaudio::StreamOptions *_options);
|
||||||
|
|
||||||
@ -175,18 +161,23 @@ namespace airtaudio {
|
|||||||
* @brief Protected method used to perform format, channel number, and/or interleaving
|
* @brief Protected method used to perform format, channel number, and/or interleaving
|
||||||
* conversions between the user and device buffers.
|
* conversions between the user and device buffers.
|
||||||
*/
|
*/
|
||||||
void convertBuffer(char *_outBuffer, char *_inBuffer, airtaudio::api::ConvertInfo& _info);
|
void convertBuffer(char *_outBuffer,
|
||||||
|
char *_inBuffer,
|
||||||
|
airtaudio::ConvertInfo& _info);
|
||||||
|
|
||||||
//! Protected common method used to perform byte-swapping on buffers.
|
//! Protected common method used to perform byte-swapping on buffers.
|
||||||
void byteSwapBuffer(char *_buffer, uint32_t _samples, audio::format _format);
|
void byteSwapBuffer(char *_buffer,
|
||||||
|
uint32_t _samples,
|
||||||
|
enum audio::format _format);
|
||||||
|
|
||||||
//! Protected common method that sets up the parameters for buffer conversion.
|
//! Protected common method that sets up the parameters for buffer conversion.
|
||||||
void setConvertInfo(airtaudio::api::StreamMode _mode, uint32_t _firstChannel);
|
void setConvertInfo(enum airtaudio::mode _mode,
|
||||||
|
uint32_t _firstChannel);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* @brief Debug operator To display the curent element in a Human redeable information
|
* @brief Debug operator To display the curent element in a Human redeable information
|
||||||
*/
|
*/
|
||||||
std::ostream& operator <<(std::ostream& _os, const airtaudio::api::type& _obj);
|
std::ostream& operator <<(std::ostream& _os, const airtaudio::type& _obj);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -38,7 +38,7 @@ namespace airtaudio {
|
|||||||
*/
|
*/
|
||||||
class Interface {
|
class Interface {
|
||||||
protected:
|
protected:
|
||||||
std::vector<std::pair<airtaudio::api::type, Api* (*)()>> m_apiAvaillable;
|
std::vector<std::pair<enum airtaudio::type, Api* (*)()>> m_apiAvaillable;
|
||||||
protected:
|
protected:
|
||||||
airtaudio::Api *m_rtapi;
|
airtaudio::Api *m_rtapi;
|
||||||
public:
|
public:
|
||||||
@ -46,7 +46,7 @@ namespace airtaudio {
|
|||||||
* @brief A static function to determine the current airtaudio version.
|
* @brief A static function to determine the current airtaudio version.
|
||||||
*/
|
*/
|
||||||
static std::string getVersion() {
|
static std::string getVersion() {
|
||||||
return airtaudio::VERSION;
|
return "4.0.12";
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief A static function to determine the available compiled audio APIs.
|
* @brief A static function to determine the available compiled audio APIs.
|
||||||
@ -55,7 +55,7 @@ namespace airtaudio {
|
|||||||
* the enumerated list values. Note that there can be more than one
|
* the enumerated list values. Note that there can be more than one
|
||||||
* API compiled for certain operating systems.
|
* API compiled for certain operating systems.
|
||||||
*/
|
*/
|
||||||
std::vector<airtaudio::api::type> getCompiledApi();
|
std::vector<enum airtaudio::type> getCompiledApi();
|
||||||
/**
|
/**
|
||||||
* @brief The class constructor.
|
* @brief The class constructor.
|
||||||
* @note the creating of the basic instance is done by Instanciate
|
* @note the creating of the basic instance is done by Instanciate
|
||||||
@ -73,17 +73,17 @@ namespace airtaudio {
|
|||||||
* @param[in] _api Type of the interface.
|
* @param[in] _api Type of the interface.
|
||||||
* @param[in] _callbackCreate API creation callback.
|
* @param[in] _callbackCreate API creation callback.
|
||||||
*/
|
*/
|
||||||
void addInterface(airtaudio::api::type _api, Api* (*_callbackCreate)());
|
void addInterface(enum airtaudio::type _api, Api* (*_callbackCreate)());
|
||||||
/**
|
/**
|
||||||
* @brief Create an interface instance
|
* @brief Create an interface instance
|
||||||
*/
|
*/
|
||||||
enum airtaudio::errorType instanciate(airtaudio::api::type _api = airtaudio::api::UNSPECIFIED);
|
enum airtaudio::errorType instanciate(enum airtaudio::type _api = airtaudio::type_undefined);
|
||||||
/**
|
/**
|
||||||
* @return the audio API specifier for the current instance of airtaudio.
|
* @return the audio API specifier for the current instance of airtaudio.
|
||||||
*/
|
*/
|
||||||
airtaudio::api::type getCurrentApi() {
|
enum airtaudio::type getCurrentApi() {
|
||||||
if (m_rtapi == nullptr) {
|
if (m_rtapi == nullptr) {
|
||||||
return airtaudio::api::UNSPECIFIED;
|
return airtaudio::type_undefined;
|
||||||
}
|
}
|
||||||
return m_rtapi->getCurrentApi();
|
return m_rtapi->getCurrentApi();
|
||||||
}
|
}
|
||||||
@ -187,7 +187,7 @@ namespace airtaudio {
|
|||||||
*/
|
*/
|
||||||
enum airtaudio::errorType openStream(airtaudio::StreamParameters *_outputParameters,
|
enum airtaudio::errorType openStream(airtaudio::StreamParameters *_outputParameters,
|
||||||
airtaudio::StreamParameters *_inputParameters,
|
airtaudio::StreamParameters *_inputParameters,
|
||||||
audio::format _format,
|
enum audio::format _format,
|
||||||
uint32_t _sampleRate,
|
uint32_t _sampleRate,
|
||||||
uint32_t *_bufferFrames,
|
uint32_t *_bufferFrames,
|
||||||
airtaudio::AirTAudioCallback _callback,
|
airtaudio::AirTAudioCallback _callback,
|
||||||
@ -302,7 +302,7 @@ namespace airtaudio {
|
|||||||
return m_rtapi->getStreamSampleRate();
|
return m_rtapi->getStreamSampleRate();
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
void openRtApi(airtaudio::api::type _api);
|
void openRtApi(enum airtaudio::type _api);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -17,8 +17,8 @@ namespace airtaudio {
|
|||||||
public:
|
public:
|
||||||
Alsa();
|
Alsa();
|
||||||
virtual ~Alsa();
|
virtual ~Alsa();
|
||||||
airtaudio::api::type getCurrentApi() {
|
enum airtaudio::type getCurrentApi() {
|
||||||
return airtaudio::api::LINUX_ALSA;
|
return airtaudio::type_alsa;
|
||||||
}
|
}
|
||||||
uint32_t getDeviceCount();
|
uint32_t getDeviceCount();
|
||||||
airtaudio::DeviceInfo getDeviceInfo(uint32_t _device);
|
airtaudio::DeviceInfo getDeviceInfo(uint32_t _device);
|
||||||
@ -35,11 +35,11 @@ namespace airtaudio {
|
|||||||
std::vector<airtaudio::DeviceInfo> m_devices;
|
std::vector<airtaudio::DeviceInfo> m_devices;
|
||||||
void saveDeviceInfo();
|
void saveDeviceInfo();
|
||||||
bool probeDeviceOpen(uint32_t _device,
|
bool probeDeviceOpen(uint32_t _device,
|
||||||
airtaudio::api::StreamMode _mode,
|
enum airtaudio::mode _mode,
|
||||||
uint32_t _channels,
|
uint32_t _channels,
|
||||||
uint32_t _firstChannel,
|
uint32_t _firstChannel,
|
||||||
uint32_t _sampleRate,
|
uint32_t _sampleRate,
|
||||||
audio::format _format,
|
enum audio::format _format,
|
||||||
uint32_t *_bufferSize,
|
uint32_t *_bufferSize,
|
||||||
airtaudio::StreamOptions *_options);
|
airtaudio::StreamOptions *_options);
|
||||||
};
|
};
|
||||||
|
@ -36,8 +36,6 @@ namespace airtaudio {
|
|||||||
errorInvalidUse, //!< The function was called incorrectly.
|
errorInvalidUse, //!< The function was called incorrectly.
|
||||||
errorSystemError //!< A system error occured.
|
errorSystemError //!< A system error occured.
|
||||||
};
|
};
|
||||||
// airtaudio version
|
|
||||||
static const std::string VERSION("4.0.12");
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef typedef uint64_t streamFlags;
|
* @typedef typedef uint64_t streamFlags;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user