[DEV] update etk null
This commit is contained in:
parent
0b8c0e3fd4
commit
28237ad66f
@ -37,8 +37,8 @@ const etk::Vector<uint32_t>& audio::orchestra::genericSampleRate() {
|
|||||||
|
|
||||||
|
|
||||||
audio::orchestra::Api::Api() :
|
audio::orchestra::Api::Api() :
|
||||||
m_callback(nullptr),
|
m_callback(null),
|
||||||
m_deviceBuffer(nullptr) {
|
m_deviceBuffer(null) {
|
||||||
m_device[0] = 11111;
|
m_device[0] = 11111;
|
||||||
m_device[1] = 11111;
|
m_device[1] = 11111;
|
||||||
m_state = audio::orchestra::state::closed;
|
m_state = audio::orchestra::state::closed;
|
||||||
@ -67,19 +67,19 @@ enum audio::orchestra::error audio::orchestra::Api::openStream(audio::orchestra:
|
|||||||
ATA_ERROR("a stream is already open!");
|
ATA_ERROR("a stream is already open!");
|
||||||
return audio::orchestra::error_invalidUse;
|
return audio::orchestra::error_invalidUse;
|
||||||
}
|
}
|
||||||
if ( _oParams != nullptr
|
if ( _oParams != null
|
||||||
&& _oParams->nChannels < 1) {
|
&& _oParams->nChannels < 1) {
|
||||||
ATA_ERROR("a non-nullptr output StreamParameters structure cannot have an nChannels value less than one.");
|
ATA_ERROR("a non-null output StreamParameters structure cannot have an nChannels value less than one.");
|
||||||
return audio::orchestra::error_invalidUse;
|
return audio::orchestra::error_invalidUse;
|
||||||
}
|
}
|
||||||
if ( _iParams != nullptr
|
if ( _iParams != null
|
||||||
&& _iParams->nChannels < 1) {
|
&& _iParams->nChannels < 1) {
|
||||||
ATA_ERROR("a non-nullptr input StreamParameters structure cannot have an nChannels value less than one.");
|
ATA_ERROR("a non-null input StreamParameters structure cannot have an nChannels value less than one.");
|
||||||
return audio::orchestra::error_invalidUse;
|
return audio::orchestra::error_invalidUse;
|
||||||
}
|
}
|
||||||
if ( _oParams == nullptr
|
if ( _oParams == null
|
||||||
&& _iParams == nullptr) {
|
&& _iParams == null) {
|
||||||
ATA_ERROR("input and output StreamParameters structures are both nullptr!");
|
ATA_ERROR("input and output StreamParameters structures are both null!");
|
||||||
return audio::orchestra::error_invalidUse;
|
return audio::orchestra::error_invalidUse;
|
||||||
}
|
}
|
||||||
if (audio::getFormatBytes(_format) == 0) {
|
if (audio::getFormatBytes(_format) == 0) {
|
||||||
@ -88,7 +88,7 @@ enum audio::orchestra::error audio::orchestra::Api::openStream(audio::orchestra:
|
|||||||
}
|
}
|
||||||
uint32_t nDevices = getDeviceCount();
|
uint32_t nDevices = getDeviceCount();
|
||||||
uint32_t oChannels = 0;
|
uint32_t oChannels = 0;
|
||||||
if (_oParams != nullptr) {
|
if (_oParams != null) {
|
||||||
oChannels = _oParams->nChannels;
|
oChannels = _oParams->nChannels;
|
||||||
if ( _oParams->deviceId >= nDevices
|
if ( _oParams->deviceId >= nDevices
|
||||||
&& _oParams->deviceName == "") {
|
&& _oParams->deviceName == "") {
|
||||||
@ -97,7 +97,7 @@ enum audio::orchestra::error audio::orchestra::Api::openStream(audio::orchestra:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
uint32_t iChannels = 0;
|
uint32_t iChannels = 0;
|
||||||
if (_iParams != nullptr) {
|
if (_iParams != null) {
|
||||||
iChannels = _iParams->nChannels;
|
iChannels = _iParams->nChannels;
|
||||||
if ( _iParams->deviceId >= nDevices
|
if ( _iParams->deviceId >= nDevices
|
||||||
&& _iParams->deviceName == "") {
|
&& _iParams->deviceName == "") {
|
||||||
@ -247,8 +247,8 @@ void audio::orchestra::Api::clearStreamInfo() {
|
|||||||
m_userFormat = audio::format_unknow;
|
m_userFormat = audio::format_unknow;
|
||||||
m_startTime = audio::Time();
|
m_startTime = audio::Time();
|
||||||
m_duration = audio::Duration(0);
|
m_duration = audio::Duration(0);
|
||||||
m_deviceBuffer = nullptr;
|
m_deviceBuffer = null;
|
||||||
m_callback = nullptr;
|
m_callback = null;
|
||||||
for (int32_t iii=0; iii<2; ++iii) {
|
for (int32_t iii=0; iii<2; ++iii) {
|
||||||
m_device[iii] = 11111;
|
m_device[iii] = 11111;
|
||||||
m_doConvertBuffer[iii] = false;
|
m_doConvertBuffer[iii] = false;
|
||||||
|
@ -25,9 +25,9 @@ namespace audio {
|
|||||||
const etk::Vector<uint32_t>& genericSampleRate();
|
const etk::Vector<uint32_t>& genericSampleRate();
|
||||||
/**
|
/**
|
||||||
* @brief airtaudio callback function prototype.
|
* @brief airtaudio callback function prototype.
|
||||||
* @param _inputBuffer For input (or duplex) streams, this buffer will hold _nbChunk of input audio chunk (nullptr if no data).
|
* @param _inputBuffer For input (or duplex) streams, this buffer will hold _nbChunk of input audio chunk (null if no data).
|
||||||
* @param _timeInput Timestamp of the first buffer sample (recording time).
|
* @param _timeInput Timestamp of the first buffer sample (recording time).
|
||||||
* @param _outputBuffer For output (or duplex) streams, the client should write _nbChunk of audio chunk into this buffer (nullptr if no data).
|
* @param _outputBuffer For output (or duplex) streams, the client should write _nbChunk of audio chunk into this buffer (null if no data).
|
||||||
* @param _timeOutput Timestamp of the first buffer sample (playing time).
|
* @param _timeOutput Timestamp of the first buffer sample (playing time).
|
||||||
* @param _nbChunk The number of chunk of input or output chunk in the buffer (same size).
|
* @param _nbChunk The number of chunk of input or output chunk in the buffer (same size).
|
||||||
* @param _status List of error that occured in the laps of time.
|
* @param _status List of error that occured in the laps of time.
|
||||||
|
@ -37,7 +37,7 @@ void audio::orchestra::Interface::openApi(const etk::String& _api) {
|
|||||||
if (_api == m_apiAvaillable[iii].first) {
|
if (_api == m_apiAvaillable[iii].first) {
|
||||||
ATA_INFO(" ==> call it");
|
ATA_INFO(" ==> call it");
|
||||||
m_api = m_apiAvaillable[iii].second();
|
m_api = m_apiAvaillable[iii].second();
|
||||||
if (m_api != nullptr) {
|
if (m_api != null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -48,7 +48,7 @@ void audio::orchestra::Interface::openApi(const etk::String& _api) {
|
|||||||
|
|
||||||
|
|
||||||
audio::orchestra::Interface::Interface() :
|
audio::orchestra::Interface::Interface() :
|
||||||
m_api(nullptr) {
|
m_api(null) {
|
||||||
ATA_DEBUG("Add interface:");
|
ATA_DEBUG("Add interface:");
|
||||||
#if defined(ORCHESTRA_BUILD_JACK)
|
#if defined(ORCHESTRA_BUILD_JACK)
|
||||||
addInterface(audio::orchestra::typeJack, audio::orchestra::api::Jack::create);
|
addInterface(audio::orchestra::typeJack, audio::orchestra::api::Jack::create);
|
||||||
@ -85,7 +85,7 @@ void audio::orchestra::Interface::addInterface(const etk::String& _api, ememory:
|
|||||||
|
|
||||||
enum audio::orchestra::error audio::orchestra::Interface::clear() {
|
enum audio::orchestra::error audio::orchestra::Interface::clear() {
|
||||||
ATA_INFO("Clear API ...");
|
ATA_INFO("Clear API ...");
|
||||||
if (m_api == nullptr) {
|
if (m_api == null) {
|
||||||
ATA_WARNING("Interface NOT started!");
|
ATA_WARNING("Interface NOT started!");
|
||||||
return audio::orchestra::error_none;
|
return audio::orchestra::error_none;
|
||||||
}
|
}
|
||||||
@ -95,7 +95,7 @@ enum audio::orchestra::error audio::orchestra::Interface::clear() {
|
|||||||
|
|
||||||
enum audio::orchestra::error audio::orchestra::Interface::instanciate(const etk::String& _api) {
|
enum audio::orchestra::error audio::orchestra::Interface::instanciate(const etk::String& _api) {
|
||||||
ATA_INFO("Instanciate API ...");
|
ATA_INFO("Instanciate API ...");
|
||||||
if (m_api != nullptr) {
|
if (m_api != null) {
|
||||||
ATA_WARNING("Interface already started!");
|
ATA_WARNING("Interface already started!");
|
||||||
return audio::orchestra::error_none;
|
return audio::orchestra::error_none;
|
||||||
}
|
}
|
||||||
@ -103,7 +103,7 @@ enum audio::orchestra::error audio::orchestra::Interface::instanciate(const etk:
|
|||||||
ATA_INFO("API specified : " << _api);
|
ATA_INFO("API specified : " << _api);
|
||||||
// Attempt to open the specified API.
|
// Attempt to open the specified API.
|
||||||
openApi(_api);
|
openApi(_api);
|
||||||
if (m_api != nullptr) {
|
if (m_api != null) {
|
||||||
if (m_api->getDeviceCount() != 0) {
|
if (m_api->getDeviceCount() != 0) {
|
||||||
ATA_INFO(" ==> api open");
|
ATA_INFO(" ==> api open");
|
||||||
}
|
}
|
||||||
@ -122,7 +122,7 @@ enum audio::orchestra::error audio::orchestra::Interface::instanciate(const etk:
|
|||||||
for (size_t iii=0; iii<apis.size(); ++iii) {
|
for (size_t iii=0; iii<apis.size(); ++iii) {
|
||||||
ATA_INFO("try open ...");
|
ATA_INFO("try open ...");
|
||||||
openApi(apis[iii]);
|
openApi(apis[iii]);
|
||||||
if(m_api == nullptr) {
|
if(m_api == null) {
|
||||||
ATA_ERROR(" ==> can not create ...");
|
ATA_ERROR(" ==> can not create ...");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -133,7 +133,7 @@ enum audio::orchestra::error audio::orchestra::Interface::instanciate(const etk:
|
|||||||
ATA_INFO(" ==> Interface exist, but have no devices: " << m_api->getDeviceCount());
|
ATA_INFO(" ==> Interface exist, but have no devices: " << m_api->getDeviceCount());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (m_api != nullptr) {
|
if (m_api != null) {
|
||||||
return audio::orchestra::error_none;
|
return audio::orchestra::error_none;
|
||||||
}
|
}
|
||||||
ATA_ERROR("API NOT Supported '" << _api << "' not in " << getListApi());
|
ATA_ERROR("API NOT Supported '" << _api << "' not in " << getListApi());
|
||||||
@ -152,7 +152,7 @@ enum audio::orchestra::error audio::orchestra::Interface::openStream(audio::orch
|
|||||||
uint32_t* _bufferFrames,
|
uint32_t* _bufferFrames,
|
||||||
audio::orchestra::AirTAudioCallback _callback,
|
audio::orchestra::AirTAudioCallback _callback,
|
||||||
const audio::orchestra::StreamOptions& _options) {
|
const audio::orchestra::StreamOptions& _options) {
|
||||||
if (m_api == nullptr) {
|
if (m_api == null) {
|
||||||
return audio::orchestra::error_inputNull;
|
return audio::orchestra::error_inputNull;
|
||||||
}
|
}
|
||||||
return m_api->openStream(_outputParameters,
|
return m_api->openStream(_outputParameters,
|
||||||
@ -165,12 +165,12 @@ enum audio::orchestra::error audio::orchestra::Interface::openStream(audio::orch
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool audio::orchestra::Interface::isMasterOf(audio::orchestra::Interface& _interface) {
|
bool audio::orchestra::Interface::isMasterOf(audio::orchestra::Interface& _interface) {
|
||||||
if (m_api == nullptr) {
|
if (m_api == null) {
|
||||||
ATA_ERROR("Current Master API is nullptr ...");
|
ATA_ERROR("Current Master API is null ...");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (_interface.m_api == nullptr) {
|
if (_interface.m_api == null) {
|
||||||
ATA_ERROR("Current Slave API is nullptr ...");
|
ATA_ERROR("Current Slave API is null ...");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (m_api->getCurrentApi() != _interface.m_api->getCurrentApi()) {
|
if (m_api->getCurrentApi() != _interface.m_api->getCurrentApi()) {
|
||||||
|
@ -32,7 +32,7 @@ namespace audio {
|
|||||||
ememory::SharedPtr<audio::orchestra::Api> m_api;
|
ememory::SharedPtr<audio::orchestra::Api> m_api;
|
||||||
public:
|
public:
|
||||||
void setName(const etk::String& _name) {
|
void setName(const etk::String& _name) {
|
||||||
if (m_api == nullptr) {
|
if (m_api == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_api->setName(_name);
|
m_api->setName(_name);
|
||||||
@ -72,7 +72,7 @@ namespace audio {
|
|||||||
* @return the audio API specifier for the current instance of airtaudio.
|
* @return the audio API specifier for the current instance of airtaudio.
|
||||||
*/
|
*/
|
||||||
const etk::String& getCurrentApi() {
|
const etk::String& getCurrentApi() {
|
||||||
if (m_api == nullptr) {
|
if (m_api == null) {
|
||||||
return audio::orchestra::typeUndefined;
|
return audio::orchestra::typeUndefined;
|
||||||
}
|
}
|
||||||
return m_api->getCurrentApi();
|
return m_api->getCurrentApi();
|
||||||
@ -85,7 +85,7 @@ namespace audio {
|
|||||||
* a system error occurs during processing, a warning will be issued.
|
* a system error occurs during processing, a warning will be issued.
|
||||||
*/
|
*/
|
||||||
uint32_t getDeviceCount() {
|
uint32_t getDeviceCount() {
|
||||||
if (m_api == nullptr) {
|
if (m_api == null) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return m_api->getDeviceCount();
|
return m_api->getDeviceCount();
|
||||||
@ -102,13 +102,13 @@ namespace audio {
|
|||||||
* @return An audio::orchestra::DeviceInfo structure for a specified device number.
|
* @return An audio::orchestra::DeviceInfo structure for a specified device number.
|
||||||
*/
|
*/
|
||||||
audio::orchestra::DeviceInfo getDeviceInfo(uint32_t _device) {
|
audio::orchestra::DeviceInfo getDeviceInfo(uint32_t _device) {
|
||||||
if (m_api == nullptr) {
|
if (m_api == null) {
|
||||||
return audio::orchestra::DeviceInfo();
|
return audio::orchestra::DeviceInfo();
|
||||||
}
|
}
|
||||||
return m_api->getDeviceInfo(_device);
|
return m_api->getDeviceInfo(_device);
|
||||||
}
|
}
|
||||||
audio::orchestra::DeviceInfo getDeviceInfo(const etk::String& _deviceName) {
|
audio::orchestra::DeviceInfo getDeviceInfo(const etk::String& _deviceName) {
|
||||||
if (m_api == nullptr) {
|
if (m_api == null) {
|
||||||
return audio::orchestra::DeviceInfo();
|
return audio::orchestra::DeviceInfo();
|
||||||
}
|
}
|
||||||
audio::orchestra::DeviceInfo info;
|
audio::orchestra::DeviceInfo info;
|
||||||
@ -125,7 +125,7 @@ namespace audio {
|
|||||||
* before attempting to open a stream.
|
* before attempting to open a stream.
|
||||||
*/
|
*/
|
||||||
uint32_t getDefaultOutputDevice() {
|
uint32_t getDefaultOutputDevice() {
|
||||||
if (m_api == nullptr) {
|
if (m_api == null) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return m_api->getDefaultOutputDevice();
|
return m_api->getDefaultOutputDevice();
|
||||||
@ -140,7 +140,7 @@ namespace audio {
|
|||||||
* before attempting to open a stream.
|
* before attempting to open a stream.
|
||||||
*/
|
*/
|
||||||
uint32_t getDefaultInputDevice() {
|
uint32_t getDefaultInputDevice() {
|
||||||
if (m_api == nullptr) {
|
if (m_api == null) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return m_api->getDefaultInputDevice();
|
return m_api->getDefaultInputDevice();
|
||||||
@ -155,12 +155,12 @@ namespace audio {
|
|||||||
* @param _outputParameters Specifies output stream parameters to use
|
* @param _outputParameters Specifies output stream parameters to use
|
||||||
* when opening a stream, including a device ID, number of channels,
|
* when opening a stream, including a device ID, number of channels,
|
||||||
* and starting channel number. For input-only streams, this
|
* and starting channel number. For input-only streams, this
|
||||||
* argument should be nullptr. The device ID is an index value between
|
* argument should be null. The device ID is an index value between
|
||||||
* 0 and getDeviceCount() - 1.
|
* 0 and getDeviceCount() - 1.
|
||||||
* @param _inputParameters Specifies input stream parameters to use
|
* @param _inputParameters Specifies input stream parameters to use
|
||||||
* when opening a stream, including a device ID, number of channels,
|
* when opening a stream, including a device ID, number of channels,
|
||||||
* and starting channel number. For output-only streams, this
|
* and starting channel number. For output-only streams, this
|
||||||
* argument should be nullptr. The device ID is an index value between
|
* argument should be null. The device ID is an index value between
|
||||||
* 0 and getDeviceCount() - 1.
|
* 0 and getDeviceCount() - 1.
|
||||||
* @param _format An audio::format specifying the desired sample data format.
|
* @param _format An audio::format specifying the desired sample data format.
|
||||||
* @param _sampleRate The desired sample rate (sample frames per second).
|
* @param _sampleRate The desired sample rate (sample frames per second).
|
||||||
@ -198,7 +198,7 @@ namespace audio {
|
|||||||
* returns (no exception is thrown).
|
* returns (no exception is thrown).
|
||||||
*/
|
*/
|
||||||
enum audio::orchestra::error closeStream() {
|
enum audio::orchestra::error closeStream() {
|
||||||
if (m_api == nullptr) {
|
if (m_api == null) {
|
||||||
return audio::orchestra::error_inputNull;
|
return audio::orchestra::error_inputNull;
|
||||||
}
|
}
|
||||||
return m_api->closeStream();
|
return m_api->closeStream();
|
||||||
@ -212,7 +212,7 @@ namespace audio {
|
|||||||
* running.
|
* running.
|
||||||
*/
|
*/
|
||||||
enum audio::orchestra::error startStream() {
|
enum audio::orchestra::error startStream() {
|
||||||
if (m_api == nullptr) {
|
if (m_api == null) {
|
||||||
return audio::orchestra::error_inputNull;
|
return audio::orchestra::error_inputNull;
|
||||||
}
|
}
|
||||||
return m_api->startStream();
|
return m_api->startStream();
|
||||||
@ -226,7 +226,7 @@ namespace audio {
|
|||||||
* stopped.
|
* stopped.
|
||||||
*/
|
*/
|
||||||
enum audio::orchestra::error stopStream() {
|
enum audio::orchestra::error stopStream() {
|
||||||
if (m_api == nullptr) {
|
if (m_api == null) {
|
||||||
return audio::orchestra::error_inputNull;
|
return audio::orchestra::error_inputNull;
|
||||||
}
|
}
|
||||||
return m_api->stopStream();
|
return m_api->stopStream();
|
||||||
@ -239,7 +239,7 @@ namespace audio {
|
|||||||
* stopped.
|
* stopped.
|
||||||
*/
|
*/
|
||||||
enum audio::orchestra::error abortStream() {
|
enum audio::orchestra::error abortStream() {
|
||||||
if (m_api == nullptr) {
|
if (m_api == null) {
|
||||||
return audio::orchestra::error_inputNull;
|
return audio::orchestra::error_inputNull;
|
||||||
}
|
}
|
||||||
return m_api->abortStream();
|
return m_api->abortStream();
|
||||||
@ -248,7 +248,7 @@ namespace audio {
|
|||||||
* @return true if a stream is open and false if not.
|
* @return true if a stream is open and false if not.
|
||||||
*/
|
*/
|
||||||
bool isStreamOpen() const {
|
bool isStreamOpen() const {
|
||||||
if (m_api == nullptr) {
|
if (m_api == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return m_api->isStreamOpen();
|
return m_api->isStreamOpen();
|
||||||
@ -257,7 +257,7 @@ namespace audio {
|
|||||||
* @return true if the stream is running and false if it is stopped or not open.
|
* @return true if the stream is running and false if it is stopped or not open.
|
||||||
*/
|
*/
|
||||||
bool isStreamRunning() const {
|
bool isStreamRunning() const {
|
||||||
if (m_api == nullptr) {
|
if (m_api == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return m_api->isStreamRunning();
|
return m_api->isStreamRunning();
|
||||||
@ -267,7 +267,7 @@ namespace audio {
|
|||||||
* @return the number of elapsed seconds since the stream was started.
|
* @return the number of elapsed seconds since the stream was started.
|
||||||
*/
|
*/
|
||||||
audio::Time getStreamTime() {
|
audio::Time getStreamTime() {
|
||||||
if (m_api == nullptr) {
|
if (m_api == null) {
|
||||||
return audio::Time();
|
return audio::Time();
|
||||||
}
|
}
|
||||||
return m_api->getStreamTime();
|
return m_api->getStreamTime();
|
||||||
@ -282,7 +282,7 @@ namespace audio {
|
|||||||
* @return The internal stream latency in sample frames.
|
* @return The internal stream latency in sample frames.
|
||||||
*/
|
*/
|
||||||
long getStreamLatency() {
|
long getStreamLatency() {
|
||||||
if (m_api == nullptr) {
|
if (m_api == null) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return m_api->getStreamLatency();
|
return m_api->getStreamLatency();
|
||||||
@ -294,7 +294,7 @@ namespace audio {
|
|||||||
* @return Returns actual sample rate in use by the stream.
|
* @return Returns actual sample rate in use by the stream.
|
||||||
*/
|
*/
|
||||||
uint32_t getStreamSampleRate() {
|
uint32_t getStreamSampleRate() {
|
||||||
if (m_api == nullptr) {
|
if (m_api == null) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return m_api->getStreamSampleRate();
|
return m_api->getStreamSampleRate();
|
||||||
|
@ -47,9 +47,9 @@ namespace audio {
|
|||||||
enum timestampMode timeMode; //!< the timestamp of the flow came from the harware.
|
enum timestampMode timeMode; //!< the timestamp of the flow came from the harware.
|
||||||
etk::Vector<snd_pcm_channel_area_t> areas;
|
etk::Vector<snd_pcm_channel_area_t> areas;
|
||||||
AlsaPrivate() :
|
AlsaPrivate() :
|
||||||
handle(nullptr),
|
handle(null),
|
||||||
runnable(false),
|
runnable(false),
|
||||||
thread(nullptr),
|
thread(null),
|
||||||
threadRunning(false),
|
threadRunning(false),
|
||||||
mmapInterface(false),
|
mmapInterface(false),
|
||||||
timeMode(timestampMode_soft) {
|
timeMode(timestampMode_soft) {
|
||||||
@ -674,7 +674,7 @@ bool audio::orchestra::api::Alsa::openName(const etk::String& _deviceName,
|
|||||||
}
|
}
|
||||||
snd_pcm_uframes_t val;
|
snd_pcm_uframes_t val;
|
||||||
// Set the software configuration to fill buffers with zeros and prevent device stopping on xruns.
|
// Set the software configuration to fill buffers with zeros and prevent device stopping on xruns.
|
||||||
snd_pcm_sw_params_t *swParams = nullptr;
|
snd_pcm_sw_params_t *swParams = null;
|
||||||
snd_pcm_sw_params_alloca(&swParams);
|
snd_pcm_sw_params_alloca(&swParams);
|
||||||
snd_pcm_sw_params_current(m_private->handle, swParams);
|
snd_pcm_sw_params_current(m_private->handle, swParams);
|
||||||
#if 0
|
#if 0
|
||||||
@ -781,10 +781,10 @@ bool audio::orchestra::api::Alsa::openName(const etk::String& _deviceName,
|
|||||||
bufferBytes *= *_bufferSize;
|
bufferBytes *= *_bufferSize;
|
||||||
if (m_deviceBuffer) {
|
if (m_deviceBuffer) {
|
||||||
free(m_deviceBuffer);
|
free(m_deviceBuffer);
|
||||||
m_deviceBuffer = nullptr;
|
m_deviceBuffer = null;
|
||||||
}
|
}
|
||||||
m_deviceBuffer = (char *) calloc(bufferBytes, 1);
|
m_deviceBuffer = (char *) calloc(bufferBytes, 1);
|
||||||
if (m_deviceBuffer == nullptr) {
|
if (m_deviceBuffer == null) {
|
||||||
ATA_ERROR("error allocating device buffer memory.");
|
ATA_ERROR("error allocating device buffer memory.");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -802,7 +802,7 @@ bool audio::orchestra::api::Alsa::openName(const etk::String& _deviceName,
|
|||||||
m_private->threadRunning = true;
|
m_private->threadRunning = true;
|
||||||
ATA_INFO("create thread ...");
|
ATA_INFO("create thread ...");
|
||||||
m_private->thread = ETK_NEW(ethread::Thread, [=]() {callbackEvent();});
|
m_private->thread = ETK_NEW(ethread::Thread, [=]() {callbackEvent();});
|
||||||
if (m_private->thread == nullptr) {
|
if (m_private->thread == null) {
|
||||||
m_private->threadRunning = false;
|
m_private->threadRunning = false;
|
||||||
ATA_ERROR("creating callback thread!");
|
ATA_ERROR("creating callback thread!");
|
||||||
goto error;
|
goto error;
|
||||||
@ -812,7 +812,7 @@ bool audio::orchestra::api::Alsa::openName(const etk::String& _deviceName,
|
|||||||
error:
|
error:
|
||||||
if (m_private->handle) {
|
if (m_private->handle) {
|
||||||
snd_pcm_close(m_private->handle);
|
snd_pcm_close(m_private->handle);
|
||||||
m_private->handle = nullptr;
|
m_private->handle = null;
|
||||||
}
|
}
|
||||||
for (int32_t iii=0; iii<2; ++iii) {
|
for (int32_t iii=0; iii<2; ++iii) {
|
||||||
m_userBuffer[iii].clear();
|
m_userBuffer[iii].clear();
|
||||||
@ -837,9 +837,9 @@ enum audio::orchestra::error audio::orchestra::api::Alsa::closeStream() {
|
|||||||
m_private->m_semaphore.post();
|
m_private->m_semaphore.post();
|
||||||
}
|
}
|
||||||
m_mutex.unLock();
|
m_mutex.unLock();
|
||||||
if (m_private->thread != nullptr) {
|
if (m_private->thread != null) {
|
||||||
m_private->thread->join();
|
m_private->thread->join();
|
||||||
m_private->thread = nullptr;
|
m_private->thread = null;
|
||||||
}
|
}
|
||||||
if (m_state == audio::orchestra::state::running) {
|
if (m_state == audio::orchestra::state::running) {
|
||||||
m_state = audio::orchestra::state::stopped;
|
m_state = audio::orchestra::state::stopped;
|
||||||
@ -848,7 +848,7 @@ enum audio::orchestra::error audio::orchestra::api::Alsa::closeStream() {
|
|||||||
// close all stream :
|
// close all stream :
|
||||||
if (m_private->handle) {
|
if (m_private->handle) {
|
||||||
snd_pcm_close(m_private->handle);
|
snd_pcm_close(m_private->handle);
|
||||||
m_private->handle = nullptr;
|
m_private->handle = null;
|
||||||
}
|
}
|
||||||
for (int32_t iii=0; iii<2; ++iii) {
|
for (int32_t iii=0; iii<2; ++iii) {
|
||||||
m_userBuffer[iii].clear();
|
m_userBuffer[iii].clear();
|
||||||
@ -880,8 +880,8 @@ enum audio::orchestra::error audio::orchestra::api::Alsa::startStream() {
|
|||||||
ATA_DEBUG("Lock (done)");
|
ATA_DEBUG("Lock (done)");
|
||||||
int32_t result = 0;
|
int32_t result = 0;
|
||||||
snd_pcm_state_t state;
|
snd_pcm_state_t state;
|
||||||
if (m_private->handle == nullptr) {
|
if (m_private->handle == null) {
|
||||||
ATA_ERROR("send nullptr to alsa ...");
|
ATA_ERROR("send null to alsa ...");
|
||||||
}
|
}
|
||||||
ATA_DEBUG("snd_pcm_state");
|
ATA_DEBUG("snd_pcm_state");
|
||||||
state = snd_pcm_state(m_private->handle);
|
state = snd_pcm_state(m_private->handle);
|
||||||
@ -1031,7 +1031,7 @@ void audio::orchestra::api::Alsa::callbackEvent() {
|
|||||||
audio::Time audio::orchestra::api::Alsa::getStreamTime() {
|
audio::Time audio::orchestra::api::Alsa::getStreamTime() {
|
||||||
//ATA_DEBUG("mode : " << m_private->timeMode);
|
//ATA_DEBUG("mode : " << m_private->timeMode);
|
||||||
if (m_private->timeMode == timestampMode_Hardware) {
|
if (m_private->timeMode == timestampMode_Hardware) {
|
||||||
snd_pcm_status_t *status = nullptr;
|
snd_pcm_status_t *status = null;
|
||||||
snd_pcm_status_alloca(&status);
|
snd_pcm_status_alloca(&status);
|
||||||
// get harware timestamp all the time:
|
// get harware timestamp all the time:
|
||||||
snd_pcm_status(m_private->handle, status);
|
snd_pcm_status(m_private->handle, status);
|
||||||
@ -1066,7 +1066,7 @@ audio::Time audio::orchestra::api::Alsa::getStreamTime() {
|
|||||||
return m_startTime;
|
return m_startTime;
|
||||||
} else if (m_private->timeMode == timestampMode_trigered) {
|
} else if (m_private->timeMode == timestampMode_trigered) {
|
||||||
if (m_startTime == audio::Time()) {
|
if (m_startTime == audio::Time()) {
|
||||||
snd_pcm_status_t *status = nullptr;
|
snd_pcm_status_t *status = null;
|
||||||
snd_pcm_status_alloca(&status);
|
snd_pcm_status_alloca(&status);
|
||||||
// get harware timestamp all the time:
|
// get harware timestamp all the time:
|
||||||
snd_pcm_status(m_private->handle, status);
|
snd_pcm_status(m_private->handle, status);
|
||||||
@ -1192,7 +1192,7 @@ noInput:
|
|||||||
audio::Time startCall = audio::Time::now();
|
audio::Time startCall = audio::Time::now();
|
||||||
doStopStream = m_callback(&m_userBuffer[1][0],
|
doStopStream = m_callback(&m_userBuffer[1][0],
|
||||||
streamTime,// - audio::Duration(m_latency[1]*1000000000LL/int64_t(m_sampleRate)),
|
streamTime,// - audio::Duration(m_latency[1]*1000000000LL/int64_t(m_sampleRate)),
|
||||||
nullptr,
|
null,
|
||||||
audio::Time(),
|
audio::Time(),
|
||||||
m_bufferSize,
|
m_bufferSize,
|
||||||
status);
|
status);
|
||||||
@ -1240,7 +1240,7 @@ void audio::orchestra::api::Alsa::callbackEventOneCycleWrite() {
|
|||||||
streamTime = getStreamTime();
|
streamTime = getStreamTime();
|
||||||
{
|
{
|
||||||
audio::Time startCall = audio::Time::now();
|
audio::Time startCall = audio::Time::now();
|
||||||
doStopStream = m_callback(nullptr,
|
doStopStream = m_callback(null,
|
||||||
audio::Time(),
|
audio::Time(),
|
||||||
&m_userBuffer[0][0],
|
&m_userBuffer[0][0],
|
||||||
streamTime,// + audio::Duration(m_latency[0]*1000000000LL/int64_t(m_sampleRate)),
|
streamTime,// + audio::Duration(m_latency[0]*1000000000LL/int64_t(m_sampleRate)),
|
||||||
@ -1346,7 +1346,7 @@ void audio::orchestra::api::Alsa::callbackEventOneCycleMMAPWrite() {
|
|||||||
streamTime = getStreamTime();
|
streamTime = getStreamTime();
|
||||||
{
|
{
|
||||||
audio::Time startCall = audio::Time::now();
|
audio::Time startCall = audio::Time::now();
|
||||||
doStopStream = m_callback(nullptr,
|
doStopStream = m_callback(null,
|
||||||
audio::Time(),
|
audio::Time(),
|
||||||
&m_userBuffer[0][0],
|
&m_userBuffer[0][0],
|
||||||
streamTime,// + audio::Duration(m_latency[0]*1000000000LL/int64_t(m_sampleRate)),
|
streamTime,// + audio::Duration(m_latency[0]*1000000000LL/int64_t(m_sampleRate)),
|
||||||
@ -1396,7 +1396,7 @@ void audio::orchestra::api::Alsa::callbackEventOneCycleMMAPWrite() {
|
|||||||
// TODO: Understand why this does not work ...
|
// TODO: Understand why this does not work ...
|
||||||
// Write samples to device in interleaved/non-interleaved format.
|
// Write samples to device in interleaved/non-interleaved format.
|
||||||
if (m_deviceInterleaved[0]) {
|
if (m_deviceInterleaved[0]) {
|
||||||
const snd_pcm_channel_area_t* myAreas = nullptr;
|
const snd_pcm_channel_area_t* myAreas = null;
|
||||||
snd_pcm_uframes_t offset, frames;
|
snd_pcm_uframes_t offset, frames;
|
||||||
frames = m_bufferSize;
|
frames = m_bufferSize;
|
||||||
ATA_DEBUG("START");
|
ATA_DEBUG("START");
|
||||||
@ -1548,7 +1548,7 @@ noInput:
|
|||||||
audio::Time startCall = audio::Time::now();
|
audio::Time startCall = audio::Time::now();
|
||||||
doStopStream = m_callback(&m_userBuffer[1][0],
|
doStopStream = m_callback(&m_userBuffer[1][0],
|
||||||
streamTime,// - audio::Duration(m_latency[1]*1000000000LL/int64_t(m_sampleRate)),
|
streamTime,// - audio::Duration(m_latency[1]*1000000000LL/int64_t(m_sampleRate)),
|
||||||
nullptr,
|
null,
|
||||||
audio::Time(),
|
audio::Time(),
|
||||||
m_bufferSize,
|
m_bufferSize,
|
||||||
status);
|
status);
|
||||||
@ -1573,7 +1573,7 @@ unlock:
|
|||||||
|
|
||||||
bool audio::orchestra::api::Alsa::isMasterOf(ememory::SharedPtr<audio::orchestra::Api> _api) {
|
bool audio::orchestra::api::Alsa::isMasterOf(ememory::SharedPtr<audio::orchestra::Api> _api) {
|
||||||
ememory::SharedPtr<audio::orchestra::api::Alsa> slave = ememory::dynamicPointerCast<audio::orchestra::api::Alsa>(_api);
|
ememory::SharedPtr<audio::orchestra::api::Alsa> slave = ememory::dynamicPointerCast<audio::orchestra::api::Alsa>(_api);
|
||||||
if (slave == nullptr) {
|
if (slave == null) {
|
||||||
ATA_ERROR("NULL ptr API (not ALSA ...)");
|
ATA_ERROR("NULL ptr API (not ALSA ...)");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1585,11 +1585,11 @@ bool audio::orchestra::api::Alsa::isMasterOf(ememory::SharedPtr<audio::orchestra
|
|||||||
ATA_ERROR("The SLAVE stream is already running! ==> can not synchronize ...");
|
ATA_ERROR("The SLAVE stream is already running! ==> can not synchronize ...");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
snd_pcm_t * master = nullptr;
|
snd_pcm_t * master = null;
|
||||||
if (m_private->handle != nullptr) {
|
if (m_private->handle != null) {
|
||||||
master = m_private->handle;
|
master = m_private->handle;
|
||||||
}
|
}
|
||||||
if (master == nullptr) {
|
if (master == null) {
|
||||||
ATA_ERROR("No ALSA handles ...");
|
ATA_ERROR("No ALSA handles ...");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ enum audio::orchestra::error audio::orchestra::api::Android::abortStream() {
|
|||||||
|
|
||||||
void audio::orchestra::api::Android::playback(int16_t* _dst, int32_t _nbChunk) {
|
void audio::orchestra::api::Android::playback(int16_t* _dst, int32_t _nbChunk) {
|
||||||
// clear output buffer:
|
// clear output buffer:
|
||||||
if (_dst != nullptr) {
|
if (_dst != null) {
|
||||||
memset(_dst, 0, _nbChunk*audio::getFormatBytes(m_deviceFormat[modeToIdTable(m_mode)])*m_nDeviceChannels[modeToIdTable(m_mode)]);
|
memset(_dst, 0, _nbChunk*audio::getFormatBytes(m_deviceFormat[modeToIdTable(m_mode)])*m_nDeviceChannels[modeToIdTable(m_mode)]);
|
||||||
}
|
}
|
||||||
int32_t doStopStream = 0;
|
int32_t doStopStream = 0;
|
||||||
@ -79,7 +79,7 @@ void audio::orchestra::api::Android::playback(int16_t* _dst, int32_t _nbChunk) {
|
|||||||
etk::Vector<enum audio::orchestra::status> status;
|
etk::Vector<enum audio::orchestra::status> status;
|
||||||
if (m_doConvertBuffer[modeToIdTable(m_mode)] == true) {
|
if (m_doConvertBuffer[modeToIdTable(m_mode)] == true) {
|
||||||
ATA_VERBOSE("Need playback data " << int32_t(_nbChunk) << " userbuffer size = " << m_userBuffer[audio::orchestra::mode_output].size() << "pointer=" << int64_t(&m_userBuffer[audio::orchestra::mode_output][0]));
|
ATA_VERBOSE("Need playback data " << int32_t(_nbChunk) << " userbuffer size = " << m_userBuffer[audio::orchestra::mode_output].size() << "pointer=" << int64_t(&m_userBuffer[audio::orchestra::mode_output][0]));
|
||||||
doStopStream = m_callback(nullptr,
|
doStopStream = m_callback(null,
|
||||||
audio::Time(),
|
audio::Time(),
|
||||||
&m_userBuffer[m_mode][0],
|
&m_userBuffer[m_mode][0],
|
||||||
streamTime,
|
streamTime,
|
||||||
@ -88,7 +88,7 @@ void audio::orchestra::api::Android::playback(int16_t* _dst, int32_t _nbChunk) {
|
|||||||
convertBuffer((char*)_dst, (char*)&m_userBuffer[audio::orchestra::mode_output][0], m_convertInfo[audio::orchestra::mode_output]);
|
convertBuffer((char*)_dst, (char*)&m_userBuffer[audio::orchestra::mode_output][0], m_convertInfo[audio::orchestra::mode_output]);
|
||||||
} else {
|
} else {
|
||||||
ATA_VERBOSE("Need playback data " << int32_t(_nbChunk) << " pointer=" << int64_t(_dst));
|
ATA_VERBOSE("Need playback data " << int32_t(_nbChunk) << " pointer=" << int64_t(_dst));
|
||||||
doStopStream = m_callback(nullptr,
|
doStopStream = m_callback(null,
|
||||||
audio::Time(),
|
audio::Time(),
|
||||||
_dst,
|
_dst,
|
||||||
streamTime,
|
streamTime,
|
||||||
@ -112,7 +112,7 @@ void audio::orchestra::api::Android::record(int16_t* _dst, int32_t _nbChunk) {
|
|||||||
convertBuffer((char*)&m_userBuffer[audio::orchestra::mode_input][0], (char*)_dst, m_convertInfo[audio::orchestra::mode_input]);
|
convertBuffer((char*)&m_userBuffer[audio::orchestra::mode_input][0], (char*)_dst, m_convertInfo[audio::orchestra::mode_input]);
|
||||||
doStopStream = m_callback(&m_userBuffer[m_mode][0],
|
doStopStream = m_callback(&m_userBuffer[m_mode][0],
|
||||||
streamTime,
|
streamTime,
|
||||||
nullptr,
|
null,
|
||||||
audio::Time(),
|
audio::Time(),
|
||||||
uint32_t(_nbChunk),
|
uint32_t(_nbChunk),
|
||||||
status);
|
status);
|
||||||
@ -120,7 +120,7 @@ void audio::orchestra::api::Android::record(int16_t* _dst, int32_t _nbChunk) {
|
|||||||
ATA_VERBOSE("Need playback data " << int32_t(_nbChunk) << " pointer=" << int64_t(_dst));
|
ATA_VERBOSE("Need playback data " << int32_t(_nbChunk) << " pointer=" << int64_t(_dst));
|
||||||
doStopStream = m_callback(_dst,
|
doStopStream = m_callback(_dst,
|
||||||
streamTime,
|
streamTime,
|
||||||
nullptr,
|
null,
|
||||||
audio::Time(),
|
audio::Time(),
|
||||||
uint32_t(_nbChunk),
|
uint32_t(_nbChunk),
|
||||||
status);
|
status);
|
||||||
|
@ -37,19 +37,19 @@ class AndroidOrchestraContext {
|
|||||||
private:
|
private:
|
||||||
bool safeInitMethodID(jmethodID& _mid, jclass& _cls, const char* _name, const char* _sign) {
|
bool safeInitMethodID(jmethodID& _mid, jclass& _cls, const char* _name, const char* _sign) {
|
||||||
_mid = m_JavaVirtualMachinePointer->GetMethodID(_cls, _name, _sign);
|
_mid = m_JavaVirtualMachinePointer->GetMethodID(_cls, _name, _sign);
|
||||||
if(_mid == nullptr) {
|
if(_mid == null) {
|
||||||
ATA_ERROR("C->java : Can't find the method " << _name);
|
ATA_ERROR("C->java : Can't find the method " << _name);
|
||||||
/* remove access on the virtual machine : */
|
/* remove access on the virtual machine : */
|
||||||
m_JavaVirtualMachinePointer = nullptr;
|
m_JavaVirtualMachinePointer = null;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool java_attach_current_thread(int *_rstatus) {
|
bool java_attach_current_thread(int *_rstatus) {
|
||||||
ATA_DEBUG("C->java : call java");
|
ATA_DEBUG("C->java : call java");
|
||||||
if (jvm_basics::getJavaVM() == nullptr) {
|
if (jvm_basics::getJavaVM() == null) {
|
||||||
ATA_ERROR("C->java : JVM not initialised");
|
ATA_ERROR("C->java : JVM not initialised");
|
||||||
m_JavaVirtualMachinePointer = nullptr;
|
m_JavaVirtualMachinePointer = null;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
*_rstatus = jvm_basics::getJavaVM()->GetEnv((void **) &m_JavaVirtualMachinePointer, JNI_VERSION_1_6);
|
*_rstatus = jvm_basics::getJavaVM()->GetEnv((void **) &m_JavaVirtualMachinePointer, JNI_VERSION_1_6);
|
||||||
@ -57,12 +57,12 @@ class AndroidOrchestraContext {
|
|||||||
JavaVMAttachArgs lJavaVMAttachArgs;
|
JavaVMAttachArgs lJavaVMAttachArgs;
|
||||||
lJavaVMAttachArgs.version = JNI_VERSION_1_6;
|
lJavaVMAttachArgs.version = JNI_VERSION_1_6;
|
||||||
lJavaVMAttachArgs.name = "EwolNativeThread";
|
lJavaVMAttachArgs.name = "EwolNativeThread";
|
||||||
lJavaVMAttachArgs.group = nullptr;
|
lJavaVMAttachArgs.group = null;
|
||||||
int status = jvm_basics::getJavaVM()->AttachCurrentThread(&m_JavaVirtualMachinePointer, &lJavaVMAttachArgs);
|
int status = jvm_basics::getJavaVM()->AttachCurrentThread(&m_JavaVirtualMachinePointer, &lJavaVMAttachArgs);
|
||||||
jvm_basics::checkExceptionJavaVM(m_JavaVirtualMachinePointer);
|
jvm_basics::checkExceptionJavaVM(m_JavaVirtualMachinePointer);
|
||||||
if (status != JNI_OK) {
|
if (status != JNI_OK) {
|
||||||
ATA_ERROR("C->java : AttachCurrentThread failed : " << status);
|
ATA_ERROR("C->java : AttachCurrentThread failed : " << status);
|
||||||
m_JavaVirtualMachinePointer = nullptr;
|
m_JavaVirtualMachinePointer = null;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -71,13 +71,13 @@ class AndroidOrchestraContext {
|
|||||||
void java_detach_current_thread(int _status) {
|
void java_detach_current_thread(int _status) {
|
||||||
if(_status == JNI_EDETACHED) {
|
if(_status == JNI_EDETACHED) {
|
||||||
jvm_basics::getJavaVM()->DetachCurrentThread();
|
jvm_basics::getJavaVM()->DetachCurrentThread();
|
||||||
m_JavaVirtualMachinePointer = nullptr;
|
m_JavaVirtualMachinePointer = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AndroidOrchestraContext(JNIEnv* _env, jclass _classBase, jobject _objCallback) :
|
AndroidOrchestraContext(JNIEnv* _env, jclass _classBase, jobject _objCallback) :
|
||||||
m_JavaVirtualMachinePointer(nullptr),
|
m_JavaVirtualMachinePointer(null),
|
||||||
m_javaClassOrchestra(0),
|
m_javaClassOrchestra(0),
|
||||||
m_javaClassOrchestraCallback(0),
|
m_javaClassOrchestraCallback(0),
|
||||||
m_javaObjectOrchestraCallback(0),
|
m_javaObjectOrchestraCallback(0),
|
||||||
@ -95,7 +95,7 @@ class AndroidOrchestraContext {
|
|||||||
ATA_DEBUG("*******************************************");
|
ATA_DEBUG("*******************************************");
|
||||||
m_JavaVirtualMachinePointer = _env;
|
m_JavaVirtualMachinePointer = _env;
|
||||||
// get default needed all time elements :
|
// get default needed all time elements :
|
||||||
if (m_JavaVirtualMachinePointer == nullptr) {
|
if (m_JavaVirtualMachinePointer == null) {
|
||||||
ATA_ERROR("C->java: NULLPTR jvm interface");
|
ATA_ERROR("C->java: NULLPTR jvm interface");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -104,15 +104,15 @@ class AndroidOrchestraContext {
|
|||||||
if (m_javaClassOrchestra == 0) {
|
if (m_javaClassOrchestra == 0) {
|
||||||
ATA_ERROR("C->java : Can't find org/musicdsp/orchestra/OrchestraNative class");
|
ATA_ERROR("C->java : Can't find org/musicdsp/orchestra/OrchestraNative class");
|
||||||
// remove access on the virtual machine :
|
// remove access on the virtual machine :
|
||||||
m_JavaVirtualMachinePointer = nullptr;
|
m_JavaVirtualMachinePointer = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* The object field extends Activity and implement OrchestraCallback */
|
/* The object field extends Activity and implement OrchestraCallback */
|
||||||
m_javaClassOrchestraCallback = m_JavaVirtualMachinePointer->GetObjectClass(_objCallback);
|
m_javaClassOrchestraCallback = m_JavaVirtualMachinePointer->GetObjectClass(_objCallback);
|
||||||
if(m_javaClassOrchestraCallback == nullptr) {
|
if(m_javaClassOrchestraCallback == null) {
|
||||||
ATA_ERROR("C->java : Can't find org/musicdsp/orchestra/OrchestraManagerCallback class");
|
ATA_ERROR("C->java : Can't find org/musicdsp/orchestra/OrchestraManagerCallback class");
|
||||||
// remove access on the virtual machine :
|
// remove access on the virtual machine :
|
||||||
m_JavaVirtualMachinePointer = nullptr;
|
m_JavaVirtualMachinePointer = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bool functionCallbackIsMissing = false;
|
bool functionCallbackIsMissing = false;
|
||||||
@ -185,7 +185,7 @@ class AndroidOrchestraContext {
|
|||||||
|
|
||||||
|
|
||||||
m_javaObjectOrchestraCallback = _env->NewGlobalRef(_objCallback);
|
m_javaObjectOrchestraCallback = _env->NewGlobalRef(_objCallback);
|
||||||
if (m_javaObjectOrchestraCallback == nullptr) {
|
if (m_javaObjectOrchestraCallback == null) {
|
||||||
functionCallbackIsMissing = true;
|
functionCallbackIsMissing = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,7 +193,7 @@ class AndroidOrchestraContext {
|
|||||||
if (m_javaDefaultClassString == 0) {
|
if (m_javaDefaultClassString == 0) {
|
||||||
ATA_ERROR("C->java : Can't find java/lang/String" );
|
ATA_ERROR("C->java : Can't find java/lang/String" );
|
||||||
// remove access on the virtual machine :
|
// remove access on the virtual machine :
|
||||||
m_JavaVirtualMachinePointer = nullptr;
|
m_JavaVirtualMachinePointer = null;
|
||||||
functionCallbackIsMissing = true;
|
functionCallbackIsMissing = true;
|
||||||
}
|
}
|
||||||
if (functionCallbackIsMissing == true) {
|
if (functionCallbackIsMissing == true) {
|
||||||
@ -207,7 +207,7 @@ class AndroidOrchestraContext {
|
|||||||
|
|
||||||
void unInit(JNIEnv* _env) {
|
void unInit(JNIEnv* _env) {
|
||||||
_env->DeleteGlobalRef(m_javaObjectOrchestraCallback);
|
_env->DeleteGlobalRef(m_javaObjectOrchestraCallback);
|
||||||
m_javaObjectOrchestraCallback = nullptr;
|
m_javaObjectOrchestraCallback = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t getDeviceCount() {
|
uint32_t getDeviceCount() {
|
||||||
@ -236,7 +236,7 @@ class AndroidOrchestraContext {
|
|||||||
}
|
}
|
||||||
//Call java ...
|
//Call java ...
|
||||||
jstring returnString = (jstring) m_JavaVirtualMachinePointer->CallObjectMethod(m_javaObjectOrchestraCallback, m_javaMethodOrchestraActivityAudioGetDeviceProperty, _idDevice);
|
jstring returnString = (jstring) m_JavaVirtualMachinePointer->CallObjectMethod(m_javaObjectOrchestraCallback, m_javaMethodOrchestraActivityAudioGetDeviceProperty, _idDevice);
|
||||||
const char *js = m_JavaVirtualMachinePointer->GetStringUTFChars(returnString, nullptr);
|
const char *js = m_JavaVirtualMachinePointer->GetStringUTFChars(returnString, null);
|
||||||
etk::String retString(js);
|
etk::String retString(js);
|
||||||
m_JavaVirtualMachinePointer->ReleaseStringUTFChars(returnString, js);
|
m_JavaVirtualMachinePointer->ReleaseStringUTFChars(returnString, js);
|
||||||
//m_JavaVirtualMachinePointer->DeleteLocalRef(returnString);
|
//m_JavaVirtualMachinePointer->DeleteLocalRef(returnString);
|
||||||
@ -371,7 +371,7 @@ class AndroidOrchestraContext {
|
|||||||
auto it = m_instanceList.begin();
|
auto it = m_instanceList.begin();
|
||||||
while (it != m_instanceList.end()) {
|
while (it != m_instanceList.end()) {
|
||||||
auto elem = it->lock();
|
auto elem = it->lock();
|
||||||
if (elem == nullptr) {
|
if (elem == null) {
|
||||||
it = m_instanceList.erase(it);
|
it = m_instanceList.erase(it);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -385,7 +385,7 @@ class AndroidOrchestraContext {
|
|||||||
auto it = m_instanceList.begin();
|
auto it = m_instanceList.begin();
|
||||||
while (it != m_instanceList.end()) {
|
while (it != m_instanceList.end()) {
|
||||||
auto elem = it->lock();
|
auto elem = it->lock();
|
||||||
if (elem == nullptr) {
|
if (elem == null) {
|
||||||
it = m_instanceList.erase(it);
|
it = m_instanceList.erase(it);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -402,7 +402,7 @@ static int32_t s_nbContextRequested(0);
|
|||||||
|
|
||||||
|
|
||||||
uint32_t audio::orchestra::api::android::getDeviceCount() {
|
uint32_t audio::orchestra::api::android::getDeviceCount() {
|
||||||
if (s_localContext == nullptr) {
|
if (s_localContext == null) {
|
||||||
ATA_ERROR("Have no Orchertra API instanciate in JAVA ...");
|
ATA_ERROR("Have no Orchertra API instanciate in JAVA ...");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -410,7 +410,7 @@ uint32_t audio::orchestra::api::android::getDeviceCount() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
audio::orchestra::DeviceInfo audio::orchestra::api::android::getDeviceInfo(uint32_t _device) {
|
audio::orchestra::DeviceInfo audio::orchestra::api::android::getDeviceInfo(uint32_t _device) {
|
||||||
if (s_localContext == nullptr) {
|
if (s_localContext == null) {
|
||||||
return audio::orchestra::DeviceInfo();
|
return audio::orchestra::DeviceInfo();
|
||||||
}
|
}
|
||||||
return s_localContext->getDeviceInfo(_device);
|
return s_localContext->getDeviceInfo(_device);
|
||||||
@ -425,35 +425,35 @@ int32_t audio::orchestra::api::android::open(uint32_t _device,
|
|||||||
uint32_t *_bufferSize,
|
uint32_t *_bufferSize,
|
||||||
const audio::orchestra::StreamOptions& _options,
|
const audio::orchestra::StreamOptions& _options,
|
||||||
ememory::SharedPtr<audio::orchestra::api::Android> _instance) {
|
ememory::SharedPtr<audio::orchestra::api::Android> _instance) {
|
||||||
if (s_localContext == nullptr) {
|
if (s_localContext == null) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return s_localContext->open(_device, _mode, _channels, _firstChannel, _sampleRate, _format, _bufferSize, _options, _instance);
|
return s_localContext->open(_device, _mode, _channels, _firstChannel, _sampleRate, _format, _bufferSize, _options, _instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum audio::orchestra::error audio::orchestra::api::android::closeStream(int32_t _id) {
|
enum audio::orchestra::error audio::orchestra::api::android::closeStream(int32_t _id) {
|
||||||
if (s_localContext == nullptr) {
|
if (s_localContext == null) {
|
||||||
return audio::orchestra::error_fail;
|
return audio::orchestra::error_fail;
|
||||||
}
|
}
|
||||||
return s_localContext->closeStream(_id);
|
return s_localContext->closeStream(_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum audio::orchestra::error audio::orchestra::api::android::startStream(int32_t _id) {
|
enum audio::orchestra::error audio::orchestra::api::android::startStream(int32_t _id) {
|
||||||
if (s_localContext == nullptr) {
|
if (s_localContext == null) {
|
||||||
return audio::orchestra::error_fail;
|
return audio::orchestra::error_fail;
|
||||||
}
|
}
|
||||||
return s_localContext->startStream(_id);
|
return s_localContext->startStream(_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum audio::orchestra::error audio::orchestra::api::android::stopStream(int32_t _id) {
|
enum audio::orchestra::error audio::orchestra::api::android::stopStream(int32_t _id) {
|
||||||
if (s_localContext == nullptr) {
|
if (s_localContext == null) {
|
||||||
return audio::orchestra::error_fail;
|
return audio::orchestra::error_fail;
|
||||||
}
|
}
|
||||||
return s_localContext->stopStream(_id);
|
return s_localContext->stopStream(_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum audio::orchestra::error audio::orchestra::api::android::abortStream(int32_t _id) {
|
enum audio::orchestra::error audio::orchestra::api::android::abortStream(int32_t _id) {
|
||||||
if (s_localContext == nullptr) {
|
if (s_localContext == null) {
|
||||||
return audio::orchestra::error_fail;
|
return audio::orchestra::error_fail;
|
||||||
}
|
}
|
||||||
return s_localContext->abortStream(_id);
|
return s_localContext->abortStream(_id);
|
||||||
@ -467,11 +467,11 @@ extern "C" {
|
|||||||
ATA_INFO("*******************************************");
|
ATA_INFO("*******************************************");
|
||||||
ATA_INFO("** Creating Orchestra context **");
|
ATA_INFO("** Creating Orchestra context **");
|
||||||
ATA_INFO("*******************************************");
|
ATA_INFO("*******************************************");
|
||||||
if (s_localContext != nullptr) {
|
if (s_localContext != null) {
|
||||||
s_nbContextRequested++;
|
s_nbContextRequested++;
|
||||||
}
|
}
|
||||||
s_localContext = ememory::makeShared<AndroidOrchestraContext>(_env, _classBase, _objCallback);
|
s_localContext = ememory::makeShared<AndroidOrchestraContext>(_env, _classBase, _objCallback);
|
||||||
if (s_localContext == nullptr) {
|
if (s_localContext == null) {
|
||||||
ATA_ERROR("Can not allocate the orchestra main context instance");
|
ATA_ERROR("Can not allocate the orchestra main context instance");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -498,14 +498,14 @@ extern "C" {
|
|||||||
jshortArray _location,
|
jshortArray _location,
|
||||||
jint _nbChunk) {
|
jint _nbChunk) {
|
||||||
ethread::UniqueLock lock(jvm_basics::getMutexJavaVM());
|
ethread::UniqueLock lock(jvm_basics::getMutexJavaVM());
|
||||||
if (s_localContext == nullptr) {
|
if (s_localContext == null) {
|
||||||
ATA_ERROR("Call audio with no more Low level interface");
|
ATA_ERROR("Call audio with no more Low level interface");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// get the short* pointer from the Java array
|
// get the short* pointer from the Java array
|
||||||
jboolean isCopy;
|
jboolean isCopy;
|
||||||
jshort* dst = _env->GetShortArrayElements(_location, &isCopy);
|
jshort* dst = _env->GetShortArrayElements(_location, &isCopy);
|
||||||
if (dst != nullptr) {
|
if (dst != null) {
|
||||||
//ATA_INFO("Need audioData " << int32_t(_nbChunk));
|
//ATA_INFO("Need audioData " << int32_t(_nbChunk));
|
||||||
s_localContext->playback(int32_t(_id), static_cast<short*>(dst), int32_t(_nbChunk));
|
s_localContext->playback(int32_t(_id), static_cast<short*>(dst), int32_t(_nbChunk));
|
||||||
}
|
}
|
||||||
@ -521,14 +521,14 @@ extern "C" {
|
|||||||
jshortArray _location,
|
jshortArray _location,
|
||||||
jint _nbChunk) {
|
jint _nbChunk) {
|
||||||
ethread::UniqueLock lock(jvm_basics::getMutexJavaVM());
|
ethread::UniqueLock lock(jvm_basics::getMutexJavaVM());
|
||||||
if (s_localContext == nullptr) {
|
if (s_localContext == null) {
|
||||||
ATA_ERROR("Call audio with no more Low level interface");
|
ATA_ERROR("Call audio with no more Low level interface");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// get the short* pointer from the Java array
|
// get the short* pointer from the Java array
|
||||||
jboolean isCopy;
|
jboolean isCopy;
|
||||||
jshort* dst = _env->GetShortArrayElements(_location, &isCopy);
|
jshort* dst = _env->GetShortArrayElements(_location, &isCopy);
|
||||||
if (dst != nullptr) {
|
if (dst != null) {
|
||||||
//ATA_INFO("Need audioData " << int32_t(_nbChunk));
|
//ATA_INFO("Need audioData " << int32_t(_nbChunk));
|
||||||
s_localContext->record(int32_t(_id), static_cast<short*>(dst), int32_t(_nbChunk));
|
s_localContext->record(int32_t(_id), static_cast<short*>(dst), int32_t(_nbChunk));
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ audio::orchestra::api::Asio::Asio() :
|
|||||||
// CoInitialize beforehand, but it must be for appartment threading
|
// CoInitialize beforehand, but it must be for appartment threading
|
||||||
// (in which case, CoInitilialize will return S_FALSE here).
|
// (in which case, CoInitilialize will return S_FALSE here).
|
||||||
m_coInitialized = false;
|
m_coInitialized = false;
|
||||||
HRESULT hr = CoInitialize(nullptr);
|
HRESULT hr = CoInitialize(null);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
ATA_ERROR("requires a single-threaded appartment. Call CoInitializeEx(0,COINIT_APARTMENTTHREADED)");
|
ATA_ERROR("requires a single-threaded appartment. Call CoInitializeEx(0,COINIT_APARTMENTTHREADED)");
|
||||||
}
|
}
|
||||||
@ -411,10 +411,10 @@ bool audio::orchestra::api::Asio::open(uint32_t _device,
|
|||||||
m_deviceInterleaved[modeToIdTable(_mode)] = false;
|
m_deviceInterleaved[modeToIdTable(_mode)] = false;
|
||||||
m_private->bufferInfos = 0;
|
m_private->bufferInfos = 0;
|
||||||
// Create a manual-reset event.
|
// Create a manual-reset event.
|
||||||
m_private->condition = CreateEvent(nullptr, // no security
|
m_private->condition = CreateEvent(null, // no security
|
||||||
TRUE, // manual-reset
|
TRUE, // manual-reset
|
||||||
FALSE, // non-signaled initially
|
FALSE, // non-signaled initially
|
||||||
nullptr); // unnamed
|
null); // unnamed
|
||||||
// Create the ASIO internal buffers. Since RtAudio sets up input
|
// Create the ASIO internal buffers. Since RtAudio sets up input
|
||||||
// and output separately, we'll have to dispose of previously
|
// and output separately, we'll have to dispose of previously
|
||||||
// created output buffers for a duplex stream.
|
// created output buffers for a duplex stream.
|
||||||
@ -422,16 +422,16 @@ bool audio::orchestra::api::Asio::open(uint32_t _device,
|
|||||||
if ( _mode == audio::orchestra::mode_input
|
if ( _mode == audio::orchestra::mode_input
|
||||||
&& m_mode == audio::orchestra::mode_output) {
|
&& m_mode == audio::orchestra::mode_output) {
|
||||||
ASIODisposeBuffers();
|
ASIODisposeBuffers();
|
||||||
if (m_private->bufferInfos == nullptr) {
|
if (m_private->bufferInfos == null) {
|
||||||
free(m_private->bufferInfos);
|
free(m_private->bufferInfos);
|
||||||
m_private->bufferInfos = nullptr;
|
m_private->bufferInfos = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Allocate, initialize, and save the bufferInfos in our stream callbackInfo structure.
|
// Allocate, initialize, and save the bufferInfos in our stream callbackInfo structure.
|
||||||
bool buffersAllocated = false;
|
bool buffersAllocated = false;
|
||||||
uint32_t i, nChannels = m_nDeviceChannels[0] + m_nDeviceChannels[1];
|
uint32_t i, nChannels = m_nDeviceChannels[0] + m_nDeviceChannels[1];
|
||||||
m_private->bufferInfos = (ASIOBufferInfo *) malloc(nChannels * sizeof(ASIOBufferInfo));
|
m_private->bufferInfos = (ASIOBufferInfo *) malloc(nChannels * sizeof(ASIOBufferInfo));
|
||||||
if (m_private->bufferInfos == nullptr) {
|
if (m_private->bufferInfos == null) {
|
||||||
ATA_ERROR("error allocating bufferInfo memory for driver (" << driverName << ").");
|
ATA_ERROR("error allocating bufferInfo memory for driver (" << driverName << ").");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -451,7 +451,7 @@ bool audio::orchestra::api::Asio::open(uint32_t _device,
|
|||||||
asioCallbacks.bufferSwitch = &bufferSwitch;
|
asioCallbacks.bufferSwitch = &bufferSwitch;
|
||||||
asioCallbacks.sampleRateDidChange = &sampleRateChanged;
|
asioCallbacks.sampleRateDidChange = &sampleRateChanged;
|
||||||
asioCallbacks.asioMessage = &asioMessages;
|
asioCallbacks.asioMessage = &asioMessages;
|
||||||
asioCallbacks.bufferSwitchTimeInfo = nullptr;
|
asioCallbacks.bufferSwitchTimeInfo = null;
|
||||||
result = ASIOCreateBuffers(m_private->bufferInfos, nChannels, m_bufferSize, &asioCallbacks);
|
result = ASIOCreateBuffers(m_private->bufferInfos, nChannels, m_bufferSize, &asioCallbacks);
|
||||||
if (result != ASE_OK) {
|
if (result != ASE_OK) {
|
||||||
ATA_ERROR("driver (" << driverName << ") error (" << getAsioErrorString(result) << ") creating buffers.");
|
ATA_ERROR("driver (" << driverName << ") error (" << getAsioErrorString(result) << ") creating buffers.");
|
||||||
@ -471,7 +471,7 @@ bool audio::orchestra::api::Asio::open(uint32_t _device,
|
|||||||
uint64_t bufferBytes;
|
uint64_t bufferBytes;
|
||||||
bufferBytes = m_nUserChannels[modeToIdTable(_mode)] * *_bufferSize * audio::getFormatBytes(m_userFormat);
|
bufferBytes = m_nUserChannels[modeToIdTable(_mode)] * *_bufferSize * audio::getFormatBytes(m_userFormat);
|
||||||
m_userBuffer[modeToIdTable(_mode)] = (char *) calloc(bufferBytes, 1);
|
m_userBuffer[modeToIdTable(_mode)] = (char *) calloc(bufferBytes, 1);
|
||||||
if (m_userBuffer[modeToIdTable(_mode)] == nullptr) {
|
if (m_userBuffer[modeToIdTable(_mode)] == null) {
|
||||||
ATA_ERROR("error allocating user buffer memory.");
|
ATA_ERROR("error allocating user buffer memory.");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -490,10 +490,10 @@ bool audio::orchestra::api::Asio::open(uint32_t _device,
|
|||||||
bufferBytes *= *_bufferSize;
|
bufferBytes *= *_bufferSize;
|
||||||
if (m_deviceBuffer) {
|
if (m_deviceBuffer) {
|
||||||
free(m_deviceBuffer);
|
free(m_deviceBuffer);
|
||||||
m_deviceBuffer = nullptr;
|
m_deviceBuffer = null;
|
||||||
}
|
}
|
||||||
m_deviceBuffer = (char *) calloc(bufferBytes, 1);
|
m_deviceBuffer = (char *) calloc(bufferBytes, 1);
|
||||||
if (m_deviceBuffer == nullptr) {
|
if (m_deviceBuffer == null) {
|
||||||
ATA_ERROR("error allocating device buffer memory.");
|
ATA_ERROR("error allocating device buffer memory.");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -530,9 +530,9 @@ error:
|
|||||||
}
|
}
|
||||||
drivers.removeCurrentDriver();
|
drivers.removeCurrentDriver();
|
||||||
CloseHandle(m_private->condition);
|
CloseHandle(m_private->condition);
|
||||||
if (m_private->bufferInfos != nullptr) {
|
if (m_private->bufferInfos != null) {
|
||||||
free(m_private->bufferInfos);
|
free(m_private->bufferInfos);
|
||||||
m_private->bufferInfos = nullptr;
|
m_private->bufferInfos = null;
|
||||||
}
|
}
|
||||||
for (int32_t i=0; i<2; i++) {
|
for (int32_t i=0; i<2; i++) {
|
||||||
if (m_userBuffer[i]) {
|
if (m_userBuffer[i]) {
|
||||||
@ -680,7 +680,7 @@ bool audio::orchestra::api::Asio::callbackEvent(long bufferIndex) {
|
|||||||
SetEvent(m_private->condition);
|
SetEvent(m_private->condition);
|
||||||
} else { // spawn a thread to stop the stream
|
} else { // spawn a thread to stop the stream
|
||||||
unsigned threadId;
|
unsigned threadId;
|
||||||
m_callbackInfo.thread = _beginthreadex(nullptr,
|
m_callbackInfo.thread = _beginthreadex(null,
|
||||||
0,
|
0,
|
||||||
&asioStopStream,
|
&asioStopStream,
|
||||||
&m_callbackInfo,
|
&m_callbackInfo,
|
||||||
@ -712,7 +712,7 @@ bool audio::orchestra::api::Asio::callbackEvent(long bufferIndex) {
|
|||||||
m_state = audio::orchestra::state::stopping;
|
m_state = audio::orchestra::state::stopping;
|
||||||
m_private->drainCounter = 2;
|
m_private->drainCounter = 2;
|
||||||
unsigned threadId;
|
unsigned threadId;
|
||||||
m_callbackInfo.thread = _beginthreadex(nullptr,
|
m_callbackInfo.thread = _beginthreadex(null,
|
||||||
0,
|
0,
|
||||||
&asioStopStream,
|
&asioStopStream,
|
||||||
&m_callbackInfo,
|
&m_callbackInfo,
|
||||||
|
@ -63,7 +63,7 @@ audio::orchestra::api::Core::Core() :
|
|||||||
// requirement starting with OS-X 10.6. If not called, queries and
|
// requirement starting with OS-X 10.6. If not called, queries and
|
||||||
// updates to various audio device properties are not handled
|
// updates to various audio device properties are not handled
|
||||||
// correctly.
|
// correctly.
|
||||||
CFRunLoopRef theRunLoop = nullptr;
|
CFRunLoopRef theRunLoop = null;
|
||||||
AudioObjectPropertyAddress property = {
|
AudioObjectPropertyAddress property = {
|
||||||
kAudioHardwarePropertyRunLoop,
|
kAudioHardwarePropertyRunLoop,
|
||||||
kAudioObjectPropertyScopeGlobal,
|
kAudioObjectPropertyScopeGlobal,
|
||||||
@ -72,7 +72,7 @@ audio::orchestra::api::Core::Core() :
|
|||||||
OSStatus result = AudioObjectSetPropertyData(kAudioObjectSystemObject,
|
OSStatus result = AudioObjectSetPropertyData(kAudioObjectSystemObject,
|
||||||
&property,
|
&property,
|
||||||
0,
|
0,
|
||||||
nullptr,
|
null,
|
||||||
sizeof(CFRunLoopRef),
|
sizeof(CFRunLoopRef),
|
||||||
&theRunLoop);
|
&theRunLoop);
|
||||||
if (result != noErr) {
|
if (result != noErr) {
|
||||||
@ -98,7 +98,7 @@ uint32_t audio::orchestra::api::Core::getDeviceCount() {
|
|||||||
kAudioObjectPropertyScopeGlobal,
|
kAudioObjectPropertyScopeGlobal,
|
||||||
kAudioObjectPropertyElementMaster
|
kAudioObjectPropertyElementMaster
|
||||||
};
|
};
|
||||||
OSStatus result = AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &propertyAddress, 0, nullptr, &dataSize);
|
OSStatus result = AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &propertyAddress, 0, null, &dataSize);
|
||||||
if (result != noErr) {
|
if (result != noErr) {
|
||||||
ATA_ERROR("OS-X error getting device info!");
|
ATA_ERROR("OS-X error getting device info!");
|
||||||
return 0;
|
return 0;
|
||||||
@ -121,7 +121,7 @@ uint32_t audio::orchestra::api::Core::getDefaultInputDevice() {
|
|||||||
OSStatus result = AudioObjectGetPropertyData(kAudioObjectSystemObject,
|
OSStatus result = AudioObjectGetPropertyData(kAudioObjectSystemObject,
|
||||||
&property,
|
&property,
|
||||||
0,
|
0,
|
||||||
nullptr,
|
null,
|
||||||
&dataSize,
|
&dataSize,
|
||||||
&id);
|
&id);
|
||||||
if (result != noErr) {
|
if (result != noErr) {
|
||||||
@ -134,7 +134,7 @@ uint32_t audio::orchestra::api::Core::getDefaultInputDevice() {
|
|||||||
result = AudioObjectGetPropertyData(kAudioObjectSystemObject,
|
result = AudioObjectGetPropertyData(kAudioObjectSystemObject,
|
||||||
&property,
|
&property,
|
||||||
0,
|
0,
|
||||||
nullptr,
|
null,
|
||||||
&dataSize,
|
&dataSize,
|
||||||
(void*)&deviceList);
|
(void*)&deviceList);
|
||||||
if (result != noErr) {
|
if (result != noErr) {
|
||||||
@ -165,7 +165,7 @@ uint32_t audio::orchestra::api::Core::getDefaultOutputDevice() {
|
|||||||
OSStatus result = AudioObjectGetPropertyData(kAudioObjectSystemObject,
|
OSStatus result = AudioObjectGetPropertyData(kAudioObjectSystemObject,
|
||||||
&property,
|
&property,
|
||||||
0,
|
0,
|
||||||
nullptr,
|
null,
|
||||||
&dataSize,
|
&dataSize,
|
||||||
&id);
|
&id);
|
||||||
if (result != noErr) {
|
if (result != noErr) {
|
||||||
@ -178,7 +178,7 @@ uint32_t audio::orchestra::api::Core::getDefaultOutputDevice() {
|
|||||||
result = AudioObjectGetPropertyData(kAudioObjectSystemObject,
|
result = AudioObjectGetPropertyData(kAudioObjectSystemObject,
|
||||||
&property,
|
&property,
|
||||||
0,
|
0,
|
||||||
nullptr,
|
null,
|
||||||
&dataSize,
|
&dataSize,
|
||||||
(void*)&deviceList);
|
(void*)&deviceList);
|
||||||
if (result != noErr) {
|
if (result != noErr) {
|
||||||
@ -223,7 +223,7 @@ audio::orchestra::DeviceInfo audio::orchestra::api::Core::getDeviceInfo(uint32_t
|
|||||||
OSStatus result = AudioObjectGetPropertyData(kAudioObjectSystemObject,
|
OSStatus result = AudioObjectGetPropertyData(kAudioObjectSystemObject,
|
||||||
&property,
|
&property,
|
||||||
0,
|
0,
|
||||||
nullptr,
|
null,
|
||||||
&dataSize,
|
&dataSize,
|
||||||
(void*)&deviceList);
|
(void*)&deviceList);
|
||||||
if (result != noErr) {
|
if (result != noErr) {
|
||||||
@ -239,7 +239,7 @@ audio::orchestra::DeviceInfo audio::orchestra::api::Core::getDeviceInfo(uint32_t
|
|||||||
CFStringRef cfname;
|
CFStringRef cfname;
|
||||||
dataSize = sizeof(CFStringRef);
|
dataSize = sizeof(CFStringRef);
|
||||||
property.mSelector = kAudioObjectPropertyManufacturer;
|
property.mSelector = kAudioObjectPropertyManufacturer;
|
||||||
result = AudioObjectGetPropertyData(id, &property, 0, nullptr, &dataSize, &cfname);
|
result = AudioObjectGetPropertyData(id, &property, 0, null, &dataSize, &cfname);
|
||||||
if (result != noErr) {
|
if (result != noErr) {
|
||||||
ATA_ERROR("system error (" << getErrorCode(result) << ") getting device manufacturer.");
|
ATA_ERROR("system error (" << getErrorCode(result) << ") getting device manufacturer.");
|
||||||
info.clear();
|
info.clear();
|
||||||
@ -254,7 +254,7 @@ audio::orchestra::DeviceInfo audio::orchestra::api::Core::getDeviceInfo(uint32_t
|
|||||||
info.name.append(": ");
|
info.name.append(": ");
|
||||||
CFRelease(cfname);
|
CFRelease(cfname);
|
||||||
property.mSelector = kAudioObjectPropertyName;
|
property.mSelector = kAudioObjectPropertyName;
|
||||||
result = AudioObjectGetPropertyData(id, &property, 0, nullptr, &dataSize, &cfname);
|
result = AudioObjectGetPropertyData(id, &property, 0, null, &dataSize, &cfname);
|
||||||
if (result != noErr) {
|
if (result != noErr) {
|
||||||
ATA_ERROR("system error (" << getErrorCode(result) << ") getting device name.");
|
ATA_ERROR("system error (" << getErrorCode(result) << ") getting device name.");
|
||||||
info.clear();
|
info.clear();
|
||||||
@ -276,9 +276,9 @@ audio::orchestra::DeviceInfo audio::orchestra::api::Core::getDeviceInfo(uint32_t
|
|||||||
} else {
|
} else {
|
||||||
property.mScope = kAudioDevicePropertyScopeInput;
|
property.mScope = kAudioDevicePropertyScopeInput;
|
||||||
}
|
}
|
||||||
AudioBufferList *bufferList = nullptr;
|
AudioBufferList *bufferList = null;
|
||||||
dataSize = 0;
|
dataSize = 0;
|
||||||
result = AudioObjectGetPropertyDataSize(id, &property, 0, nullptr, &dataSize);
|
result = AudioObjectGetPropertyDataSize(id, &property, 0, null, &dataSize);
|
||||||
if (result != noErr || dataSize == 0) {
|
if (result != noErr || dataSize == 0) {
|
||||||
ATA_ERROR("system error (" << getErrorCode(result) << ") getting stream configuration info for device (" << _device << ").");
|
ATA_ERROR("system error (" << getErrorCode(result) << ") getting stream configuration info for device (" << _device << ").");
|
||||||
info.clear();
|
info.clear();
|
||||||
@ -286,12 +286,12 @@ audio::orchestra::DeviceInfo audio::orchestra::api::Core::getDeviceInfo(uint32_t
|
|||||||
}
|
}
|
||||||
// Allocate the AudioBufferList.
|
// Allocate the AudioBufferList.
|
||||||
bufferList = (AudioBufferList *) malloc(dataSize);
|
bufferList = (AudioBufferList *) malloc(dataSize);
|
||||||
if (bufferList == nullptr) {
|
if (bufferList == null) {
|
||||||
ATA_ERROR("memory error allocating AudioBufferList.");
|
ATA_ERROR("memory error allocating AudioBufferList.");
|
||||||
info.clear();
|
info.clear();
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
result = AudioObjectGetPropertyData(id, &property, 0, nullptr, &dataSize, bufferList);
|
result = AudioObjectGetPropertyData(id, &property, 0, null, &dataSize, bufferList);
|
||||||
if ( result != noErr
|
if ( result != noErr
|
||||||
|| dataSize == 0) {
|
|| dataSize == 0) {
|
||||||
free(bufferList);
|
free(bufferList);
|
||||||
@ -316,7 +316,7 @@ audio::orchestra::DeviceInfo audio::orchestra::api::Core::getDeviceInfo(uint32_t
|
|||||||
// Determine the supported sample rates.
|
// Determine the supported sample rates.
|
||||||
// ------------------------------------------------
|
// ------------------------------------------------
|
||||||
property.mSelector = kAudioDevicePropertyAvailableNominalSampleRates;
|
property.mSelector = kAudioDevicePropertyAvailableNominalSampleRates;
|
||||||
result = AudioObjectGetPropertyDataSize(id, &property, 0, nullptr, &dataSize);
|
result = AudioObjectGetPropertyDataSize(id, &property, 0, null, &dataSize);
|
||||||
if ( result != kAudioHardwareNoError
|
if ( result != kAudioHardwareNoError
|
||||||
|| dataSize == 0) {
|
|| dataSize == 0) {
|
||||||
ATA_ERROR("system error (" << getErrorCode(result) << ") getting sample rate info.");
|
ATA_ERROR("system error (" << getErrorCode(result) << ") getting sample rate info.");
|
||||||
@ -325,7 +325,7 @@ audio::orchestra::DeviceInfo audio::orchestra::api::Core::getDeviceInfo(uint32_t
|
|||||||
}
|
}
|
||||||
uint32_t nRanges = dataSize / sizeof(AudioValueRange);
|
uint32_t nRanges = dataSize / sizeof(AudioValueRange);
|
||||||
AudioValueRange rangeList[ nRanges ];
|
AudioValueRange rangeList[ nRanges ];
|
||||||
result = AudioObjectGetPropertyData(id, &property, 0, nullptr, &dataSize, &rangeList);
|
result = AudioObjectGetPropertyData(id, &property, 0, null, &dataSize, &rangeList);
|
||||||
if (result != kAudioHardwareNoError) {
|
if (result != kAudioHardwareNoError) {
|
||||||
ATA_ERROR("system error (" << getErrorCode(result) << ") getting sample rates.");
|
ATA_ERROR("system error (" << getErrorCode(result) << ") getting sample rates.");
|
||||||
info.clear();
|
info.clear();
|
||||||
@ -386,10 +386,10 @@ OSStatus audio::orchestra::api::Core::callbackEvent(AudioDeviceID _inDevice,
|
|||||||
audio::orchestra::api::Core* myClass = reinterpret_cast<audio::orchestra::api::Core*>(_userData);
|
audio::orchestra::api::Core* myClass = reinterpret_cast<audio::orchestra::api::Core*>(_userData);
|
||||||
audio::Time inputTime;
|
audio::Time inputTime;
|
||||||
audio::Time outputTime;
|
audio::Time outputTime;
|
||||||
if (_inInputTime != nullptr) {
|
if (_inInputTime != null) {
|
||||||
inputTime = audio::Time(_inInputTime->mHostTime/1000000000LL, _inInputTime->mHostTime%1000000000LL);
|
inputTime = audio::Time(_inInputTime->mHostTime/1000000000LL, _inInputTime->mHostTime%1000000000LL);
|
||||||
}
|
}
|
||||||
if (_inOutputTime != nullptr) {
|
if (_inOutputTime != null) {
|
||||||
outputTime = audio::Time(_inOutputTime->mHostTime/1000000000LL, _inOutputTime->mHostTime%1000000000LL);
|
outputTime = audio::Time(_inOutputTime->mHostTime/1000000000LL, _inOutputTime->mHostTime%1000000000LL);
|
||||||
}
|
}
|
||||||
if (myClass->callbackEvent(_inDevice, _inInputData, inputTime, _outOutputData, outputTime) == false) {
|
if (myClass->callbackEvent(_inDevice, _inInputData, inputTime, _outOutputData, outputTime) == false) {
|
||||||
@ -427,7 +427,7 @@ static OSStatus rateListener(AudioObjectID _inDevice,
|
|||||||
kAudioObjectPropertyScopeGlobal,
|
kAudioObjectPropertyScopeGlobal,
|
||||||
kAudioObjectPropertyElementMaster
|
kAudioObjectPropertyElementMaster
|
||||||
};
|
};
|
||||||
AudioObjectGetPropertyData(_inDevice, &property, 0, nullptr, &dataSize, rate);
|
AudioObjectGetPropertyData(_inDevice, &property, 0, null, &dataSize, rate);
|
||||||
return kAudioHardwareNoError;
|
return kAudioHardwareNoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -461,7 +461,7 @@ bool audio::orchestra::api::Core::open(uint32_t _device,
|
|||||||
OSStatus result = AudioObjectGetPropertyData(kAudioObjectSystemObject,
|
OSStatus result = AudioObjectGetPropertyData(kAudioObjectSystemObject,
|
||||||
&property,
|
&property,
|
||||||
0,
|
0,
|
||||||
nullptr,
|
null,
|
||||||
&dataSize,
|
&dataSize,
|
||||||
(void *) &deviceList);
|
(void *) &deviceList);
|
||||||
if (result != noErr) {
|
if (result != noErr) {
|
||||||
@ -481,7 +481,7 @@ bool audio::orchestra::api::Core::open(uint32_t _device,
|
|||||||
AudioBufferList *bufferList = nil;
|
AudioBufferList *bufferList = nil;
|
||||||
dataSize = 0;
|
dataSize = 0;
|
||||||
property.mSelector = kAudioDevicePropertyStreamConfiguration;
|
property.mSelector = kAudioDevicePropertyStreamConfiguration;
|
||||||
result = AudioObjectGetPropertyDataSize(id, &property, 0, nullptr, &dataSize);
|
result = AudioObjectGetPropertyDataSize(id, &property, 0, null, &dataSize);
|
||||||
if ( result != noErr
|
if ( result != noErr
|
||||||
|| dataSize == 0) {
|
|| dataSize == 0) {
|
||||||
ATA_ERROR("system error (" << getErrorCode(result) << ") getting stream configuration info for device (" << _device << ").");
|
ATA_ERROR("system error (" << getErrorCode(result) << ") getting stream configuration info for device (" << _device << ").");
|
||||||
@ -489,11 +489,11 @@ bool audio::orchestra::api::Core::open(uint32_t _device,
|
|||||||
}
|
}
|
||||||
// Allocate the AudioBufferList.
|
// Allocate the AudioBufferList.
|
||||||
bufferList = (AudioBufferList *) malloc(dataSize);
|
bufferList = (AudioBufferList *) malloc(dataSize);
|
||||||
if (bufferList == nullptr) {
|
if (bufferList == null) {
|
||||||
ATA_ERROR("memory error allocating AudioBufferList.");
|
ATA_ERROR("memory error allocating AudioBufferList.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
result = AudioObjectGetPropertyData(id, &property, 0, nullptr, &dataSize, bufferList);
|
result = AudioObjectGetPropertyData(id, &property, 0, null, &dataSize, bufferList);
|
||||||
if ( result != noErr
|
if ( result != noErr
|
||||||
|| dataSize == 0) {
|
|| dataSize == 0) {
|
||||||
ATA_ERROR("system error (" << getErrorCode(result) << ") getting stream configuration for device (" << _device << ").");
|
ATA_ERROR("system error (" << getErrorCode(result) << ") getting stream configuration for device (" << _device << ").");
|
||||||
@ -569,7 +569,7 @@ bool audio::orchestra::api::Core::open(uint32_t _device,
|
|||||||
AudioValueRange bufferRange;
|
AudioValueRange bufferRange;
|
||||||
dataSize = sizeof(AudioValueRange);
|
dataSize = sizeof(AudioValueRange);
|
||||||
property.mSelector = kAudioDevicePropertyBufferFrameSizeRange;
|
property.mSelector = kAudioDevicePropertyBufferFrameSizeRange;
|
||||||
result = AudioObjectGetPropertyData(id, &property, 0, nullptr, &dataSize, &bufferRange);
|
result = AudioObjectGetPropertyData(id, &property, 0, null, &dataSize, &bufferRange);
|
||||||
if (result != noErr) {
|
if (result != noErr) {
|
||||||
ATA_ERROR("system error (" << getErrorCode(result) << ") getting buffer size range for device (" << _device << ").");
|
ATA_ERROR("system error (" << getErrorCode(result) << ") getting buffer size range for device (" << _device << ").");
|
||||||
return false;
|
return false;
|
||||||
@ -587,7 +587,7 @@ bool audio::orchestra::api::Core::open(uint32_t _device,
|
|||||||
uint32_t theSize = (uint32_t) *_bufferSize;
|
uint32_t theSize = (uint32_t) *_bufferSize;
|
||||||
dataSize = sizeof(uint32_t);
|
dataSize = sizeof(uint32_t);
|
||||||
property.mSelector = kAudioDevicePropertyBufferFrameSize;
|
property.mSelector = kAudioDevicePropertyBufferFrameSize;
|
||||||
result = AudioObjectSetPropertyData(id, &property, 0, nullptr, dataSize, &theSize);
|
result = AudioObjectSetPropertyData(id, &property, 0, null, dataSize, &theSize);
|
||||||
if (result != noErr) {
|
if (result != noErr) {
|
||||||
ATA_ERROR("system error (" << getErrorCode(result) << ") setting the buffer size for device (" << _device << ").");
|
ATA_ERROR("system error (" << getErrorCode(result) << ") setting the buffer size for device (" << _device << ").");
|
||||||
return false;
|
return false;
|
||||||
@ -607,7 +607,7 @@ bool audio::orchestra::api::Core::open(uint32_t _device,
|
|||||||
double nominalRate;
|
double nominalRate;
|
||||||
dataSize = sizeof(double);
|
dataSize = sizeof(double);
|
||||||
property.mSelector = kAudioDevicePropertyNominalSampleRate;
|
property.mSelector = kAudioDevicePropertyNominalSampleRate;
|
||||||
result = AudioObjectGetPropertyData(id, &property, 0, nullptr, &dataSize, &nominalRate);
|
result = AudioObjectGetPropertyData(id, &property, 0, null, &dataSize, &nominalRate);
|
||||||
if (result != noErr) {
|
if (result != noErr) {
|
||||||
ATA_ERROR("system error (" << getErrorCode(result) << ") getting current sample rate.");
|
ATA_ERROR("system error (" << getErrorCode(result) << ") getting current sample rate.");
|
||||||
return false;
|
return false;
|
||||||
@ -623,7 +623,7 @@ bool audio::orchestra::api::Core::open(uint32_t _device,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
nominalRate = (double) _sampleRate;
|
nominalRate = (double) _sampleRate;
|
||||||
result = AudioObjectSetPropertyData(id, &property, 0, nullptr, dataSize, &nominalRate);
|
result = AudioObjectSetPropertyData(id, &property, 0, null, dataSize, &nominalRate);
|
||||||
if (result != noErr) {
|
if (result != noErr) {
|
||||||
ATA_ERROR("system error (" << getErrorCode(result) << ") setting sample rate for device (" << _device << ").");
|
ATA_ERROR("system error (" << getErrorCode(result) << ") setting sample rate for device (" << _device << ").");
|
||||||
return false;
|
return false;
|
||||||
@ -649,7 +649,7 @@ bool audio::orchestra::api::Core::open(uint32_t _device,
|
|||||||
AudioStreamBasicDescription description;
|
AudioStreamBasicDescription description;
|
||||||
dataSize = sizeof(AudioStreamBasicDescription);
|
dataSize = sizeof(AudioStreamBasicDescription);
|
||||||
property.mSelector = kAudioStreamPropertyVirtualFormat;
|
property.mSelector = kAudioStreamPropertyVirtualFormat;
|
||||||
result = AudioObjectGetPropertyData(id, &property, 0, nullptr, &dataSize, &description);
|
result = AudioObjectGetPropertyData(id, &property, 0, null, &dataSize, &description);
|
||||||
if (result != noErr) {
|
if (result != noErr) {
|
||||||
ATA_ERROR("system error (" << getErrorCode(result) << ") getting stream format for device (" << _device << ").");
|
ATA_ERROR("system error (" << getErrorCode(result) << ") getting stream format for device (" << _device << ").");
|
||||||
return false;
|
return false;
|
||||||
@ -667,7 +667,7 @@ bool audio::orchestra::api::Core::open(uint32_t _device,
|
|||||||
updateFormat = true;
|
updateFormat = true;
|
||||||
}
|
}
|
||||||
if (updateFormat) {
|
if (updateFormat) {
|
||||||
result = AudioObjectSetPropertyData(id, &property, 0, nullptr, dataSize, &description);
|
result = AudioObjectSetPropertyData(id, &property, 0, null, dataSize, &description);
|
||||||
if (result != noErr) {
|
if (result != noErr) {
|
||||||
ATA_ERROR("system error (" << getErrorCode(result) << ") setting sample rate or data format for device (" << _device << ").");
|
ATA_ERROR("system error (" << getErrorCode(result) << ") setting sample rate or data format for device (" << _device << ").");
|
||||||
return false;
|
return false;
|
||||||
@ -675,7 +675,7 @@ bool audio::orchestra::api::Core::open(uint32_t _device,
|
|||||||
}
|
}
|
||||||
// Now check the physical format.
|
// Now check the physical format.
|
||||||
property.mSelector = kAudioStreamPropertyPhysicalFormat;
|
property.mSelector = kAudioStreamPropertyPhysicalFormat;
|
||||||
result = AudioObjectGetPropertyData(id, &property, 0, nullptr, &dataSize, &description);
|
result = AudioObjectGetPropertyData(id, &property, 0, null, &dataSize, &description);
|
||||||
if (result != noErr) {
|
if (result != noErr) {
|
||||||
ATA_ERROR("system error (" << getErrorCode(result) << ") getting stream physical format for device (" << _device << ").");
|
ATA_ERROR("system error (" << getErrorCode(result) << ") getting stream physical format for device (" << _device << ").");
|
||||||
return false;
|
return false;
|
||||||
@ -717,7 +717,7 @@ bool audio::orchestra::api::Core::open(uint32_t _device,
|
|||||||
testDescription.mBytesPerFrame = testDescription.mBitsPerChannel/8 * testDescription.mChannelsPerFrame;
|
testDescription.mBytesPerFrame = testDescription.mBitsPerChannel/8 * testDescription.mChannelsPerFrame;
|
||||||
}
|
}
|
||||||
testDescription.mBytesPerPacket = testDescription.mBytesPerFrame * testDescription.mFramesPerPacket;
|
testDescription.mBytesPerPacket = testDescription.mBytesPerFrame * testDescription.mFramesPerPacket;
|
||||||
result = AudioObjectSetPropertyData(id, &property, 0, nullptr, dataSize, &testDescription);
|
result = AudioObjectSetPropertyData(id, &property, 0, null, dataSize, &testDescription);
|
||||||
if (result == noErr) {
|
if (result == noErr) {
|
||||||
setPhysicalFormat = true;
|
setPhysicalFormat = true;
|
||||||
//ATA_DEBUG("Updated physical stream format:");
|
//ATA_DEBUG("Updated physical stream format:");
|
||||||
@ -738,7 +738,7 @@ bool audio::orchestra::api::Core::open(uint32_t _device,
|
|||||||
dataSize = sizeof(uint32_t);
|
dataSize = sizeof(uint32_t);
|
||||||
property.mSelector = kAudioDevicePropertyLatency;
|
property.mSelector = kAudioDevicePropertyLatency;
|
||||||
if (AudioObjectHasProperty(id, &property) == true) {
|
if (AudioObjectHasProperty(id, &property) == true) {
|
||||||
result = AudioObjectGetPropertyData(id, &property, 0, nullptr, &dataSize, &latency);
|
result = AudioObjectGetPropertyData(id, &property, 0, null, &dataSize, &latency);
|
||||||
if (result == kAudioHardwareNoError) {
|
if (result == kAudioHardwareNoError) {
|
||||||
m_latency[ _mode ] = latency;
|
m_latency[ _mode ] = latency;
|
||||||
} else {
|
} else {
|
||||||
@ -814,10 +814,10 @@ bool audio::orchestra::api::Core::open(uint32_t _device,
|
|||||||
bufferBytes *= *_bufferSize;
|
bufferBytes *= *_bufferSize;
|
||||||
if (m_deviceBuffer) {
|
if (m_deviceBuffer) {
|
||||||
free(m_deviceBuffer);
|
free(m_deviceBuffer);
|
||||||
m_deviceBuffer = nullptr;
|
m_deviceBuffer = null;
|
||||||
}
|
}
|
||||||
m_deviceBuffer = (char *) calloc(bufferBytes, 1);
|
m_deviceBuffer = (char *) calloc(bufferBytes, 1);
|
||||||
if (m_deviceBuffer == nullptr) {
|
if (m_deviceBuffer == null) {
|
||||||
ATA_ERROR("error allocating device buffer memory.");
|
ATA_ERROR("error allocating device buffer memory.");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -908,7 +908,7 @@ enum audio::orchestra::error audio::orchestra::api::Core::closeStream() {
|
|||||||
m_userBuffer[1].clear();
|
m_userBuffer[1].clear();
|
||||||
if (m_deviceBuffer) {
|
if (m_deviceBuffer) {
|
||||||
free(m_deviceBuffer);
|
free(m_deviceBuffer);
|
||||||
m_deviceBuffer = nullptr;
|
m_deviceBuffer = null;
|
||||||
}
|
}
|
||||||
m_mode = audio::orchestra::mode_unknow;
|
m_mode = audio::orchestra::mode_unknow;
|
||||||
m_state = audio::orchestra::state::closed;
|
m_state = audio::orchestra::state::closed;
|
||||||
|
@ -139,7 +139,7 @@ void audio::orchestra::api::CoreIos::callBackEvent(void* _data,
|
|||||||
|| m_mode == audio::orchestra::mode_duplex) {
|
|| m_mode == audio::orchestra::mode_duplex) {
|
||||||
if (m_doConvertBuffer[modeToIdTable(audio::orchestra::mode_output)] == true) {
|
if (m_doConvertBuffer[modeToIdTable(audio::orchestra::mode_output)] == true) {
|
||||||
ATA_INFO("get output DATA : " << uint64_t(&m_userBuffer[modeToIdTable(audio::orchestra::mode_output)][0]));
|
ATA_INFO("get output DATA : " << uint64_t(&m_userBuffer[modeToIdTable(audio::orchestra::mode_output)][0]));
|
||||||
doStopStream = m_callback(nullptr,
|
doStopStream = m_callback(null,
|
||||||
audio::Time(),
|
audio::Time(),
|
||||||
&m_userBuffer[modeToIdTable(audio::orchestra::mode_output)][0],
|
&m_userBuffer[modeToIdTable(audio::orchestra::mode_output)][0],
|
||||||
_time,
|
_time,
|
||||||
@ -148,7 +148,7 @@ void audio::orchestra::api::CoreIos::callBackEvent(void* _data,
|
|||||||
convertBuffer((char*)_data, &m_userBuffer[modeToIdTable(audio::orchestra::mode_output)][0], m_convertInfo[modeToIdTable(audio::orchestra::mode_output)]);
|
convertBuffer((char*)_data, &m_userBuffer[modeToIdTable(audio::orchestra::mode_output)][0], m_convertInfo[modeToIdTable(audio::orchestra::mode_output)]);
|
||||||
} else {
|
} else {
|
||||||
ATA_INFO("have output DATA : " << uint64_t(_data));
|
ATA_INFO("have output DATA : " << uint64_t(_data));
|
||||||
doStopStream = m_callback(nullptr,
|
doStopStream = m_callback(null,
|
||||||
_time,
|
_time,
|
||||||
_data,
|
_data,
|
||||||
audio::Time(),
|
audio::Time(),
|
||||||
@ -161,7 +161,7 @@ void audio::orchestra::api::CoreIos::callBackEvent(void* _data,
|
|||||||
ATA_INFO("have input DATA : " << uint64_t(_data));
|
ATA_INFO("have input DATA : " << uint64_t(_data));
|
||||||
doStopStream = m_callback(_data,
|
doStopStream = m_callback(_data,
|
||||||
_time,
|
_time,
|
||||||
nullptr,
|
null,
|
||||||
audio::Time(),
|
audio::Time(),
|
||||||
_nbChunk,
|
_nbChunk,
|
||||||
status);
|
status);
|
||||||
@ -180,12 +180,12 @@ static OSStatus playbackCallback(void *_userData,
|
|||||||
uint32_t _inBusNumber,
|
uint32_t _inBusNumber,
|
||||||
uint32_t _inNumberFrames,
|
uint32_t _inNumberFrames,
|
||||||
AudioBufferList* _ioData) {
|
AudioBufferList* _ioData) {
|
||||||
if (_userData == nullptr) {
|
if (_userData == null) {
|
||||||
ATA_ERROR("callback event ... nullptr pointer");
|
ATA_ERROR("callback event ... null pointer");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
audio::Time tmpTimeime;
|
audio::Time tmpTimeime;
|
||||||
if (_inTime != nullptr) {
|
if (_inTime != null) {
|
||||||
tmpTimeime = audio::Time(_inTime->mHostTime/1000000000LL, _inTime->mHostTime%1000000000LL);
|
tmpTimeime = audio::Time(_inTime->mHostTime/1000000000LL, _inTime->mHostTime%1000000000LL);
|
||||||
}
|
}
|
||||||
audio::orchestra::api::CoreIos* myClass = static_cast<audio::orchestra::api::CoreIos*>(_userData);
|
audio::orchestra::api::CoreIos* myClass = static_cast<audio::orchestra::api::CoreIos*>(_userData);
|
||||||
@ -267,7 +267,7 @@ bool audio::orchestra::api::CoreIos::open(uint32_t _device,
|
|||||||
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
|
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
|
||||||
|
|
||||||
// Get component
|
// Get component
|
||||||
AudioComponent inputComponent = AudioComponentFindNext(nullptr, &desc);
|
AudioComponent inputComponent = AudioComponentFindNext(null, &desc);
|
||||||
|
|
||||||
// Get audio units
|
// Get audio units
|
||||||
status = AudioComponentInstanceNew(inputComponent, &m_private->audioUnit);
|
status = AudioComponentInstanceNew(inputComponent, &m_private->audioUnit);
|
||||||
|
@ -114,7 +114,7 @@ audio::orchestra::api::Ds::Ds() :
|
|||||||
// Dsound will run both-threaded. If CoInitialize fails, then just
|
// Dsound will run both-threaded. If CoInitialize fails, then just
|
||||||
// accept whatever the mainline chose for a threading model.
|
// accept whatever the mainline chose for a threading model.
|
||||||
m_coInitialized = false;
|
m_coInitialized = false;
|
||||||
HRESULT hr = CoInitialize(nullptr);
|
HRESULT hr = CoInitialize(null);
|
||||||
if (!FAILED(hr)) {
|
if (!FAILED(hr)) {
|
||||||
m_coInitialized = true;
|
m_coInitialized = true;
|
||||||
}
|
}
|
||||||
@ -133,9 +133,9 @@ audio::orchestra::api::Ds::~Ds() {
|
|||||||
#include "tchar.h"
|
#include "tchar.h"
|
||||||
static etk::String convertTChar(LPCTSTR _name) {
|
static etk::String convertTChar(LPCTSTR _name) {
|
||||||
#if defined(UNICODE) || defined(_UNICODE)
|
#if defined(UNICODE) || defined(_UNICODE)
|
||||||
int32_t length = WideCharToMultiByte(CP_UTF8, 0, _name, -1, nullptr, 0, nullptr, nullptr);
|
int32_t length = WideCharToMultiByte(CP_UTF8, 0, _name, -1, null, 0, null, null);
|
||||||
etk::String s(length-1, '\0');
|
etk::String s(length-1, '\0');
|
||||||
WideCharToMultiByte(CP_UTF8, 0, _name, -1, &s[0], length, nullptr, nullptr);
|
WideCharToMultiByte(CP_UTF8, 0, _name, -1, &s[0], length, null, null);
|
||||||
#else
|
#else
|
||||||
etk::String s(_name);
|
etk::String s(_name);
|
||||||
#endif
|
#endif
|
||||||
@ -153,7 +153,7 @@ static BOOL CALLBACK deviceQueryCallback(LPGUID _lpguid,
|
|||||||
if (probeInfo.isInput == true) {
|
if (probeInfo.isInput == true) {
|
||||||
DSCCAPS caps;
|
DSCCAPS caps;
|
||||||
LPDIRECTSOUNDCAPTURE object;
|
LPDIRECTSOUNDCAPTURE object;
|
||||||
hr = DirectSoundCaptureCreate(_lpguid, &object, nullptr);
|
hr = DirectSoundCaptureCreate(_lpguid, &object, null);
|
||||||
if (hr != DS_OK) {
|
if (hr != DS_OK) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -168,7 +168,7 @@ static BOOL CALLBACK deviceQueryCallback(LPGUID _lpguid,
|
|||||||
} else {
|
} else {
|
||||||
DSCAPS caps;
|
DSCAPS caps;
|
||||||
LPDIRECTSOUND object;
|
LPDIRECTSOUND object;
|
||||||
hr = DirectSoundCreate(_lpguid, &object, nullptr);
|
hr = DirectSoundCreate(_lpguid, &object, null);
|
||||||
if (hr != DS_OK) {
|
if (hr != DS_OK) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -188,7 +188,7 @@ static BOOL CALLBACK deviceQueryCallback(LPGUID _lpguid,
|
|||||||
// If good device, then save its name and guid.
|
// If good device, then save its name and guid.
|
||||||
etk::String name = convertTChar(_description);
|
etk::String name = convertTChar(_description);
|
||||||
//if (name == "Primary Sound Driver" || name == "Primary Sound Capture Driver")
|
//if (name == "Primary Sound Driver" || name == "Primary Sound Capture Driver")
|
||||||
if (_lpguid == nullptr) {
|
if (_lpguid == null) {
|
||||||
name = "Default Device";
|
name = "Default Device";
|
||||||
}
|
}
|
||||||
DsDevice device;
|
DsDevice device;
|
||||||
@ -233,7 +233,7 @@ audio::orchestra::DeviceInfo audio::orchestra::api::Ds::getDeviceInfo(uint32_t _
|
|||||||
info.input = true;
|
info.input = true;
|
||||||
LPDIRECTSOUND output;
|
LPDIRECTSOUND output;
|
||||||
DSCAPS outCaps;
|
DSCAPS outCaps;
|
||||||
result = DirectSoundCreate(m_private->dsDevices[_device].id, &output, nullptr);
|
result = DirectSoundCreate(m_private->dsDevices[_device].id, &output, null);
|
||||||
if (FAILED(result)) {
|
if (FAILED(result)) {
|
||||||
ATA_ERROR(getErrorString(result) << ": opening output device (" << m_private->dsDevices[_device].name << ")!");
|
ATA_ERROR(getErrorString(result) << ": opening output device (" << m_private->dsDevices[_device].name << ")!");
|
||||||
info.clear();
|
info.clear();
|
||||||
@ -274,7 +274,7 @@ audio::orchestra::DeviceInfo audio::orchestra::api::Ds::getDeviceInfo(uint32_t _
|
|||||||
return info;
|
return info;
|
||||||
} else {
|
} else {
|
||||||
LPDIRECTSOUNDCAPTURE input;
|
LPDIRECTSOUNDCAPTURE input;
|
||||||
result = DirectSoundCaptureCreate(m_private->dsDevices[_device].id, &input, nullptr);
|
result = DirectSoundCaptureCreate(m_private->dsDevices[_device].id, &input, null);
|
||||||
if (FAILED(result)) {
|
if (FAILED(result)) {
|
||||||
ATA_ERROR(getErrorString(result) << ": opening input device (" << m_private->dsDevices[_device].name << ")!");
|
ATA_ERROR(getErrorString(result) << ": opening input device (" << m_private->dsDevices[_device].name << ")!");
|
||||||
info.clear();
|
info.clear();
|
||||||
@ -452,7 +452,7 @@ bool audio::orchestra::api::Ds::open(uint32_t _device,
|
|||||||
HRESULT result;
|
HRESULT result;
|
||||||
if (_mode == audio::orchestra::mode_output) {
|
if (_mode == audio::orchestra::mode_output) {
|
||||||
LPDIRECTSOUND output;
|
LPDIRECTSOUND output;
|
||||||
result = DirectSoundCreate(m_private->dsDevices[_device].id, &output, nullptr);
|
result = DirectSoundCreate(m_private->dsDevices[_device].id, &output, null);
|
||||||
if (FAILED(result)) {
|
if (FAILED(result)) {
|
||||||
ATA_ERROR(getErrorString(result) << ": opening output device (" << m_private->dsDevices[_device].name << ")!");
|
ATA_ERROR(getErrorString(result) << ": opening output device (" << m_private->dsDevices[_device].name << ")!");
|
||||||
return false;
|
return false;
|
||||||
@ -509,7 +509,7 @@ bool audio::orchestra::api::Ds::open(uint32_t _device,
|
|||||||
bufferDescription.dwFlags = DSBCAPS_PRIMARYBUFFER;
|
bufferDescription.dwFlags = DSBCAPS_PRIMARYBUFFER;
|
||||||
// Obtain the primary buffer
|
// Obtain the primary buffer
|
||||||
LPDIRECTSOUNDBUFFER buffer;
|
LPDIRECTSOUNDBUFFER buffer;
|
||||||
result = output->CreateSoundBuffer(&bufferDescription, &buffer, nullptr);
|
result = output->CreateSoundBuffer(&bufferDescription, &buffer, null);
|
||||||
if (FAILED(result)) {
|
if (FAILED(result)) {
|
||||||
output->Release();
|
output->Release();
|
||||||
ATA_ERROR(getErrorString(result) << ": accessing primary buffer (" << m_private->dsDevices[_device].name << ")!");
|
ATA_ERROR(getErrorString(result) << ": accessing primary buffer (" << m_private->dsDevices[_device].name << ")!");
|
||||||
@ -533,13 +533,13 @@ bool audio::orchestra::api::Ds::open(uint32_t _device,
|
|||||||
bufferDescription.lpwfxFormat = &waveFormat;
|
bufferDescription.lpwfxFormat = &waveFormat;
|
||||||
// Try to create the secondary DS buffer. If that doesn't work,
|
// Try to create the secondary DS buffer. If that doesn't work,
|
||||||
// try to use software mixing. Otherwise, there's a problem.
|
// try to use software mixing. Otherwise, there's a problem.
|
||||||
result = output->CreateSoundBuffer(&bufferDescription, &buffer, nullptr);
|
result = output->CreateSoundBuffer(&bufferDescription, &buffer, null);
|
||||||
if (FAILED(result)) {
|
if (FAILED(result)) {
|
||||||
bufferDescription.dwFlags = ( DSBCAPS_STICKYFOCUS
|
bufferDescription.dwFlags = ( DSBCAPS_STICKYFOCUS
|
||||||
| DSBCAPS_GLOBALFOCUS
|
| DSBCAPS_GLOBALFOCUS
|
||||||
| DSBCAPS_GETCURRENTPOSITION2
|
| DSBCAPS_GETCURRENTPOSITION2
|
||||||
| DSBCAPS_LOCSOFTWARE); // Force software mixing
|
| DSBCAPS_LOCSOFTWARE); // Force software mixing
|
||||||
result = output->CreateSoundBuffer(&bufferDescription, &buffer, nullptr);
|
result = output->CreateSoundBuffer(&bufferDescription, &buffer, null);
|
||||||
if (FAILED(result)) {
|
if (FAILED(result)) {
|
||||||
output->Release();
|
output->Release();
|
||||||
ATA_ERROR(getErrorString(result) << ": creating secondary buffer (" << m_private->dsDevices[_device].name << ")!");
|
ATA_ERROR(getErrorString(result) << ": creating secondary buffer (" << m_private->dsDevices[_device].name << ")!");
|
||||||
@ -560,7 +560,7 @@ bool audio::orchestra::api::Ds::open(uint32_t _device,
|
|||||||
// Lock the DS buffer
|
// Lock the DS buffer
|
||||||
LPVOID audioPtr;
|
LPVOID audioPtr;
|
||||||
DWORD dataLen;
|
DWORD dataLen;
|
||||||
result = buffer->Lock(0, dsBufferSize, &audioPtr, &dataLen, nullptr, nullptr, 0);
|
result = buffer->Lock(0, dsBufferSize, &audioPtr, &dataLen, null, null, 0);
|
||||||
if (FAILED(result)) {
|
if (FAILED(result)) {
|
||||||
output->Release();
|
output->Release();
|
||||||
buffer->Release();
|
buffer->Release();
|
||||||
@ -570,7 +570,7 @@ bool audio::orchestra::api::Ds::open(uint32_t _device,
|
|||||||
// Zero the DS buffer
|
// Zero the DS buffer
|
||||||
ZeroMemory(audioPtr, dataLen);
|
ZeroMemory(audioPtr, dataLen);
|
||||||
// Unlock the DS buffer
|
// Unlock the DS buffer
|
||||||
result = buffer->Unlock(audioPtr, dataLen, nullptr, 0);
|
result = buffer->Unlock(audioPtr, dataLen, null, 0);
|
||||||
if (FAILED(result)) {
|
if (FAILED(result)) {
|
||||||
output->Release();
|
output->Release();
|
||||||
buffer->Release();
|
buffer->Release();
|
||||||
@ -582,7 +582,7 @@ bool audio::orchestra::api::Ds::open(uint32_t _device,
|
|||||||
}
|
}
|
||||||
if (_mode == audio::orchestra::mode_input) {
|
if (_mode == audio::orchestra::mode_input) {
|
||||||
LPDIRECTSOUNDCAPTURE input;
|
LPDIRECTSOUNDCAPTURE input;
|
||||||
result = DirectSoundCaptureCreate(m_private->dsDevices[_device].id, &input, nullptr);
|
result = DirectSoundCaptureCreate(m_private->dsDevices[_device].id, &input, null);
|
||||||
if (FAILED(result)) {
|
if (FAILED(result)) {
|
||||||
ATA_ERROR(getErrorString(result) << ": opening input device (" << m_private->dsDevices[_device].name << ")!");
|
ATA_ERROR(getErrorString(result) << ": opening input device (" << m_private->dsDevices[_device].name << ")!");
|
||||||
return false;
|
return false;
|
||||||
@ -642,7 +642,7 @@ bool audio::orchestra::api::Ds::open(uint32_t _device,
|
|||||||
bufferDescription.lpwfxFormat = &waveFormat;
|
bufferDescription.lpwfxFormat = &waveFormat;
|
||||||
// Create the capture buffer.
|
// Create the capture buffer.
|
||||||
LPDIRECTSOUNDCAPTUREBUFFER buffer;
|
LPDIRECTSOUNDCAPTUREBUFFER buffer;
|
||||||
result = input->CreateCaptureBuffer(&bufferDescription, &buffer, nullptr);
|
result = input->CreateCaptureBuffer(&bufferDescription, &buffer, null);
|
||||||
if (FAILED(result)) {
|
if (FAILED(result)) {
|
||||||
input->Release();
|
input->Release();
|
||||||
ATA_ERROR(getErrorString(result) << ": creating input buffer (" << m_private->dsDevices[_device].name << ")!");
|
ATA_ERROR(getErrorString(result) << ": creating input buffer (" << m_private->dsDevices[_device].name << ")!");
|
||||||
@ -666,7 +666,7 @@ bool audio::orchestra::api::Ds::open(uint32_t _device,
|
|||||||
// Lock the capture buffer
|
// Lock the capture buffer
|
||||||
LPVOID audioPtr;
|
LPVOID audioPtr;
|
||||||
DWORD dataLen;
|
DWORD dataLen;
|
||||||
result = buffer->Lock(0, dsBufferSize, &audioPtr, &dataLen, nullptr, nullptr, 0);
|
result = buffer->Lock(0, dsBufferSize, &audioPtr, &dataLen, null, null, 0);
|
||||||
if (FAILED(result)) {
|
if (FAILED(result)) {
|
||||||
input->Release();
|
input->Release();
|
||||||
buffer->Release();
|
buffer->Release();
|
||||||
@ -676,7 +676,7 @@ bool audio::orchestra::api::Ds::open(uint32_t _device,
|
|||||||
// Zero the buffer
|
// Zero the buffer
|
||||||
ZeroMemory(audioPtr, dataLen);
|
ZeroMemory(audioPtr, dataLen);
|
||||||
// Unlock the buffer
|
// Unlock the buffer
|
||||||
result = buffer->Unlock(audioPtr, dataLen, nullptr, 0);
|
result = buffer->Unlock(audioPtr, dataLen, null, 0);
|
||||||
if (FAILED(result)) {
|
if (FAILED(result)) {
|
||||||
input->Release();
|
input->Release();
|
||||||
buffer->Release();
|
buffer->Release();
|
||||||
@ -728,17 +728,17 @@ bool audio::orchestra::api::Ds::open(uint32_t _device,
|
|||||||
free(m_deviceBuffer);
|
free(m_deviceBuffer);
|
||||||
}
|
}
|
||||||
m_deviceBuffer = (char *) calloc(bufferBytes, 1);
|
m_deviceBuffer = (char *) calloc(bufferBytes, 1);
|
||||||
if (m_deviceBuffer == nullptr) {
|
if (m_deviceBuffer == null) {
|
||||||
ATA_ERROR("error allocating device buffer memory.");
|
ATA_ERROR("error allocating device buffer memory.");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Create a manual-reset event.
|
// Create a manual-reset event.
|
||||||
m_private->condition = CreateEvent(nullptr, // no security
|
m_private->condition = CreateEvent(null, // no security
|
||||||
TRUE, // manual-reset
|
TRUE, // manual-reset
|
||||||
FALSE, // non-signaled initially
|
FALSE, // non-signaled initially
|
||||||
nullptr); // unnamed
|
null); // unnamed
|
||||||
m_private->id[modeToIdTable(_mode)] = ohandle;
|
m_private->id[modeToIdTable(_mode)] = ohandle;
|
||||||
m_private->buffer[modeToIdTable(_mode)] = bhandle;
|
m_private->buffer[modeToIdTable(_mode)] = bhandle;
|
||||||
m_private->dsBufferSize[modeToIdTable(_mode)] = dsBufferSize;
|
m_private->dsBufferSize[modeToIdTable(_mode)] = dsBufferSize;
|
||||||
@ -763,7 +763,7 @@ bool audio::orchestra::api::Ds::open(uint32_t _device,
|
|||||||
m_private->threadRunning = true;
|
m_private->threadRunning = true;
|
||||||
ememory::SharedPtr<ethread::Thread> tmpThread(ETK_NEW(ethread::Thread, [=](){audio::orchestra::api::Ds::dsCallbackEvent();});
|
ememory::SharedPtr<ethread::Thread> tmpThread(ETK_NEW(ethread::Thread, [=](){audio::orchestra::api::Ds::dsCallbackEvent();});
|
||||||
m_private->thread = etk::move(tmpThread);
|
m_private->thread = etk::move(tmpThread);
|
||||||
if (m_private->thread == nullptr) {
|
if (m_private->thread == null) {
|
||||||
ATA_ERROR("error creating callback thread!");
|
ATA_ERROR("error creating callback thread!");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -773,7 +773,7 @@ bool audio::orchestra::api::Ds::open(uint32_t _device,
|
|||||||
return true;
|
return true;
|
||||||
error:
|
error:
|
||||||
if (m_private->buffer[0]) {
|
if (m_private->buffer[0]) {
|
||||||
// the object pointer can be nullptr and valid
|
// the object pointer can be null and valid
|
||||||
LPDIRECTSOUND object = (LPDIRECTSOUND) m_private->id[0];
|
LPDIRECTSOUND object = (LPDIRECTSOUND) m_private->id[0];
|
||||||
LPDIRECTSOUNDBUFFER buffer = (LPDIRECTSOUNDBUFFER) m_private->buffer[0];
|
LPDIRECTSOUNDBUFFER buffer = (LPDIRECTSOUNDBUFFER) m_private->buffer[0];
|
||||||
if (buffer) {
|
if (buffer) {
|
||||||
@ -784,7 +784,7 @@ error:
|
|||||||
if (m_private->buffer[1]) {
|
if (m_private->buffer[1]) {
|
||||||
LPDIRECTSOUNDCAPTURE object = (LPDIRECTSOUNDCAPTURE) m_private->id[1];
|
LPDIRECTSOUNDCAPTURE object = (LPDIRECTSOUNDCAPTURE) m_private->id[1];
|
||||||
LPDIRECTSOUNDCAPTUREBUFFER buffer = (LPDIRECTSOUNDCAPTUREBUFFER) m_private->buffer[1];
|
LPDIRECTSOUNDCAPTUREBUFFER buffer = (LPDIRECTSOUNDCAPTUREBUFFER) m_private->buffer[1];
|
||||||
if (buffer != nullptr) {
|
if (buffer != null) {
|
||||||
buffer->Release();
|
buffer->Release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -807,11 +807,11 @@ enum audio::orchestra::error audio::orchestra::api::Ds::closeStream() {
|
|||||||
}
|
}
|
||||||
// Stop the callback thread.
|
// Stop the callback thread.
|
||||||
m_private->threadRunning = false;
|
m_private->threadRunning = false;
|
||||||
if (m_private->thread != nullptr) {
|
if (m_private->thread != null) {
|
||||||
m_private->thread->join();
|
m_private->thread->join();
|
||||||
m_private->thread = nullptr;
|
m_private->thread = null;
|
||||||
}
|
}
|
||||||
if (m_private->buffer[0]) { // the object pointer can be nullptr and valid
|
if (m_private->buffer[0]) { // the object pointer can be null and valid
|
||||||
LPDIRECTSOUND object = (LPDIRECTSOUND) m_private->id[0];
|
LPDIRECTSOUND object = (LPDIRECTSOUND) m_private->id[0];
|
||||||
LPDIRECTSOUNDBUFFER buffer = (LPDIRECTSOUNDBUFFER) m_private->buffer[0];
|
LPDIRECTSOUNDBUFFER buffer = (LPDIRECTSOUNDBUFFER) m_private->buffer[0];
|
||||||
if (buffer) {
|
if (buffer) {
|
||||||
@ -918,7 +918,7 @@ enum audio::orchestra::error audio::orchestra::api::Ds::stopStream() {
|
|||||||
}
|
}
|
||||||
// Lock the buffer and clear it so that if we start to play again,
|
// Lock the buffer and clear it so that if we start to play again,
|
||||||
// we won't have old data playing.
|
// we won't have old data playing.
|
||||||
result = buffer->Lock(0, m_private->dsBufferSize[0], &audioPtr, &dataLen, nullptr, nullptr, 0);
|
result = buffer->Lock(0, m_private->dsBufferSize[0], &audioPtr, &dataLen, null, null, 0);
|
||||||
if (FAILED(result)) {
|
if (FAILED(result)) {
|
||||||
ATA_ERROR(getErrorString(result) << ": locking output buffer!");
|
ATA_ERROR(getErrorString(result) << ": locking output buffer!");
|
||||||
goto unlock;
|
goto unlock;
|
||||||
@ -926,7 +926,7 @@ enum audio::orchestra::error audio::orchestra::api::Ds::stopStream() {
|
|||||||
// Zero the DS buffer
|
// Zero the DS buffer
|
||||||
ZeroMemory(audioPtr, dataLen);
|
ZeroMemory(audioPtr, dataLen);
|
||||||
// Unlock the DS buffer
|
// Unlock the DS buffer
|
||||||
result = buffer->Unlock(audioPtr, dataLen, nullptr, 0);
|
result = buffer->Unlock(audioPtr, dataLen, null, 0);
|
||||||
if (FAILED(result)) {
|
if (FAILED(result)) {
|
||||||
ATA_ERROR(getErrorString(result) << ": unlocking output buffer!");
|
ATA_ERROR(getErrorString(result) << ": unlocking output buffer!");
|
||||||
goto unlock;
|
goto unlock;
|
||||||
@ -937,7 +937,7 @@ enum audio::orchestra::error audio::orchestra::api::Ds::stopStream() {
|
|||||||
if ( m_mode == audio::orchestra::mode_input
|
if ( m_mode == audio::orchestra::mode_input
|
||||||
|| m_mode == audio::orchestra::mode_duplex) {
|
|| m_mode == audio::orchestra::mode_duplex) {
|
||||||
LPDIRECTSOUNDCAPTUREBUFFER buffer = (LPDIRECTSOUNDCAPTUREBUFFER) m_private->buffer[1];
|
LPDIRECTSOUNDCAPTUREBUFFER buffer = (LPDIRECTSOUNDCAPTUREBUFFER) m_private->buffer[1];
|
||||||
audioPtr = nullptr;
|
audioPtr = null;
|
||||||
dataLen = 0;
|
dataLen = 0;
|
||||||
m_state = audio::orchestra::state::stopped;
|
m_state = audio::orchestra::state::stopped;
|
||||||
result = buffer->Stop();
|
result = buffer->Stop();
|
||||||
@ -947,7 +947,7 @@ enum audio::orchestra::error audio::orchestra::api::Ds::stopStream() {
|
|||||||
}
|
}
|
||||||
// Lock the buffer and clear it so that if we start to play again,
|
// Lock the buffer and clear it so that if we start to play again,
|
||||||
// we won't have old data playing.
|
// we won't have old data playing.
|
||||||
result = buffer->Lock(0, m_private->dsBufferSize[1], &audioPtr, &dataLen, nullptr, nullptr, 0);
|
result = buffer->Lock(0, m_private->dsBufferSize[1], &audioPtr, &dataLen, null, null, 0);
|
||||||
if (FAILED(result)) {
|
if (FAILED(result)) {
|
||||||
ATA_ERROR(getErrorString(result) << ": locking input buffer!");
|
ATA_ERROR(getErrorString(result) << ": locking input buffer!");
|
||||||
goto unlock;
|
goto unlock;
|
||||||
@ -955,7 +955,7 @@ enum audio::orchestra::error audio::orchestra::api::Ds::stopStream() {
|
|||||||
// Zero the DS buffer
|
// Zero the DS buffer
|
||||||
ZeroMemory(audioPtr, dataLen);
|
ZeroMemory(audioPtr, dataLen);
|
||||||
// Unlock the DS buffer
|
// Unlock the DS buffer
|
||||||
result = buffer->Unlock(audioPtr, dataLen, nullptr, 0);
|
result = buffer->Unlock(audioPtr, dataLen, null, 0);
|
||||||
if (FAILED(result)) {
|
if (FAILED(result)) {
|
||||||
ATA_ERROR(getErrorString(result) << ": unlocking input buffer!");
|
ATA_ERROR(getErrorString(result) << ": unlocking input buffer!");
|
||||||
goto unlock;
|
goto unlock;
|
||||||
@ -1039,8 +1039,8 @@ void audio::orchestra::api::Ds::callbackEvent() {
|
|||||||
DWORD currentWritePointer, safeWritePointer;
|
DWORD currentWritePointer, safeWritePointer;
|
||||||
DWORD currentReadPointer, safeReadPointer;
|
DWORD currentReadPointer, safeReadPointer;
|
||||||
UINT nextWritePointer;
|
UINT nextWritePointer;
|
||||||
LPVOID buffer1 = nullptr;
|
LPVOID buffer1 = null;
|
||||||
LPVOID buffer2 = nullptr;
|
LPVOID buffer2 = null;
|
||||||
DWORD bufferSize1 = 0;
|
DWORD bufferSize1 = 0;
|
||||||
DWORD bufferSize2 = 0;
|
DWORD bufferSize2 = 0;
|
||||||
char *buffer;
|
char *buffer;
|
||||||
@ -1063,23 +1063,23 @@ void audio::orchestra::api::Ds::callbackEvent() {
|
|||||||
LPDIRECTSOUNDBUFFER dsWriteBuffer = (LPDIRECTSOUNDBUFFER) m_private->buffer[0];
|
LPDIRECTSOUNDBUFFER dsWriteBuffer = (LPDIRECTSOUNDBUFFER) m_private->buffer[0];
|
||||||
LPDIRECTSOUNDCAPTUREBUFFER dsCaptureBuffer = (LPDIRECTSOUNDCAPTUREBUFFER) m_private->buffer[1];
|
LPDIRECTSOUNDCAPTUREBUFFER dsCaptureBuffer = (LPDIRECTSOUNDCAPTUREBUFFER) m_private->buffer[1];
|
||||||
DWORD startSafeWritePointer, startSafeReadPointer;
|
DWORD startSafeWritePointer, startSafeReadPointer;
|
||||||
result = dsWriteBuffer->GetCurrentPosition(nullptr, &startSafeWritePointer);
|
result = dsWriteBuffer->GetCurrentPosition(null, &startSafeWritePointer);
|
||||||
if (FAILED(result)) {
|
if (FAILED(result)) {
|
||||||
ATA_ERROR(getErrorString(result) << ": getting current write position!");
|
ATA_ERROR(getErrorString(result) << ": getting current write position!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
result = dsCaptureBuffer->GetCurrentPosition(nullptr, &startSafeReadPointer);
|
result = dsCaptureBuffer->GetCurrentPosition(null, &startSafeReadPointer);
|
||||||
if (FAILED(result)) {
|
if (FAILED(result)) {
|
||||||
ATA_ERROR(getErrorString(result) << ": getting current read position!");
|
ATA_ERROR(getErrorString(result) << ": getting current read position!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
while (true) {
|
while (true) {
|
||||||
result = dsWriteBuffer->GetCurrentPosition(nullptr, &safeWritePointer);
|
result = dsWriteBuffer->GetCurrentPosition(null, &safeWritePointer);
|
||||||
if (FAILED(result)) {
|
if (FAILED(result)) {
|
||||||
ATA_ERROR(getErrorString(result) << ": getting current write position!");
|
ATA_ERROR(getErrorString(result) << ": getting current write position!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
result = dsCaptureBuffer->GetCurrentPosition(nullptr, &safeReadPointer);
|
result = dsCaptureBuffer->GetCurrentPosition(null, &safeReadPointer);
|
||||||
if (FAILED(result)) {
|
if (FAILED(result)) {
|
||||||
ATA_ERROR(getErrorString(result) << ": getting current read position!");
|
ATA_ERROR(getErrorString(result) << ": getting current read position!");
|
||||||
return;
|
return;
|
||||||
@ -1200,7 +1200,7 @@ void audio::orchestra::api::Ds::callbackEvent() {
|
|||||||
}
|
}
|
||||||
// Copy our buffer into the DS buffer
|
// Copy our buffer into the DS buffer
|
||||||
CopyMemory(buffer1, buffer, bufferSize1);
|
CopyMemory(buffer1, buffer, bufferSize1);
|
||||||
if (buffer2 != nullptr) {
|
if (buffer2 != null) {
|
||||||
CopyMemory(buffer2, buffer+bufferSize1, bufferSize2);
|
CopyMemory(buffer2, buffer+bufferSize1, bufferSize2);
|
||||||
}
|
}
|
||||||
// Update our buffer offset and unlock sound buffer
|
// Update our buffer offset and unlock sound buffer
|
||||||
@ -1318,12 +1318,12 @@ void audio::orchestra::api::Ds::callbackEvent() {
|
|||||||
if (m_duplexPrerollBytes <= 0) {
|
if (m_duplexPrerollBytes <= 0) {
|
||||||
// Copy our buffer into the DS buffer
|
// Copy our buffer into the DS buffer
|
||||||
CopyMemory(buffer, buffer1, bufferSize1);
|
CopyMemory(buffer, buffer1, bufferSize1);
|
||||||
if (buffer2 != nullptr) {
|
if (buffer2 != null) {
|
||||||
CopyMemory(buffer+bufferSize1, buffer2, bufferSize2);
|
CopyMemory(buffer+bufferSize1, buffer2, bufferSize2);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
memset(buffer, 0, bufferSize1);
|
memset(buffer, 0, bufferSize1);
|
||||||
if (buffer2 != nullptr) {
|
if (buffer2 != null) {
|
||||||
memset(buffer + bufferSize1, 0, bufferSize2);
|
memset(buffer + bufferSize1, 0, bufferSize2);
|
||||||
}
|
}
|
||||||
m_duplexPrerollBytes -= bufferSize1 + bufferSize2;
|
m_duplexPrerollBytes -= bufferSize1 + bufferSize2;
|
||||||
|
@ -97,15 +97,15 @@ audio::orchestra::api::Jack::~Jack() {
|
|||||||
uint32_t audio::orchestra::api::Jack::getDeviceCount() {
|
uint32_t audio::orchestra::api::Jack::getDeviceCount() {
|
||||||
// See if we can become a jack client.
|
// See if we can become a jack client.
|
||||||
jack_options_t options = (jack_options_t) (JackNoStartServer); //JackNullOption;
|
jack_options_t options = (jack_options_t) (JackNoStartServer); //JackNullOption;
|
||||||
jack_status_t *status = nullptr;
|
jack_status_t *status = null;
|
||||||
jack_client_t *client = jack_client_open("orchestraJackCount", options, status);
|
jack_client_t *client = jack_client_open("orchestraJackCount", options, status);
|
||||||
if (client == nullptr) {
|
if (client == null) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
const char **ports;
|
const char **ports;
|
||||||
etk::String port, previousPort;
|
etk::String port, previousPort;
|
||||||
uint32_t nChannels = 0, nDevices = 0;
|
uint32_t nChannels = 0, nDevices = 0;
|
||||||
ports = jack_get_ports(client, nullptr, nullptr, 0);
|
ports = jack_get_ports(client, null, null, 0);
|
||||||
if (ports) {
|
if (ports) {
|
||||||
// Parse the port names up to the first colon (:).
|
// Parse the port names up to the first colon (:).
|
||||||
size_t iColon = 0;
|
size_t iColon = 0;
|
||||||
@ -121,7 +121,7 @@ uint32_t audio::orchestra::api::Jack::getDeviceCount() {
|
|||||||
}
|
}
|
||||||
} while (ports[++nChannels]);
|
} while (ports[++nChannels]);
|
||||||
free(ports);
|
free(ports);
|
||||||
ports = nullptr;
|
ports = null;
|
||||||
}
|
}
|
||||||
jack_client_close(client);
|
jack_client_close(client);
|
||||||
return nDevices*2;
|
return nDevices*2;
|
||||||
@ -130,9 +130,9 @@ uint32_t audio::orchestra::api::Jack::getDeviceCount() {
|
|||||||
audio::orchestra::DeviceInfo audio::orchestra::api::Jack::getDeviceInfo(uint32_t _device) {
|
audio::orchestra::DeviceInfo audio::orchestra::api::Jack::getDeviceInfo(uint32_t _device) {
|
||||||
audio::orchestra::DeviceInfo info;
|
audio::orchestra::DeviceInfo info;
|
||||||
jack_options_t options = (jack_options_t) (JackNoStartServer); //JackNullOption
|
jack_options_t options = (jack_options_t) (JackNoStartServer); //JackNullOption
|
||||||
jack_status_t *status = nullptr;
|
jack_status_t *status = null;
|
||||||
jack_client_t *client = jack_client_open("orchestraJackInfo", options, status);
|
jack_client_t *client = jack_client_open("orchestraJackInfo", options, status);
|
||||||
if (client == nullptr) {
|
if (client == null) {
|
||||||
ATA_ERROR("Jack server not found or connection error!");
|
ATA_ERROR("Jack server not found or connection error!");
|
||||||
// TODO : audio::orchestra::error_warning;
|
// TODO : audio::orchestra::error_warning;
|
||||||
info.clear();
|
info.clear();
|
||||||
@ -141,7 +141,7 @@ audio::orchestra::DeviceInfo audio::orchestra::api::Jack::getDeviceInfo(uint32_t
|
|||||||
const char **ports;
|
const char **ports;
|
||||||
etk::String port, previousPort;
|
etk::String port, previousPort;
|
||||||
uint32_t nPorts = 0, nDevices = 0;
|
uint32_t nPorts = 0, nDevices = 0;
|
||||||
ports = jack_get_ports(client, nullptr, nullptr, 0);
|
ports = jack_get_ports(client, null, null, 0);
|
||||||
int32_t deviceID = _device/2;
|
int32_t deviceID = _device/2;
|
||||||
info.input = _device%2==0?true:false; // note that jack sens are inverted
|
info.input = _device%2==0?true:false; // note that jack sens are inverted
|
||||||
if (ports) {
|
if (ports) {
|
||||||
@ -173,7 +173,7 @@ audio::orchestra::DeviceInfo audio::orchestra::api::Jack::getDeviceInfo(uint32_t
|
|||||||
info.sampleRates.clear();
|
info.sampleRates.clear();
|
||||||
info.sampleRates.pushBack(jack_get_sample_rate(client));
|
info.sampleRates.pushBack(jack_get_sample_rate(client));
|
||||||
if (info.input == true) {
|
if (info.input == true) {
|
||||||
ports = jack_get_ports(client, info.name.c_str(), nullptr, JackPortIsOutput);
|
ports = jack_get_ports(client, info.name.c_str(), null, JackPortIsOutput);
|
||||||
if (ports) {
|
if (ports) {
|
||||||
int32_t iii=0;
|
int32_t iii=0;
|
||||||
while (ports[iii]) {
|
while (ports[iii]) {
|
||||||
@ -184,7 +184,7 @@ audio::orchestra::DeviceInfo audio::orchestra::api::Jack::getDeviceInfo(uint32_t
|
|||||||
free(ports);
|
free(ports);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ports = jack_get_ports(client, info.name.c_str(), nullptr, JackPortIsInput);
|
ports = jack_get_ports(client, info.name.c_str(), null, JackPortIsInput);
|
||||||
if (ports) {
|
if (ports) {
|
||||||
int32_t iii=0;
|
int32_t iii=0;
|
||||||
while (ports[iii]) {
|
while (ports[iii]) {
|
||||||
@ -264,7 +264,7 @@ bool audio::orchestra::api::Jack::open(uint32_t _device,
|
|||||||
|| ( _mode == audio::orchestra::mode_input
|
|| ( _mode == audio::orchestra::mode_input
|
||||||
&& m_mode != audio::orchestra::mode_output)) {
|
&& m_mode != audio::orchestra::mode_output)) {
|
||||||
jack_options_t jackoptions = (jack_options_t) (JackNoStartServer); //JackNullOption;
|
jack_options_t jackoptions = (jack_options_t) (JackNoStartServer); //JackNullOption;
|
||||||
jack_status_t *status = nullptr;
|
jack_status_t *status = null;
|
||||||
if (_options.streamName.size() != 0) {
|
if (_options.streamName.size() != 0) {
|
||||||
client = jack_client_open(_options.streamName.c_str(), jackoptions, status);
|
client = jack_client_open(_options.streamName.c_str(), jackoptions, status);
|
||||||
} else {
|
} else {
|
||||||
@ -283,7 +283,7 @@ bool audio::orchestra::api::Jack::open(uint32_t _device,
|
|||||||
uint32_t nPorts = 0, nDevices = 0;
|
uint32_t nPorts = 0, nDevices = 0;
|
||||||
int32_t deviceID = _device/2;
|
int32_t deviceID = _device/2;
|
||||||
bool isInput = _device%2==0?true:false;
|
bool isInput = _device%2==0?true:false;
|
||||||
ports = jack_get_ports(client, nullptr, nullptr, 0);
|
ports = jack_get_ports(client, null, null, 0);
|
||||||
if (ports) {
|
if (ports) {
|
||||||
// Parse the port names up to the first colon (:).
|
// Parse the port names up to the first colon (:).
|
||||||
size_t iColon = 0;
|
size_t iColon = 0;
|
||||||
@ -314,7 +314,7 @@ bool audio::orchestra::api::Jack::open(uint32_t _device,
|
|||||||
if (_mode == audio::orchestra::mode_input) {
|
if (_mode == audio::orchestra::mode_input) {
|
||||||
flag = JackPortIsOutput;
|
flag = JackPortIsOutput;
|
||||||
}
|
}
|
||||||
ports = jack_get_ports(client, deviceName.c_str(), nullptr, flag);
|
ports = jack_get_ports(client, deviceName.c_str(), null, flag);
|
||||||
if (ports) {
|
if (ports) {
|
||||||
while (ports[ nChannels ]) {
|
while (ports[ nChannels ]) {
|
||||||
nChannels++;
|
nChannels++;
|
||||||
@ -335,7 +335,7 @@ bool audio::orchestra::api::Jack::open(uint32_t _device,
|
|||||||
}
|
}
|
||||||
m_sampleRate = jackRate;
|
m_sampleRate = jackRate;
|
||||||
// Get the latency of the JACK port.
|
// Get the latency of the JACK port.
|
||||||
ports = jack_get_ports(client, deviceName.c_str(), nullptr, flag);
|
ports = jack_get_ports(client, deviceName.c_str(), null, flag);
|
||||||
if (ports[ _firstChannel ]) {
|
if (ports[ _firstChannel ]) {
|
||||||
// Added by Ge Wang
|
// Added by Ge Wang
|
||||||
jack_latency_callback_mode_t cbmode = (_mode == audio::orchestra::mode_input ? JackCaptureLatency : JackPlaybackLatency);
|
jack_latency_callback_mode_t cbmode = (_mode == audio::orchestra::mode_input ? JackCaptureLatency : JackPlaybackLatency);
|
||||||
@ -401,7 +401,7 @@ bool audio::orchestra::api::Jack::open(uint32_t _device,
|
|||||||
bufferBytes *= *_bufferSize;
|
bufferBytes *= *_bufferSize;
|
||||||
if (m_deviceBuffer) free(m_deviceBuffer);
|
if (m_deviceBuffer) free(m_deviceBuffer);
|
||||||
m_deviceBuffer = (char *) calloc(bufferBytes, 1);
|
m_deviceBuffer = (char *) calloc(bufferBytes, 1);
|
||||||
if (m_deviceBuffer == nullptr) {
|
if (m_deviceBuffer == null) {
|
||||||
ATA_ERROR("error allocating device buffer memory.");
|
ATA_ERROR("error allocating device buffer memory.");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -409,7 +409,7 @@ bool audio::orchestra::api::Jack::open(uint32_t _device,
|
|||||||
}
|
}
|
||||||
// Allocate memory for the Jack ports (channels) identifiers.
|
// Allocate memory for the Jack ports (channels) identifiers.
|
||||||
m_private->ports[modeToIdTable(_mode)] = (jack_port_t **) malloc (sizeof (jack_port_t *) * _channels);
|
m_private->ports[modeToIdTable(_mode)] = (jack_port_t **) malloc (sizeof (jack_port_t *) * _channels);
|
||||||
if (m_private->ports[modeToIdTable(_mode)] == nullptr) {
|
if (m_private->ports[modeToIdTable(_mode)] == null) {
|
||||||
ATA_ERROR("error allocating port memory.");
|
ATA_ERROR("error allocating port memory.");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -456,20 +456,20 @@ bool audio::orchestra::api::Jack::open(uint32_t _device,
|
|||||||
return true;
|
return true;
|
||||||
error:
|
error:
|
||||||
jack_client_close(m_private->client);
|
jack_client_close(m_private->client);
|
||||||
if (m_private->ports[0] != nullptr) {
|
if (m_private->ports[0] != null) {
|
||||||
free(m_private->ports[0]);
|
free(m_private->ports[0]);
|
||||||
m_private->ports[0] = nullptr;
|
m_private->ports[0] = null;
|
||||||
}
|
}
|
||||||
if (m_private->ports[1] != nullptr) {
|
if (m_private->ports[1] != null) {
|
||||||
free(m_private->ports[1]);
|
free(m_private->ports[1]);
|
||||||
m_private->ports[1] = nullptr;
|
m_private->ports[1] = null;
|
||||||
}
|
}
|
||||||
for (int32_t iii=0; iii<2; ++iii) {
|
for (int32_t iii=0; iii<2; ++iii) {
|
||||||
m_userBuffer[iii].clear();
|
m_userBuffer[iii].clear();
|
||||||
}
|
}
|
||||||
if (m_deviceBuffer) {
|
if (m_deviceBuffer) {
|
||||||
free(m_deviceBuffer);
|
free(m_deviceBuffer);
|
||||||
m_deviceBuffer = nullptr;
|
m_deviceBuffer = null;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -479,26 +479,26 @@ enum audio::orchestra::error audio::orchestra::api::Jack::closeStream() {
|
|||||||
ATA_ERROR("no open stream to close!");
|
ATA_ERROR("no open stream to close!");
|
||||||
return audio::orchestra::error_warning;
|
return audio::orchestra::error_warning;
|
||||||
}
|
}
|
||||||
if (m_private != nullptr) {
|
if (m_private != null) {
|
||||||
if (m_state == audio::orchestra::state::running) {
|
if (m_state == audio::orchestra::state::running) {
|
||||||
jack_deactivate(m_private->client);
|
jack_deactivate(m_private->client);
|
||||||
}
|
}
|
||||||
jack_client_close(m_private->client);
|
jack_client_close(m_private->client);
|
||||||
}
|
}
|
||||||
if (m_private->ports[0] != nullptr) {
|
if (m_private->ports[0] != null) {
|
||||||
free(m_private->ports[0]);
|
free(m_private->ports[0]);
|
||||||
m_private->ports[0] = nullptr;
|
m_private->ports[0] = null;
|
||||||
}
|
}
|
||||||
if (m_private->ports[1] != nullptr) {
|
if (m_private->ports[1] != null) {
|
||||||
free(m_private->ports[1]);
|
free(m_private->ports[1]);
|
||||||
m_private->ports[1] = nullptr;
|
m_private->ports[1] = null;
|
||||||
}
|
}
|
||||||
for (int32_t i=0; i<2; i++) {
|
for (int32_t i=0; i<2; i++) {
|
||||||
m_userBuffer[i].clear();
|
m_userBuffer[i].clear();
|
||||||
}
|
}
|
||||||
if (m_deviceBuffer) {
|
if (m_deviceBuffer) {
|
||||||
free(m_deviceBuffer);
|
free(m_deviceBuffer);
|
||||||
m_deviceBuffer = nullptr;
|
m_deviceBuffer = null;
|
||||||
}
|
}
|
||||||
m_mode = audio::orchestra::mode_unknow;
|
m_mode = audio::orchestra::mode_unknow;
|
||||||
m_state = audio::orchestra::state::closed;
|
m_state = audio::orchestra::state::closed;
|
||||||
@ -525,8 +525,8 @@ enum audio::orchestra::error audio::orchestra::api::Jack::startStream() {
|
|||||||
if ( m_mode == audio::orchestra::mode_output
|
if ( m_mode == audio::orchestra::mode_output
|
||||||
|| m_mode == audio::orchestra::mode_duplex) {
|
|| m_mode == audio::orchestra::mode_duplex) {
|
||||||
result = 1;
|
result = 1;
|
||||||
ports = jack_get_ports(m_private->client, m_private->deviceName[0].c_str(), nullptr, JackPortIsInput);
|
ports = jack_get_ports(m_private->client, m_private->deviceName[0].c_str(), null, JackPortIsInput);
|
||||||
if (ports == nullptr) {
|
if (ports == null) {
|
||||||
ATA_ERROR("error determining available JACK input ports!");
|
ATA_ERROR("error determining available JACK input ports!");
|
||||||
goto unlock;
|
goto unlock;
|
||||||
}
|
}
|
||||||
@ -548,8 +548,8 @@ enum audio::orchestra::error audio::orchestra::api::Jack::startStream() {
|
|||||||
if ( m_mode == audio::orchestra::mode_input
|
if ( m_mode == audio::orchestra::mode_input
|
||||||
|| m_mode == audio::orchestra::mode_duplex) {
|
|| m_mode == audio::orchestra::mode_duplex) {
|
||||||
result = 1;
|
result = 1;
|
||||||
ports = jack_get_ports(m_private->client, m_private->deviceName[1].c_str(), nullptr, JackPortIsOutput);
|
ports = jack_get_ports(m_private->client, m_private->deviceName[1].c_str(), null, JackPortIsOutput);
|
||||||
if (ports == nullptr) {
|
if (ports == null) {
|
||||||
ATA_ERROR("error determining available JACK output ports!");
|
ATA_ERROR("error determining available JACK output ports!");
|
||||||
goto unlock;
|
goto unlock;
|
||||||
}
|
}
|
||||||
|
@ -116,10 +116,10 @@ enum audio::orchestra::error audio::orchestra::api::Pulse::closeStream() {
|
|||||||
m_mutex.unLock();
|
m_mutex.unLock();
|
||||||
m_private->thread->join();
|
m_private->thread->join();
|
||||||
if (m_mode == audio::orchestra::mode_output) {
|
if (m_mode == audio::orchestra::mode_output) {
|
||||||
pa_simple_flush(m_private->handle, nullptr);
|
pa_simple_flush(m_private->handle, null);
|
||||||
}
|
}
|
||||||
pa_simple_free(m_private->handle);
|
pa_simple_free(m_private->handle);
|
||||||
m_private->handle = nullptr;
|
m_private->handle = null;
|
||||||
m_userBuffer[0].clear();
|
m_userBuffer[0].clear();
|
||||||
m_userBuffer[1].clear();
|
m_userBuffer[1].clear();
|
||||||
m_state = audio::orchestra::state::closed;
|
m_state = audio::orchestra::state::closed;
|
||||||
@ -231,8 +231,8 @@ enum audio::orchestra::error audio::orchestra::api::Pulse::stopStream() {
|
|||||||
}
|
}
|
||||||
m_state = audio::orchestra::state::stopped;
|
m_state = audio::orchestra::state::stopped;
|
||||||
m_mutex.lock();
|
m_mutex.lock();
|
||||||
if ( m_private != nullptr
|
if ( m_private != null
|
||||||
&& m_private->handle != nullptr
|
&& m_private->handle != null
|
||||||
&& m_mode == audio::orchestra::mode_output) {
|
&& m_mode == audio::orchestra::mode_output) {
|
||||||
int32_t pa_error;
|
int32_t pa_error;
|
||||||
if (pa_simple_drain(m_private->handle, &pa_error) < 0) {
|
if (pa_simple_drain(m_private->handle, &pa_error) < 0) {
|
||||||
@ -257,8 +257,8 @@ enum audio::orchestra::error audio::orchestra::api::Pulse::abortStream() {
|
|||||||
}
|
}
|
||||||
m_state = audio::orchestra::state::stopped;
|
m_state = audio::orchestra::state::stopped;
|
||||||
m_mutex.lock();
|
m_mutex.lock();
|
||||||
if ( m_private != nullptr
|
if ( m_private != null
|
||||||
&& m_private->handle != nullptr
|
&& m_private->handle != null
|
||||||
&& m_mode == audio::orchestra::mode_output) {
|
&& m_mode == audio::orchestra::mode_output) {
|
||||||
int32_t pa_error;
|
int32_t pa_error;
|
||||||
if (pa_simple_flush(m_private->handle, &pa_error) < 0) {
|
if (pa_simple_flush(m_private->handle, &pa_error) < 0) {
|
||||||
@ -353,7 +353,7 @@ bool audio::orchestra::api::Pulse::open(uint32_t _device,
|
|||||||
bufferBytes *= *_bufferSize;
|
bufferBytes *= *_bufferSize;
|
||||||
if (m_deviceBuffer) free(m_deviceBuffer);
|
if (m_deviceBuffer) free(m_deviceBuffer);
|
||||||
m_deviceBuffer = (char *) calloc(bufferBytes, 1);
|
m_deviceBuffer = (char *) calloc(bufferBytes, 1);
|
||||||
if (m_deviceBuffer == nullptr) {
|
if (m_deviceBuffer == null) {
|
||||||
ATA_ERROR("error allocating device buffer memory.");
|
ATA_ERROR("error allocating device buffer memory.");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -367,15 +367,15 @@ bool audio::orchestra::api::Pulse::open(uint32_t _device,
|
|||||||
int32_t error;
|
int32_t error;
|
||||||
switch (_mode) {
|
switch (_mode) {
|
||||||
case audio::orchestra::mode_input:
|
case audio::orchestra::mode_input:
|
||||||
m_private->handle = pa_simple_new(nullptr, "orchestra", PA_STREAM_RECORD, nullptr, "Record", &ss, nullptr, nullptr, &error);
|
m_private->handle = pa_simple_new(null, "orchestra", PA_STREAM_RECORD, null, "Record", &ss, null, null, &error);
|
||||||
if (m_private->handle == nullptr) {
|
if (m_private->handle == null) {
|
||||||
ATA_ERROR("error connecting input to PulseAudio server.");
|
ATA_ERROR("error connecting input to PulseAudio server.");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case audio::orchestra::mode_output:
|
case audio::orchestra::mode_output:
|
||||||
m_private->handle = pa_simple_new(nullptr, "orchestra", PA_STREAM_PLAYBACK, nullptr, "Playback", &ss, nullptr, nullptr, &error);
|
m_private->handle = pa_simple_new(null, "orchestra", PA_STREAM_PLAYBACK, null, "Playback", &ss, null, null, &error);
|
||||||
if (m_private->handle == nullptr) {
|
if (m_private->handle == null) {
|
||||||
ATA_ERROR("error connecting output to PulseAudio server.");
|
ATA_ERROR("error connecting output to PulseAudio server.");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@ -391,7 +391,7 @@ bool audio::orchestra::api::Pulse::open(uint32_t _device,
|
|||||||
if (m_private->threadRunning == false) {
|
if (m_private->threadRunning == false) {
|
||||||
m_private->threadRunning = true;
|
m_private->threadRunning = true;
|
||||||
m_private->thread = ememory::makeShared<ethread::Thread>([&](){callbackEvent();}, "pulseCallback");
|
m_private->thread = ememory::makeShared<ethread::Thread>([&](){callbackEvent();}, "pulseCallback");
|
||||||
if (m_private->thread == nullptr) {
|
if (m_private->thread == null) {
|
||||||
ATA_ERROR("error creating thread.");
|
ATA_ERROR("error creating thread.");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
@ -277,7 +277,7 @@ etk::Vector<audio::orchestra::DeviceInfo> audio::orchestra::api::pulse::getDevic
|
|||||||
// We can't do anything until PA is ready, so just iterate the mainloop
|
// We can't do anything until PA is ready, so just iterate the mainloop
|
||||||
// and continue
|
// and continue
|
||||||
if (pulseAudioReady == 0) {
|
if (pulseAudioReady == 0) {
|
||||||
pa_mainloop_iterate(pulseAudioMainLoop, 1, nullptr);
|
pa_mainloop_iterate(pulseAudioMainLoop, 1, null);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// We couldn't get a connection to the server, so exit out
|
// We couldn't get a connection to the server, so exit out
|
||||||
@ -331,7 +331,7 @@ etk::Vector<audio::orchestra::DeviceInfo> audio::orchestra::api::pulse::getDevic
|
|||||||
}
|
}
|
||||||
// Iterate the main loop ..
|
// Iterate the main loop ..
|
||||||
if (playLoop == true) {
|
if (playLoop == true) {
|
||||||
pa_mainloop_iterate(pulseAudioMainLoop, 1, nullptr);
|
pa_mainloop_iterate(pulseAudioMainLoop, 1, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO: need to do it better ...
|
// TODO: need to do it better ...
|
||||||
|
Loading…
Reference in New Issue
Block a user