[DEV] start compleate rework
This commit is contained in:
parent
3629886590
commit
7c6a495d86
@ -17,32 +17,32 @@
|
||||
#undef __class__
|
||||
#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){
|
||||
switch (_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;
|
||||
}
|
||||
std::ostream& operator <<(std::ostream& _os, const airtaudio::type& _obj){
|
||||
_os << listType[_obj];
|
||||
return _os;
|
||||
}
|
||||
|
||||
// Static variable definitions.
|
||||
const uint32_t airtaudio::api::MAX_SAMPLE_RATES = 14;
|
||||
const uint32_t airtaudio::api::SAMPLE_RATES[] = {
|
||||
static const uint32_t MAX_SAMPLE_RATES = 14;
|
||||
static const uint32_t SAMPLE_RATES[] = {
|
||||
4000,
|
||||
5512,
|
||||
8000,
|
||||
@ -61,8 +61,8 @@ const uint32_t airtaudio::api::SAMPLE_RATES[] = {
|
||||
|
||||
|
||||
airtaudio::Api::Api() {
|
||||
m_stream.state = airtaudio::api::STREAM_CLOSED;
|
||||
m_stream.mode = airtaudio::api::UNINITIALIZED;
|
||||
m_stream.state = airtaudio::state_closed;
|
||||
m_stream.mode = airtaudio::mode_unknow;
|
||||
m_stream.apiHandle = 0;
|
||||
m_stream.userBuffer[0] = 0;
|
||||
m_stream.userBuffer[1] = 0;
|
||||
@ -74,7 +74,7 @@ airtaudio::Api::~Api() {
|
||||
|
||||
enum airtaudio::errorType airtaudio::Api::openStream(airtaudio::StreamParameters *oParams,
|
||||
airtaudio::StreamParameters *iParams,
|
||||
audio::format format,
|
||||
enum audio::format format,
|
||||
uint32_t sampleRate,
|
||||
uint32_t *bufferFrames,
|
||||
airtaudio::AirTAudioCallback callback,
|
||||
|
135
airtaudio/Api.h
135
airtaudio/Api.h
@ -13,61 +13,58 @@
|
||||
#include <airtaudio/debug.h>
|
||||
|
||||
namespace airtaudio {
|
||||
namespace api {
|
||||
/**
|
||||
* @brief Audio API specifier arguments.
|
||||
*/
|
||||
enum type {
|
||||
UNSPECIFIED, //!< Search for a working compiled API.
|
||||
LINUX_ALSA, //!< The Advanced Linux Sound Architecture API.
|
||||
LINUX_PULSE, //!< The Linux PulseAudio API.
|
||||
LINUX_OSS, //!< The Linux Open Sound System API.
|
||||
UNIX_JACK, //!< The Jack Low-Latency Audio Server API.
|
||||
MACOSX_CORE, //!< Macintosh OS-X Core Audio API.
|
||||
IOS_CORE, //!< Macintosh OS-X Core Audio API.
|
||||
WINDOWS_ASIO, //!< The Steinberg Audio Stream I/O API.
|
||||
WINDOWS_DS, //!< The Microsoft Direct Sound API.
|
||||
RTAUDIO_DUMMY, //!< A compilable but non-functional API.
|
||||
ANDROID_JAVA, //!< Android Interface.
|
||||
USER_INTERFACE_1, //!< User interface 1.
|
||||
USER_INTERFACE_2, //!< User interface 2.
|
||||
USER_INTERFACE_3, //!< User interface 3.
|
||||
USER_INTERFACE_4, //!< User interface 4.
|
||||
};
|
||||
|
||||
extern const uint32_t MAX_SAMPLE_RATES;
|
||||
extern const uint32_t SAMPLE_RATES[];
|
||||
|
||||
enum StreamState {
|
||||
STREAM_STOPPED,
|
||||
STREAM_STOPPING,
|
||||
STREAM_RUNNING,
|
||||
STREAM_CLOSED = -50
|
||||
};
|
||||
|
||||
enum StreamMode {
|
||||
OUTPUT,
|
||||
INPUT,
|
||||
DUPLEX,
|
||||
UNINITIALIZED = -75
|
||||
};
|
||||
|
||||
// A protected structure used for buffer conversion.
|
||||
struct ConvertInfo {
|
||||
/**
|
||||
* @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.
|
||||
};
|
||||
enum state {
|
||||
state_closed,
|
||||
state_stopped,
|
||||
state_stopping,
|
||||
state_running
|
||||
};
|
||||
enum mode {
|
||||
mode_unknow,
|
||||
mode_output,
|
||||
mode_input,
|
||||
mode_duplex
|
||||
};
|
||||
// A protected structure used for buffer conversion.
|
||||
class ConvertInfo {
|
||||
public:
|
||||
int32_t channels;
|
||||
int32_t inJump, outJump;
|
||||
audio::format inFormat, outFormat;
|
||||
int32_t inJump;
|
||||
int32_t outJump;
|
||||
enum audio::format inFormat;
|
||||
enum audio::format outFormat;
|
||||
std::vector<int> inOffset;
|
||||
std::vector<int> outOffset;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
namespace api {
|
||||
// A protected structure for audio streams.
|
||||
class Stream {
|
||||
public:
|
||||
uint32_t device[2]; // Playback and record, respectively.
|
||||
void *apiHandle; // void pointer for API specific stream handle information
|
||||
airtaudio::api::StreamMode mode; // OUTPUT, INPUT, or DUPLEX.
|
||||
airtaudio::api::StreamState state; // STOPPED, RUNNING, or CLOSED
|
||||
enum airtaudio::mode mode; // OUTPUT, INPUT, or DUPLEX.
|
||||
enum airtaudio::state state; // STOPPED, RUNNING, or CLOSED
|
||||
char *userBuffer[2]; // Playback and record, respectively.
|
||||
char *deviceBuffer;
|
||||
bool doConvertBuffer[2]; // Playback and record, respectively.
|
||||
@ -81,11 +78,11 @@ namespace airtaudio {
|
||||
uint32_t nDeviceChannels[2]; // Playback and record channels, respectively.
|
||||
uint32_t channelOffset[2]; // Playback and record, respectively.
|
||||
uint64_t latency[2]; // Playback and record, respectively.
|
||||
audio::format userFormat;
|
||||
audio::format deviceFormat[2]; // Playback and record, respectively.
|
||||
enum audio::format userFormat;
|
||||
enum audio::format deviceFormat[2]; // Playback and record, respectively.
|
||||
std::mutex mutex;
|
||||
airtaudio::CallbackInfo callbackInfo;
|
||||
airtaudio::api::ConvertInfo convertInfo[2];
|
||||
airtaudio::ConvertInfo convertInfo[2];
|
||||
double streamTime; // Number of elapsed seconds since the stream started.
|
||||
|
||||
#if defined(HAVE_GETTIMEOFDAY)
|
||||
@ -93,29 +90,18 @@ namespace airtaudio {
|
||||
#endif
|
||||
|
||||
Stream() :
|
||||
apiHandle(0),
|
||||
deviceBuffer(0) {
|
||||
apiHandle(nullptr),
|
||||
deviceBuffer(nullptr) {
|
||||
device[0] = 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 {
|
||||
public:
|
||||
Api();
|
||||
virtual ~Api();
|
||||
virtual airtaudio::api::type getCurrentApi() = 0;
|
||||
virtual airtaudio::type getCurrentApi() = 0;
|
||||
virtual uint32_t getDeviceCount() = 0;
|
||||
virtual airtaudio::DeviceInfo getDeviceInfo(uint32_t _device) = 0;
|
||||
virtual uint32_t getDefaultInputDevice();
|
||||
@ -135,10 +121,10 @@ namespace airtaudio {
|
||||
uint32_t getStreamSampleRate();
|
||||
virtual double getStreamTime();
|
||||
bool isStreamOpen() const {
|
||||
return m_stream.state != airtaudio::api::STREAM_CLOSED;
|
||||
return m_stream.state != airtaudio::state_closed;
|
||||
}
|
||||
bool isStreamRunning() const {
|
||||
return m_stream.state == airtaudio::api::STREAM_RUNNING;
|
||||
return m_stream.state == airtaudio::state_running;
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -152,11 +138,11 @@ namespace airtaudio {
|
||||
successful probe is indicated by a return value of true.
|
||||
*/
|
||||
virtual bool probeDeviceOpen(uint32_t _device,
|
||||
airtaudio::api::StreamMode _mode,
|
||||
enum airtaudio::mode _mode,
|
||||
uint32_t _channels,
|
||||
uint32_t _firstChannel,
|
||||
uint32_t _sampleRate,
|
||||
audio::format _format,
|
||||
enum audio::format _format,
|
||||
uint32_t *_bufferSize,
|
||||
airtaudio::StreamOptions *_options);
|
||||
|
||||
@ -175,18 +161,23 @@ namespace airtaudio {
|
||||
* @brief Protected method used to perform format, channel number, and/or interleaving
|
||||
* 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.
|
||||
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.
|
||||
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
|
||||
*/
|
||||
std::ostream& operator <<(std::ostream& _os, const airtaudio::api::type& _obj);
|
||||
std::ostream& operator <<(std::ostream& _os, const airtaudio::type& _obj);
|
||||
|
||||
#endif
|
||||
|
@ -38,7 +38,7 @@ namespace airtaudio {
|
||||
*/
|
||||
class Interface {
|
||||
protected:
|
||||
std::vector<std::pair<airtaudio::api::type, Api* (*)()>> m_apiAvaillable;
|
||||
std::vector<std::pair<enum airtaudio::type, Api* (*)()>> m_apiAvaillable;
|
||||
protected:
|
||||
airtaudio::Api *m_rtapi;
|
||||
public:
|
||||
@ -46,7 +46,7 @@ namespace airtaudio {
|
||||
* @brief A static function to determine the current airtaudio version.
|
||||
*/
|
||||
static std::string getVersion() {
|
||||
return airtaudio::VERSION;
|
||||
return "4.0.12";
|
||||
}
|
||||
/**
|
||||
* @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
|
||||
* API compiled for certain operating systems.
|
||||
*/
|
||||
std::vector<airtaudio::api::type> getCompiledApi();
|
||||
std::vector<enum airtaudio::type> getCompiledApi();
|
||||
/**
|
||||
* @brief The class constructor.
|
||||
* @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] _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
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
airtaudio::api::type getCurrentApi() {
|
||||
enum airtaudio::type getCurrentApi() {
|
||||
if (m_rtapi == nullptr) {
|
||||
return airtaudio::api::UNSPECIFIED;
|
||||
return airtaudio::type_undefined;
|
||||
}
|
||||
return m_rtapi->getCurrentApi();
|
||||
}
|
||||
@ -187,7 +187,7 @@ namespace airtaudio {
|
||||
*/
|
||||
enum airtaudio::errorType openStream(airtaudio::StreamParameters *_outputParameters,
|
||||
airtaudio::StreamParameters *_inputParameters,
|
||||
audio::format _format,
|
||||
enum audio::format _format,
|
||||
uint32_t _sampleRate,
|
||||
uint32_t *_bufferFrames,
|
||||
airtaudio::AirTAudioCallback _callback,
|
||||
@ -302,7 +302,7 @@ namespace airtaudio {
|
||||
return m_rtapi->getStreamSampleRate();
|
||||
}
|
||||
protected:
|
||||
void openRtApi(airtaudio::api::type _api);
|
||||
void openRtApi(enum airtaudio::type _api);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -17,8 +17,8 @@ namespace airtaudio {
|
||||
public:
|
||||
Alsa();
|
||||
virtual ~Alsa();
|
||||
airtaudio::api::type getCurrentApi() {
|
||||
return airtaudio::api::LINUX_ALSA;
|
||||
enum airtaudio::type getCurrentApi() {
|
||||
return airtaudio::type_alsa;
|
||||
}
|
||||
uint32_t getDeviceCount();
|
||||
airtaudio::DeviceInfo getDeviceInfo(uint32_t _device);
|
||||
@ -35,11 +35,11 @@ namespace airtaudio {
|
||||
std::vector<airtaudio::DeviceInfo> m_devices;
|
||||
void saveDeviceInfo();
|
||||
bool probeDeviceOpen(uint32_t _device,
|
||||
airtaudio::api::StreamMode _mode,
|
||||
enum airtaudio::mode _mode,
|
||||
uint32_t _channels,
|
||||
uint32_t _firstChannel,
|
||||
uint32_t _sampleRate,
|
||||
audio::format _format,
|
||||
enum audio::format _format,
|
||||
uint32_t *_bufferSize,
|
||||
airtaudio::StreamOptions *_options);
|
||||
};
|
||||
|
@ -36,8 +36,6 @@ namespace airtaudio {
|
||||
errorInvalidUse, //!< The function was called incorrectly.
|
||||
errorSystemError //!< A system error occured.
|
||||
};
|
||||
// airtaudio version
|
||||
static const std::string VERSION("4.0.12");
|
||||
|
||||
/**
|
||||
* @typedef typedef uint64_t streamFlags;
|
||||
|
Loading…
x
Reference in New Issue
Block a user