[DEV] start rework Lib
This commit is contained in:
@@ -14,6 +14,11 @@
|
||||
#include <airtaudio/Interface.h>
|
||||
#include <limits.h>
|
||||
|
||||
airtaudio::Api* airtaudio::api::Alsa::Create(void) {
|
||||
return new airtaudio::api::Alsa();
|
||||
}
|
||||
|
||||
|
||||
// A structure to hold various information related to the ALSA API
|
||||
// implementation.
|
||||
struct AlsaHandle {
|
||||
@@ -370,13 +375,13 @@ void airtaudio::api::Alsa::saveDeviceInfo(void) {
|
||||
}
|
||||
|
||||
bool airtaudio::api::Alsa::probeDeviceOpen(uint32_t _device,
|
||||
airtaudio::api::StreamMode _mode,
|
||||
uint32_t _channels,
|
||||
uint32_t _firstChannel,
|
||||
uint32_t _sampleRate,
|
||||
airtaudio::format _format,
|
||||
uint32_t *_bufferSize,
|
||||
airtaudio::StreamOptions *_options) {
|
||||
airtaudio::api::StreamMode _mode,
|
||||
uint32_t _channels,
|
||||
uint32_t _firstChannel,
|
||||
uint32_t _sampleRate,
|
||||
airtaudio::format _format,
|
||||
uint32_t *_bufferSize,
|
||||
airtaudio::StreamOptions *_options) {
|
||||
#if defined(__RTAUDIO_DEBUG__)
|
||||
snd_output_t *out;
|
||||
snd_output_stdio_attach(&out, stderr, 0);
|
||||
@@ -818,7 +823,7 @@ error:
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
void airtaudio::api::Alsa::closeStream(void) {
|
||||
enum airtaudio::errorType airtaudio::api::Alsa::closeStream(void) {
|
||||
if (m_stream.state == STREAM_CLOSED) {
|
||||
m_errorText = "airtaudio::api::Alsa::closeStream(): no open stream to close!";
|
||||
error(airtaudio::errorWarning);
|
||||
@@ -871,7 +876,7 @@ void airtaudio::api::Alsa::closeStream(void) {
|
||||
m_stream.state = STREAM_CLOSED;
|
||||
}
|
||||
|
||||
void airtaudio::api::Alsa::startStream(void) {
|
||||
enum airtaudio::errorType airtaudio::api::Alsa::startStream(void) {
|
||||
// This method calls snd_pcm_prepare if the device isn't already in that state.
|
||||
verifyStream();
|
||||
if (m_stream.state == STREAM_RUNNING) {
|
||||
@@ -918,7 +923,7 @@ unlock:
|
||||
error(airtaudio::errorSystemError);
|
||||
}
|
||||
|
||||
void airtaudio::api::Alsa::stopStream(void) {
|
||||
enum airtaudio::errorType airtaudio::api::Alsa::stopStream(void) {
|
||||
verifyStream();
|
||||
if (m_stream.state == STREAM_STOPPED) {
|
||||
m_errorText = "airtaudio::api::Alsa::stopStream(): the stream is already stopped!";
|
||||
@@ -960,7 +965,7 @@ unlock:
|
||||
error(airtaudio::errorSystemError);
|
||||
}
|
||||
|
||||
void airtaudio::api::Alsa::abortStream(void) {
|
||||
enum airtaudio::errorType airtaudio::api::Alsa::abortStream(void) {
|
||||
verifyStream();
|
||||
if (m_stream.state == STREAM_STOPPED) {
|
||||
m_errorText = "airtaudio::api::Alsa::abortStream(): the stream is already stopped!";
|
||||
|
@@ -12,6 +12,8 @@
|
||||
namespace airtaudio {
|
||||
namespace api {
|
||||
class Alsa: public airtaudio::Api {
|
||||
public:
|
||||
static airtaudio::Api* Create(void);
|
||||
public:
|
||||
Alsa();
|
||||
~Alsa();
|
||||
@@ -20,10 +22,10 @@ namespace airtaudio {
|
||||
}
|
||||
uint32_t getDeviceCount(void);
|
||||
airtaudio::DeviceInfo getDeviceInfo(uint32_t _device);
|
||||
void closeStream(void);
|
||||
void startStream(void);
|
||||
void stopStream(void);
|
||||
void abortStream(void);
|
||||
enum airtaudio::errorType closeStream(void);
|
||||
enum airtaudio::errorType startStream(void);
|
||||
enum airtaudio::errorType stopStream(void);
|
||||
enum airtaudio::errorType abortStream(void);
|
||||
// This function is intended for internal use only. It must be
|
||||
// public because it is called by the internal callback handler,
|
||||
// which is not a member of RtAudio. External use of this function
|
||||
|
@@ -11,6 +11,11 @@
|
||||
|
||||
#include <airtaudio/Interface.h>
|
||||
|
||||
airtaudio::Api* airtaudio::api::Asio::Create(void) {
|
||||
return new airtaudio::api::Asio();
|
||||
}
|
||||
|
||||
|
||||
// The ASIO API is designed around a callback scheme, so this
|
||||
// implementation is similar to that used for OS-X CoreAudio and Linux
|
||||
// Jack. The primary constraint with ASIO is that it only allows
|
||||
|
@@ -12,6 +12,8 @@
|
||||
namespace airtaudio {
|
||||
namespace api {
|
||||
class Asio: public airtaudio::Api {
|
||||
public:
|
||||
static airtaudio::Api* Create(void);
|
||||
public:
|
||||
Asio();
|
||||
~Asio();
|
||||
|
@@ -17,6 +17,11 @@
|
||||
|
||||
#include <airtaudio/Interface.h>
|
||||
|
||||
airtaudio::Api* airtaudio::api::Core::Create(void) {
|
||||
return new airtaudio::api::Core();
|
||||
}
|
||||
|
||||
|
||||
// The OS X CoreAudio API is designed to use a separate callback
|
||||
// procedure for each of its audio devices. A single RtAudio duplex
|
||||
// stream using two different devices is supported here, though it
|
||||
|
@@ -14,6 +14,8 @@
|
||||
namespace airtaudio {
|
||||
namespace api {
|
||||
class Core: public airtaudio::Api {
|
||||
public:
|
||||
static airtaudio::Api* Create(void);
|
||||
public:
|
||||
Core();
|
||||
~Core();
|
||||
|
@@ -10,6 +10,11 @@
|
||||
#if defined(__WINDOWS_DS__)
|
||||
#include <airtaudio/Interface.h>
|
||||
|
||||
airtaudio::Api* airtaudio::api::Ds::Create(void) {
|
||||
return new airtaudio::api::Ds();
|
||||
}
|
||||
|
||||
|
||||
// Modified by Robin Davies, October 2005
|
||||
// - Improvements to DirectX pointer chasing.
|
||||
// - Bug fix for non-power-of-two Asio granularity used by Edirol PCR-A30.
|
||||
|
@@ -12,6 +12,8 @@
|
||||
namespace airtaudio {
|
||||
namespace api {
|
||||
class Ds: public airtaudio::Api {
|
||||
public:
|
||||
static airtaudio::Api* Create(void);
|
||||
public:
|
||||
Ds(void);
|
||||
~Ds(void);
|
||||
|
@@ -8,6 +8,11 @@
|
||||
|
||||
#if defined(__AIRTAUDIO_DUMMY__)
|
||||
|
||||
airtaudio::Api* airtaudio::api::Dummy::Create(void) {
|
||||
return new airtaudio::api::Dummy();
|
||||
}
|
||||
|
||||
|
||||
airtaudio::api::Dummy::Dummy(void) {
|
||||
m_errorText = "airtaudio::api::Dummy: This class provides no functionality.";
|
||||
error(airtaudio::errorWarning);
|
||||
|
@@ -14,6 +14,8 @@
|
||||
namespace airtaudio {
|
||||
namespace api {
|
||||
class Dummy: public airtaudio::Api {
|
||||
public:
|
||||
static airtaudio::Api* Create(void);
|
||||
public:
|
||||
Dummy(void);
|
||||
airtaudio::api::type getCurrentApi(void) {
|
||||
|
@@ -14,6 +14,11 @@
|
||||
#include <airtaudio/Interface.h>
|
||||
#include <string.h>
|
||||
|
||||
airtaudio::Api* airtaudio::api::Jack::Create(void) {
|
||||
return new airtaudio::api::Jack();
|
||||
}
|
||||
|
||||
|
||||
// JACK is a low-latency audio server, originally written for the
|
||||
// GNU/Linux operating system and now also ported to OS-X. It can
|
||||
// connect a number of different applications to an audio device, as
|
||||
|
@@ -12,6 +12,8 @@
|
||||
namespace airtaudio {
|
||||
namespace api {
|
||||
class Jack: public airtaudio::Api {
|
||||
public:
|
||||
static airtaudio::Api* Create(void);
|
||||
public:
|
||||
Jack(void);
|
||||
~Jack(void);
|
||||
|
@@ -18,6 +18,10 @@
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
|
||||
airtaudio::Api* airtaudio::api::Oss::Create(void) {
|
||||
return new airtaudio::api::Oss();
|
||||
}
|
||||
|
||||
static void *ossCallbackHandler(void * ptr);
|
||||
|
||||
// A structure to hold various information related to the OSS API
|
||||
@@ -28,8 +32,13 @@ struct OssHandle {
|
||||
bool triggered;
|
||||
pthread_cond_t runnable;
|
||||
|
||||
OssHandle()
|
||||
:triggered(false) { id[0] = 0; id[1] = 0; xrun[0] = false; xrun[1] = false; }
|
||||
OssHandle(void):
|
||||
triggered(false) {
|
||||
id[0] = 0;
|
||||
id[1] = 0;
|
||||
xrun[0] = false;
|
||||
xrun[1] = false;
|
||||
}
|
||||
};
|
||||
|
||||
airtaudio::api::Oss::Oss(void) {
|
||||
|
@@ -12,6 +12,8 @@
|
||||
namespace airtaudio {
|
||||
namespace api {
|
||||
class Oss: public airtaudio::Api {
|
||||
public:
|
||||
static airtaudio::Api* Create(void);
|
||||
public:
|
||||
Oss(void);
|
||||
~Oss(void);
|
||||
|
@@ -19,6 +19,11 @@
|
||||
#include <pulse/simple.h>
|
||||
#include <cstdio>
|
||||
|
||||
airtaudio::Api* airtaudio::api::Pulse::Create(void) {
|
||||
return new airtaudio::api::Pulse();
|
||||
}
|
||||
|
||||
|
||||
static const uint32_t SUPPORTED_SAMPLERATES[] = {
|
||||
8000,
|
||||
16000,
|
||||
@@ -47,7 +52,12 @@ struct PulseAudioHandle {
|
||||
std::thread* thread;
|
||||
std::condition_variable runnable_cv;
|
||||
bool runnable;
|
||||
PulseAudioHandle() : s_play(0), s_rec(0), runnable(false) { }
|
||||
PulseAudioHandle(void) :
|
||||
s_play(0),
|
||||
s_rec(0),
|
||||
runnable(false) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
airtaudio::api::Pulse::~Pulse()
|
||||
|
@@ -12,6 +12,8 @@
|
||||
namespace airtaudio {
|
||||
namespace api {
|
||||
class Pulse: public airtaudio::Api {
|
||||
public:
|
||||
static airtaudio::Api* Create(void);
|
||||
public:
|
||||
~Pulse(void);
|
||||
airtaudio::api::type getCurrentApi(void) {
|
||||
|
Reference in New Issue
Block a user