[DEV] Rework uncheck core, asio, ds, and start Android over EWOL
This commit is contained in:
parent
366d9a7049
commit
56836c7876
@ -157,7 +157,7 @@ bool airtaudio::Api::probeDeviceOpen(uint32_t /*device*/,
|
||||
uint32_t * /*bufferSize*/,
|
||||
airtaudio::StreamOptions * /*options*/) {
|
||||
// MUST be implemented in subclasses!
|
||||
return airtaudio::api::FAILURE;
|
||||
return false;
|
||||
}
|
||||
|
||||
void airtaudio::Api::tickStreamTime(void) {
|
||||
|
@ -36,11 +36,6 @@ namespace airtaudio {
|
||||
extern const uint32_t MAX_SAMPLE_RATES;
|
||||
extern const uint32_t SAMPLE_RATES[];
|
||||
|
||||
enum {
|
||||
FAILURE,
|
||||
SUCCESS
|
||||
};
|
||||
|
||||
enum StreamState {
|
||||
STREAM_STOPPED,
|
||||
STREAM_STOPPING,
|
||||
@ -152,8 +147,8 @@ namespace airtaudio {
|
||||
Protected, api-specific method that attempts to open a device
|
||||
with the given parameters. This function MUST be implemented by
|
||||
all subclasses. If an error is encountered during the probe, a
|
||||
"warning" message is reported and FAILURE is returned. A
|
||||
successful probe is indicated by a return value of SUCCESS.
|
||||
"warning" message is reported and false is returned. A
|
||||
successful probe is indicated by a return value of true.
|
||||
*/
|
||||
virtual bool probeDeviceOpen(uint32_t _device,
|
||||
airtaudio::api::StreamMode _mode,
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include <airtaudio/CallbackInfo.h>
|
||||
#include <airtaudio/Api.h>
|
||||
#include <airtaudio/api/Alsa.h>
|
||||
#include <airtaudio/api/Android.h>
|
||||
#include <airtaudio/api/Asio.h>
|
||||
#include <airtaudio/api/Core.h>
|
||||
#include <airtaudio/api/Ds.h>
|
||||
|
@ -382,7 +382,7 @@ bool airtaudio::api::Alsa::probeDeviceOpen(uint32_t _device,
|
||||
result = snd_ctl_open(&chandle, name, SND_CTL_NONBLOCK);
|
||||
if (result < 0) {
|
||||
ATA_ERROR("airtaudio::api::Alsa::probeDeviceOpen: control open, card = " << card << ", " << snd_strerror(result) << ".");
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
subdevice = -1;
|
||||
while(1) {
|
||||
@ -410,12 +410,12 @@ bool airtaudio::api::Alsa::probeDeviceOpen(uint32_t _device,
|
||||
if (nDevices == 0) {
|
||||
// This should not happen because a check is made before this function is called.
|
||||
ATA_ERROR("airtaudio::api::Alsa::probeDeviceOpen: no devices found!");
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
if (_device >= nDevices) {
|
||||
// This should not happen because a check is made before this function is called.
|
||||
ATA_ERROR("airtaudio::api::Alsa::probeDeviceOpen: device ID is invalid!");
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -444,7 +444,7 @@ foundDevice:
|
||||
} else {
|
||||
ATA_ERROR("airtaudio::api::Alsa::probeDeviceOpen: pcm device (" << name << ") won't open for input.");
|
||||
}
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
// Fill the parameter structure.
|
||||
snd_pcm_hw_params_t *hw_params;
|
||||
@ -453,7 +453,7 @@ foundDevice:
|
||||
if (result < 0) {
|
||||
snd_pcm_close(phandle);
|
||||
ATA_ERROR("airtaudio::api::Alsa::probeDeviceOpen: error getting pcm device (" << name << ") parameters, " << snd_strerror(result) << ".");
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
// Set access ... check user preference.
|
||||
if ( _options != NULL
|
||||
@ -479,7 +479,7 @@ foundDevice:
|
||||
if (result < 0) {
|
||||
snd_pcm_close(phandle);
|
||||
ATA_ERROR("airtaudio::api::Alsa::probeDeviceOpen: error setting pcm device (" << name << ") access, " << snd_strerror(result) << ".");
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
// Determine how to set the device format.
|
||||
m_stream.userFormat = _format;
|
||||
@ -535,14 +535,14 @@ foundDevice:
|
||||
// If we get here, no supported format was found.
|
||||
snd_pcm_close(phandle);
|
||||
ATA_ERROR("airtaudio::api::Alsa::probeDeviceOpen: pcm device " << _device << " data format not supported by RtAudio.");
|
||||
return FAILURE;
|
||||
return false;
|
||||
|
||||
setFormat:
|
||||
result = snd_pcm_hw_params_set_format(phandle, hw_params, deviceFormat);
|
||||
if (result < 0) {
|
||||
snd_pcm_close(phandle);
|
||||
ATA_ERROR("airtaudio::api::Alsa::probeDeviceOpen: error setting pcm device (" << name << ") data format, " << snd_strerror(result) << ".");
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
// Determine whether byte-swaping is necessary.
|
||||
m_stream.doByteSwap[_mode] = false;
|
||||
@ -553,7 +553,7 @@ setFormat:
|
||||
} else if (result < 0) {
|
||||
snd_pcm_close(phandle);
|
||||
ATA_ERROR("airtaudio::api::Alsa::probeDeviceOpen: error getting pcm device (" << name << ") endian-ness, " << snd_strerror(result) << ".");
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Set the sample rate.
|
||||
@ -561,7 +561,7 @@ setFormat:
|
||||
if (result < 0) {
|
||||
snd_pcm_close(phandle);
|
||||
ATA_ERROR("airtaudio::api::Alsa::probeDeviceOpen: error setting sample rate on device (" << name << "), " << snd_strerror(result) << ".");
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
// Determine the number of channels for this device. We support a possible
|
||||
// minimum device channel number > than the value requested by the user.
|
||||
@ -573,13 +573,13 @@ setFormat:
|
||||
|| deviceChannels < _channels + _firstChannel) {
|
||||
snd_pcm_close(phandle);
|
||||
ATA_ERROR("airtaudio::api::Alsa::probeDeviceOpen: requested channel parameters not supported by device (" << name << "), " << snd_strerror(result) << ".");
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
result = snd_pcm_hw_params_get_channels_min(hw_params, &value);
|
||||
if (result < 0) {
|
||||
snd_pcm_close(phandle);
|
||||
ATA_ERROR("airtaudio::api::Alsa::probeDeviceOpen: error getting minimum channels for device (" << name << "), " << snd_strerror(result) << ".");
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
deviceChannels = value;
|
||||
if (deviceChannels < _channels + _firstChannel) {
|
||||
@ -591,7 +591,7 @@ setFormat:
|
||||
if (result < 0) {
|
||||
snd_pcm_close(phandle);
|
||||
ATA_ERROR("airtaudio::api::Alsa::probeDeviceOpen: error setting channels for device (" << name << "), " << snd_strerror(result) << ".");
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
// Set the buffer (or period) size.
|
||||
int32_t dir = 0;
|
||||
@ -600,7 +600,7 @@ setFormat:
|
||||
if (result < 0) {
|
||||
snd_pcm_close(phandle);
|
||||
ATA_ERROR("airtaudio::api::Alsa::probeDeviceOpen: error setting period size for device (" << name << "), " << snd_strerror(result) << ".");
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
*_bufferSize = periodSize;
|
||||
// Set the buffer number, which in ALSA is referred to as the "period".
|
||||
@ -612,14 +612,14 @@ setFormat:
|
||||
if (result < 0) {
|
||||
snd_pcm_close(phandle);
|
||||
ATA_ERROR("airtaudio::api::Alsa::probeDeviceOpen: error setting periods for device (" << name << "), " << snd_strerror(result) << ".");
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
// If attempting to setup a duplex stream, the bufferSize parameter
|
||||
// MUST be the same in both directions!
|
||||
if (m_stream.mode == OUTPUT && _mode == INPUT && *_bufferSize != m_stream.bufferSize) {
|
||||
snd_pcm_close(phandle);
|
||||
ATA_ERROR("airtaudio::api::Alsa::probeDeviceOpen: system error setting buffer size for duplex stream on device (" << name << ").");
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
m_stream.bufferSize = *_bufferSize;
|
||||
// Install the hardware configuration
|
||||
@ -627,7 +627,7 @@ setFormat:
|
||||
if (result < 0) {
|
||||
snd_pcm_close(phandle);
|
||||
ATA_ERROR("airtaudio::api::Alsa::probeDeviceOpen: error installing hardware configuration on device (" << name << "), " << snd_strerror(result) << ".");
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
// Set the software configuration to fill buffers with zeros and prevent device stopping on xruns.
|
||||
snd_pcm_sw_params_t *sw_params = NULL;
|
||||
@ -648,7 +648,7 @@ setFormat:
|
||||
if (result < 0) {
|
||||
snd_pcm_close(phandle);
|
||||
ATA_ERROR("airtaudio::api::Alsa::probeDeviceOpen: error installing software configuration on device (" << name << "), " << snd_strerror(result) << ".");
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
// Set flags for buffer conversion
|
||||
m_stream.doConvertBuffer[_mode] = false;
|
||||
@ -743,7 +743,7 @@ setFormat:
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
return SUCCESS;
|
||||
return true;
|
||||
error:
|
||||
if (apiInfo != NULL) {
|
||||
if (apiInfo->handles[0]) {
|
||||
@ -770,7 +770,7 @@ error:
|
||||
m_stream.deviceBuffer = 0;
|
||||
}
|
||||
m_stream.state = STREAM_CLOSED;
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
|
||||
enum airtaudio::errorType airtaudio::api::Alsa::closeStream(void) {
|
||||
|
84
airtaudio/api/Android.cpp
Normal file
84
airtaudio/api/Android.cpp
Normal file
@ -0,0 +1,84 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @license like MIT (see license file)
|
||||
*/
|
||||
|
||||
#if defined(__ANDROID_JAVA__)
|
||||
|
||||
#include <alsa/asoundlib.h>
|
||||
#include <unistd.h>
|
||||
#include <airtaudio/Interface.h>
|
||||
#include <airtaudio/debug.h>
|
||||
#include <limits.h>
|
||||
|
||||
airtaudio::api::Android(void) {
|
||||
// On android, we set a static device ...
|
||||
airtaudio::DeviceInfo tmp;
|
||||
tmp.name = "speaker";
|
||||
tmp.outputChannels = 2;
|
||||
tmp.inputChannels = 0;
|
||||
tmp.duplexChannels = 1;
|
||||
tmp.isDefaultOutput = true;
|
||||
tmp.isDefaultInput = false;
|
||||
sampleRates.pushBack(44100);
|
||||
nativeFormats = SINT16;
|
||||
m_devices.push_back(tmp);
|
||||
ATA_INFO("Create Android interface");
|
||||
}
|
||||
|
||||
airtaudio::api::~Android(void) {
|
||||
ATA_INFO("Destroy Android interface");
|
||||
}
|
||||
|
||||
uint32_t airtaudio::api::getDeviceCount(void) {
|
||||
ATA_INFO("Get device count:"<< m_devices.size());
|
||||
return m_devices.size();
|
||||
}
|
||||
|
||||
airtaudio::DeviceInfo airtaudio::api::getDeviceInfo(uint32_t _device) {
|
||||
ATA_INFO("Get device info ...");
|
||||
return m_devices[_device];
|
||||
}
|
||||
|
||||
enum airtaudio::errorType airtaudio::api::closeStream(void) {
|
||||
ATA_INFO("Clese Stream");
|
||||
// Can not close the stream now...
|
||||
return airtaudio::errorNone;
|
||||
}
|
||||
|
||||
enum airtaudio::errorType airtaudio::api::startStream(void) {
|
||||
ATA_INFO("Start Stream");
|
||||
// Can not close the stream now...
|
||||
return airtaudio::errorNone;
|
||||
}
|
||||
|
||||
enum airtaudio::errorType airtaudio::api::stopStream(void) {
|
||||
ATA_INFO("Stop stream");
|
||||
// Can not close the stream now...
|
||||
return airtaudio::errorNone;
|
||||
}
|
||||
|
||||
enum airtaudio::errorType airtaudio::api::abortStream(void) {
|
||||
ATA_INFO("Abort Stream");
|
||||
// Can not close the stream now...
|
||||
return airtaudio::errorNone;
|
||||
}
|
||||
|
||||
void airtaudio::api::callbackEvent(void) {
|
||||
ATA_INFO("callback event ...");
|
||||
}
|
||||
|
||||
bool airtaudio::api::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) {
|
||||
ATA_INFO("Probe : device=" << _device << " channels=" << _channels << " firstChannel=" << _firstChannel << " sampleRate=" << _sampleRate);
|
||||
return true
|
||||
}
|
||||
|
||||
#endif
|
47
airtaudio/api/Android.h
Normal file
47
airtaudio/api/Android.h
Normal file
@ -0,0 +1,47 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @license like MIT (see license file)
|
||||
*/
|
||||
|
||||
#if !defined(__AIRTAUDIO_API_ANDROID_H__) && defined(__ANDROID_JAVA__)
|
||||
#define __AIRTAUDIO_API_ANDROID_H__
|
||||
|
||||
namespace airtaudio {
|
||||
namespace api {
|
||||
class Android: public airtaudio::Api {
|
||||
public:
|
||||
static airtaudio::Api* Create(void);
|
||||
public:
|
||||
Android(void);
|
||||
~Android(void);
|
||||
airtaudio::api::type getCurrentApi(void) {
|
||||
return airtaudio::api::ANDROID_JAVA;
|
||||
}
|
||||
uint32_t getDeviceCount(void);
|
||||
airtaudio::DeviceInfo getDeviceInfo(uint32_t _device);
|
||||
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
|
||||
// will most likely produce highly undesireable results!
|
||||
void callbackEvent(void);
|
||||
private:
|
||||
std::vector<airtaudio::DeviceInfo> m_devices;
|
||||
void saveDeviceInfo(void);
|
||||
bool 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);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
@ -444,12 +444,12 @@ bool airtaudio::api::Core::probeDeviceOpen(uint32_t _device,
|
||||
if (nDevices == 0) {
|
||||
// This should not happen because a check is made before this function is called.
|
||||
ATA_ERROR("airtaudio::api::Core::probeDeviceOpen: no devices found!");
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
if (_device >= nDevices) {
|
||||
// This should not happen because a check is made before this function is called.
|
||||
ATA_ERROR("airtaudio::api::Core::probeDeviceOpen: device ID is invalid!");
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
AudioDeviceID deviceList[ nDevices ];
|
||||
uint32_t dataSize = sizeof(AudioDeviceID) * nDevices;
|
||||
@ -466,7 +466,7 @@ bool airtaudio::api::Core::probeDeviceOpen(uint32_t _device,
|
||||
(void *) &deviceList);
|
||||
if (result != noErr) {
|
||||
ATA_ERROR("airtaudio::api::Core::probeDeviceOpen: OS-X system error getting device IDs.");
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
AudioDeviceID id = deviceList[ _device ];
|
||||
// Setup for stream mode.
|
||||
@ -485,19 +485,19 @@ bool airtaudio::api::Core::probeDeviceOpen(uint32_t _device,
|
||||
if ( result != noErr
|
||||
|| dataSize == 0) {
|
||||
ATA_ERROR("airtaudio::api::Core::probeDeviceOpen: system error (" << getErrorCode(result) << ") getting stream configuration info for device (" << _device << ").");
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
// Allocate the AudioBufferList.
|
||||
bufferList = (AudioBufferList *) malloc(dataSize);
|
||||
if (bufferList == NULL) {
|
||||
ATA_ERROR("airtaudio::api::Core::probeDeviceOpen: memory error allocating AudioBufferList.");
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
result = AudioObjectGetPropertyData(id, &property, 0, NULL, &dataSize, bufferList);
|
||||
if ( result != noErr
|
||||
|| dataSize == 0) {
|
||||
ATA_ERROR("airtaudio::api::Core::probeDeviceOpen: system error (" << getErrorCode(result) << ") getting stream configuration for device (" << _device << ").");
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
// Search for one or more streams that contain the desired number of
|
||||
// channels. CoreAudio devices can have an arbitrary number of
|
||||
@ -520,7 +520,7 @@ bool airtaudio::api::Core::probeDeviceOpen(uint32_t _device,
|
||||
if (deviceChannels < (_channels + _firstChannel)) {
|
||||
free(bufferList);
|
||||
ATA_ERROR("airtaudio::api::Core::probeDeviceOpen: the device (" << _device << ") does not support the requested channel count.");
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
// Look for a single stream meeting our needs.
|
||||
uint32_t firstStream, streamCount = 1, streamChannels = 0, channelOffset = 0;
|
||||
@ -572,7 +572,7 @@ bool airtaudio::api::Core::probeDeviceOpen(uint32_t _device,
|
||||
result = AudioObjectGetPropertyData(id, &property, 0, NULL, &dataSize, &bufferRange);
|
||||
if (result != noErr) {
|
||||
ATA_ERROR("airtaudio::api::Core::probeDeviceOpen: system error (" << getErrorCode(result) << ") getting buffer size range for device (" << _device << ").");
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
if (bufferRange.mMinimum > *_bufferSize) {
|
||||
*_bufferSize = (uint64_t) bufferRange.mMinimum;
|
||||
@ -591,7 +591,7 @@ bool airtaudio::api::Core::probeDeviceOpen(uint32_t _device,
|
||||
result = AudioObjectSetPropertyData(id, &property, 0, NULL, dataSize, &theSize);
|
||||
if (result != noErr) {
|
||||
ATA_ERROR("airtaudio::api::Core::probeDeviceOpen: system error (" << getErrorCode(result) << ") setting the buffer size for device (" << _device << ").");
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
// If attempting to setup a duplex stream, the bufferSize parameter
|
||||
// MUST be the same in both directions!
|
||||
@ -600,7 +600,7 @@ bool airtaudio::api::Core::probeDeviceOpen(uint32_t _device,
|
||||
&& _mode == INPUT
|
||||
&& *_bufferSize != m_stream.bufferSize) {
|
||||
ATA_ERROR("airtaudio::api::Core::probeDeviceOpen: system error setting buffer size for duplex stream on device (" << _device << ").");
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
m_stream.bufferSize = *_bufferSize;
|
||||
m_stream.nBuffers = 1;
|
||||
@ -613,14 +613,14 @@ bool airtaudio::api::Core::probeDeviceOpen(uint32_t _device,
|
||||
result = AudioObjectGetPropertyData(id, &property, 0, NULL, &dataSize, &hog_pid);
|
||||
if (result != noErr) {
|
||||
ATA_ERROR("airtaudio::api::Core::probeDeviceOpen: system error (" << getErrorCode(result) << ") getting 'hog' state!");
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
if (hog_pid != getpid()) {
|
||||
hog_pid = getpid();
|
||||
result = AudioObjectSetPropertyData(id, &property, 0, NULL, dataSize, &hog_pid);
|
||||
if (result != noErr) {
|
||||
ATA_ERROR("airtaudio::api::Core::probeDeviceOpen: system error (" << getErrorCode(result) << ") setting 'hog' state!");
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -631,7 +631,7 @@ bool airtaudio::api::Core::probeDeviceOpen(uint32_t _device,
|
||||
result = AudioObjectGetPropertyData(id, &property, 0, NULL, &dataSize, &nominalRate);
|
||||
if (result != noErr) {
|
||||
ATA_ERROR("airtaudio::api::Core::probeDeviceOpen: system error (" << getErrorCode(result) << ") getting current sample rate.");
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
// Only change the sample rate if off by more than 1 Hz.
|
||||
if (fabs(nominalRate - (double)_sampleRate) > 1.0) {
|
||||
@ -641,13 +641,13 @@ bool airtaudio::api::Core::probeDeviceOpen(uint32_t _device,
|
||||
result = AudioObjectAddPropertyListener(id, &tmp, rateListener, (void *) &reportedRate);
|
||||
if (result != noErr) {
|
||||
ATA_ERROR("airtaudio::api::Core::probeDeviceOpen: system error (" << getErrorCode(result) << ") setting sample rate property listener for device (" << _device << ").");
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
nominalRate = (double) _sampleRate;
|
||||
result = AudioObjectSetPropertyData(id, &property, 0, NULL, dataSize, &nominalRate);
|
||||
if (result != noErr) {
|
||||
ATA_ERROR("airtaudio::api::Core::probeDeviceOpen: system error (" << getErrorCode(result) << ") setting sample rate for device (" << _device << ").");
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
// Now wait until the reported nominal rate is what we just set.
|
||||
uint32_t microCounter = 0;
|
||||
@ -662,7 +662,7 @@ bool airtaudio::api::Core::probeDeviceOpen(uint32_t _device,
|
||||
AudioObjectRemovePropertyListener(id, &tmp, rateListener, (void *) &reportedRate);
|
||||
if (microCounter > 5000000) {
|
||||
ATA_ERROR("airtaudio::api::Core::probeDeviceOpen: timeout waiting for sample rate update for device (" << _device << ").");
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Now set the stream format for all streams. Also, check the
|
||||
@ -673,7 +673,7 @@ bool airtaudio::api::Core::probeDeviceOpen(uint32_t _device,
|
||||
result = AudioObjectGetPropertyData(id, &property, 0, NULL, &dataSize, &description);
|
||||
if (result != noErr) {
|
||||
ATA_ERROR("airtaudio::api::Core::probeDeviceOpen: system error (" << getErrorCode(result) << ") getting stream format for device (" << _device << ").");
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
// Set the sample rate and data format id. However, only make the
|
||||
// change if the sample rate is not within 1.0 of the desired
|
||||
@ -691,7 +691,7 @@ bool airtaudio::api::Core::probeDeviceOpen(uint32_t _device,
|
||||
result = AudioObjectSetPropertyData(id, &property, 0, NULL, dataSize, &description);
|
||||
if (result != noErr) {
|
||||
ATA_ERROR("airtaudio::api::Core::probeDeviceOpen: system error (" << getErrorCode(result) << ") setting sample rate or data format for device (" << _device << ").");
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Now check the physical format.
|
||||
@ -699,7 +699,7 @@ bool airtaudio::api::Core::probeDeviceOpen(uint32_t _device,
|
||||
result = AudioObjectGetPropertyData(id, &property, 0, NULL, &dataSize, &description);
|
||||
if (result != noErr) {
|
||||
ATA_ERROR("airtaudio::api::Core::probeDeviceOpen: system error (" << getErrorCode(result) << ") getting stream physical format for device (" << _device << ").");
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
//std::cout << "Current physical stream format:" << std::endl;
|
||||
//std::cout << " mBitsPerChan = " << description.mBitsPerChannel << std::endl;
|
||||
@ -751,7 +751,7 @@ bool airtaudio::api::Core::probeDeviceOpen(uint32_t _device,
|
||||
}
|
||||
if (!setPhysicalFormat) {
|
||||
ATA_ERROR("airtaudio::api::Core::probeDeviceOpen: system error (" << getErrorCode(result) << ") setting physical data format for device (" << _device << ").");
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
} // done setting virtual/physical formats.
|
||||
// Get the stream / device latency.
|
||||
@ -901,7 +901,7 @@ bool airtaudio::api::Core::probeDeviceOpen(uint32_t _device,
|
||||
// Setup the device property listener for over/underload.
|
||||
property.mSelector = kAudioDeviceProcessorOverload;
|
||||
result = AudioObjectAddPropertyListener(id, &property, xrunListener, (void *) handle);
|
||||
return SUCCESS;
|
||||
return true;
|
||||
error:
|
||||
if (handle) {
|
||||
delete handle;
|
||||
@ -918,7 +918,7 @@ error:
|
||||
m_stream.deviceBuffer = 0;
|
||||
}
|
||||
m_stream.state = STREAM_CLOSED;
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
|
||||
enum airtaudio::errorType airtaudio::api::Core::closeStream(void) {
|
||||
@ -1077,11 +1077,11 @@ bool airtaudio::api::Core::callbackEvent(AudioDeviceID _deviceId,
|
||||
const AudioBufferList *_outBufferList) {
|
||||
if ( m_stream.state == STREAM_STOPPED
|
||||
|| m_stream.state == STREAM_STOPPING) {
|
||||
return SUCCESS;
|
||||
return true;
|
||||
}
|
||||
if (m_stream.state == STREAM_CLOSED) {
|
||||
ATA_ERROR("airtaudio::api::Core::callbackEvent(): the stream is closed ... this shouldn't happen!");
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
CallbackInfo *info = (CallbackInfo *) &m_stream.callbackInfo;
|
||||
CoreHandle *handle = (CoreHandle *) m_stream.apiHandle;
|
||||
@ -1094,7 +1094,7 @@ bool airtaudio::api::Core::callbackEvent(AudioDeviceID _deviceId,
|
||||
// external call to stopStream()
|
||||
handle->condition.notify_one();
|
||||
}
|
||||
return SUCCESS;
|
||||
return true;
|
||||
}
|
||||
AudioDeviceID outputDevice = handle->id[0];
|
||||
// Invoke user callback to get fresh output data UNLESS we are
|
||||
@ -1124,7 +1124,7 @@ bool airtaudio::api::Core::callbackEvent(AudioDeviceID _deviceId,
|
||||
m_stream.state = STREAM_STOPPING;
|
||||
handle->drainCounter = 2;
|
||||
abortStream();
|
||||
return SUCCESS;
|
||||
return true;
|
||||
} else if (cbReturnValue == 1) {
|
||||
handle->drainCounter = 1;
|
||||
handle->internalDrain = true;
|
||||
@ -1319,7 +1319,7 @@ bool airtaudio::api::Core::callbackEvent(AudioDeviceID _deviceId,
|
||||
unlock:
|
||||
//m_stream.mutex.unlock();
|
||||
RtApi::tickStreamTime();
|
||||
return SUCCESS;
|
||||
return true;
|
||||
}
|
||||
|
||||
const char* airtaudio::api::Core::getErrorCode(OSStatus _code) {
|
||||
|
1189
airtaudio/api/Ds.cpp
1189
airtaudio/api/Ds.cpp
File diff suppressed because it is too large
Load Diff
@ -275,7 +275,7 @@ bool airtaudio::api::Jack::probeDeviceOpen(uint32_t _device,
|
||||
}
|
||||
if (client == 0) {
|
||||
ATA_ERROR("airtaudio::api::Jack::probeDeviceOpen: Jack server not found or connection error!");
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// The handle must have been created on an earlier pass.
|
||||
@ -306,7 +306,7 @@ bool airtaudio::api::Jack::probeDeviceOpen(uint32_t _device,
|
||||
}
|
||||
if (_device >= nDevices) {
|
||||
ATA_ERROR("airtaudio::api::Jack::probeDeviceOpen: device ID is invalid!");
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
// Count the available ports containing the client name as device
|
||||
// channels. Jack "input ports" equal RtAudio output channels.
|
||||
@ -323,14 +323,14 @@ bool airtaudio::api::Jack::probeDeviceOpen(uint32_t _device,
|
||||
// Compare the jack ports for specified client to the requested number of channels.
|
||||
if (nChannels < (_channels + _firstChannel)) {
|
||||
ATA_ERROR("airtaudio::api::Jack::probeDeviceOpen: requested number of channels (" << _channels << ") + offset (" << _firstChannel << ") not found for specified device (" << _device << ":" << deviceName << ").");
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
// Check the jack server sample rate.
|
||||
uint32_t jackRate = jack_get_sample_rate(client);
|
||||
if (_sampleRate != jackRate) {
|
||||
jack_client_close(client);
|
||||
ATA_ERROR("airtaudio::api::Jack::probeDeviceOpen: the requested sample rate (" << _sampleRate << ") is different than the JACK server rate (" << jackRate << ").");
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
m_stream.sampleRate = jackRate;
|
||||
// Get the latency of the JACK port.
|
||||
@ -463,7 +463,7 @@ bool airtaudio::api::Jack::probeDeviceOpen(uint32_t _device,
|
||||
if (m_stream.doConvertBuffer[_mode]) {
|
||||
setConvertInfo(_mode, 0);
|
||||
}
|
||||
return SUCCESS;
|
||||
return true;
|
||||
error:
|
||||
if (handle) {
|
||||
jack_client_close(handle->client);
|
||||
@ -486,7 +486,7 @@ error:
|
||||
free(m_stream.deviceBuffer);
|
||||
m_stream.deviceBuffer = NULL;
|
||||
}
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
|
||||
enum airtaudio::errorType airtaudio::api::Jack::closeStream(void) {
|
||||
@ -646,15 +646,15 @@ static void jackStopStream(void *_ptr) {
|
||||
bool airtaudio::api::Jack::callbackEvent(uint64_t _nframes) {
|
||||
if ( m_stream.state == STREAM_STOPPED
|
||||
|| m_stream.state == STREAM_STOPPING) {
|
||||
return SUCCESS;
|
||||
return true;
|
||||
}
|
||||
if (m_stream.state == STREAM_CLOSED) {
|
||||
ATA_ERROR("RtApiCore::callbackEvent(): the stream is closed ... this shouldn't happen!");
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
if (m_stream.bufferSize != _nframes) {
|
||||
ATA_ERROR("RtApiCore::callbackEvent(): the JACK buffer size has changed ... cannot process!");
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
CallbackInfo *info = (CallbackInfo *) &m_stream.callbackInfo;
|
||||
JackHandle *handle = (JackHandle *) m_stream.apiHandle;
|
||||
@ -666,7 +666,7 @@ bool airtaudio::api::Jack::callbackEvent(uint64_t _nframes) {
|
||||
} else {
|
||||
handle->condition.notify_one();
|
||||
}
|
||||
return SUCCESS;
|
||||
return true;
|
||||
}
|
||||
// Invoke user callback first, to get fresh output data.
|
||||
if (handle->drainCounter == 0) {
|
||||
@ -691,7 +691,7 @@ bool airtaudio::api::Jack::callbackEvent(uint64_t _nframes) {
|
||||
m_stream.state = STREAM_STOPPING;
|
||||
handle->drainCounter = 2;
|
||||
new std::thread(jackStopStream, info);
|
||||
return SUCCESS;
|
||||
return true;
|
||||
}
|
||||
else if (cbReturnValue == 1) {
|
||||
handle->drainCounter = 1;
|
||||
@ -741,7 +741,7 @@ bool airtaudio::api::Jack::callbackEvent(uint64_t _nframes) {
|
||||
}
|
||||
unlock:
|
||||
airtaudio::Api::tickStreamTime();
|
||||
return SUCCESS;
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -386,22 +386,22 @@ bool airtaudio::api::Pulse::probeDeviceOpen(uint32_t _device,
|
||||
pah = static_cast<PulseAudioHandle *>(m_stream.apiHandle);
|
||||
int32_t error;
|
||||
switch (_mode) {
|
||||
case INPUT:
|
||||
pah->s_rec = pa_simple_new(NULL, "RtAudio", PA_STREAM_RECORD, NULL, "Record", &ss, NULL, NULL, &error);
|
||||
if (!pah->s_rec) {
|
||||
ATA_ERROR("airtaudio::api::Pulse::probeDeviceOpen: error connecting input to PulseAudio server.");
|
||||
case INPUT:
|
||||
pah->s_rec = pa_simple_new(NULL, "RtAudio", PA_STREAM_RECORD, NULL, "Record", &ss, NULL, NULL, &error);
|
||||
if (!pah->s_rec) {
|
||||
ATA_ERROR("airtaudio::api::Pulse::probeDeviceOpen: error connecting input to PulseAudio server.");
|
||||
goto error;
|
||||
}
|
||||
break;
|
||||
case OUTPUT:
|
||||
pah->s_play = pa_simple_new(NULL, "RtAudio", PA_STREAM_PLAYBACK, NULL, "Playback", &ss, NULL, NULL, &error);
|
||||
if (!pah->s_play) {
|
||||
ATA_ERROR("airtaudio::api::Pulse::probeDeviceOpen: error connecting output to PulseAudio server.");
|
||||
goto error;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
goto error;
|
||||
}
|
||||
break;
|
||||
case OUTPUT:
|
||||
pah->s_play = pa_simple_new(NULL, "RtAudio", PA_STREAM_PLAYBACK, NULL, "Playback", &ss, NULL, NULL, &error);
|
||||
if (!pah->s_play) {
|
||||
ATA_ERROR("airtaudio::api::Pulse::probeDeviceOpen: error connecting output to PulseAudio server.");
|
||||
goto error;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
goto error;
|
||||
}
|
||||
if (m_stream.mode == UNINITIALIZED) {
|
||||
m_stream.mode = _mode;
|
||||
@ -436,7 +436,7 @@ error:
|
||||
free(m_stream.deviceBuffer);
|
||||
m_stream.deviceBuffer = 0;
|
||||
}
|
||||
return FAILURE;
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -15,6 +15,7 @@ def create(target):
|
||||
'airtaudio/Interface.cpp',
|
||||
'airtaudio/Api.cpp',
|
||||
'airtaudio/api/Alsa.cpp',
|
||||
'airtaudio/api/Android.cpp',
|
||||
'airtaudio/api/Asio.cpp',
|
||||
'airtaudio/api/Core.cpp',
|
||||
'airtaudio/api/Ds.cpp',
|
||||
@ -46,6 +47,9 @@ def create(target):
|
||||
myModule.add_export_flag_CC(['__MACOSX_CORE__'])
|
||||
myModule.add_export_flag_LD("-framework CoreAudio")
|
||||
myModule.add_export_flag_LD("-framework CoreMIDI")
|
||||
elif target.name=="Android":
|
||||
# MacOsX core
|
||||
myModule.add_export_flag_CC(['__ANDROID_JAVA__'])
|
||||
else:
|
||||
debug.warning("unknow target for RTAudio : " + target.name);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user