[DEV] MAcOS is now Ok ==> error when killing the application
This commit is contained in:
parent
c35dbe04f4
commit
9b55657ef1
@ -13,7 +13,7 @@
|
|||||||
//
|
//
|
||||||
// *************************************************** //
|
// *************************************************** //
|
||||||
|
|
||||||
#if defined(__MACOSX_CORE__)
|
#if defined(__MACOSX_CORE__) || defined(__IOS_CORE__)
|
||||||
|
|
||||||
#include <airtaudio/Interface.h>
|
#include <airtaudio/Interface.h>
|
||||||
#include <airtaudio/debug.h>
|
#include <airtaudio/debug.h>
|
||||||
@ -151,7 +151,7 @@ uint32_t airtaudio::api::Core::getDefaultInputDevice(void) {
|
|||||||
}
|
}
|
||||||
for (uint32_t iii=0; iii<nDevices; iii++) {
|
for (uint32_t iii=0; iii<nDevices; iii++) {
|
||||||
if (id == deviceList[iii]) {
|
if (id == deviceList[iii]) {
|
||||||
return i;
|
return iii;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ATA_ERROR("airtaudio::api::Core::getDefaultInputDevice: No default device found!");
|
ATA_ERROR("airtaudio::api::Core::getDefaultInputDevice: No default device found!");
|
||||||
@ -202,8 +202,8 @@ uint32_t airtaudio::api::Core::getDefaultOutputDevice(void) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
rtaudio::DeviceInfo airtaudio::api::Core::getDeviceInfo(uint32_t _device) {
|
airtaudio::DeviceInfo airtaudio::api::Core::getDeviceInfo(uint32_t _device) {
|
||||||
rtaudio::DeviceInfo info;
|
airtaudio::DeviceInfo info;
|
||||||
info.probed = false;
|
info.probed = false;
|
||||||
// Get device ID
|
// Get device ID
|
||||||
uint32_t nDevices = getDeviceCount();
|
uint32_t nDevices = getDeviceCount();
|
||||||
@ -212,7 +212,7 @@ rtaudio::DeviceInfo airtaudio::api::Core::getDeviceInfo(uint32_t _device) {
|
|||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
if (_device >= nDevices) {
|
if (_device >= nDevices) {
|
||||||
m_errorText = "airtaudio::api::Core::getDeviceInfo: device ID is invalid!";
|
ATA_ERROR("airtaudio::api::Core::getDeviceInfo: device ID is invalid!");
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
AudioDeviceID deviceList[ nDevices ];
|
AudioDeviceID deviceList[ nDevices ];
|
||||||
@ -272,7 +272,7 @@ rtaudio::DeviceInfo airtaudio::api::Core::getDeviceInfo(uint32_t _device) {
|
|||||||
dataSize = 0;
|
dataSize = 0;
|
||||||
result = AudioObjectGetPropertyDataSize(id, &property, 0, NULL, &dataSize);
|
result = AudioObjectGetPropertyDataSize(id, &property, 0, NULL, &dataSize);
|
||||||
if (result != noErr || dataSize == 0) {
|
if (result != noErr || dataSize == 0) {
|
||||||
ATA_ERROR("airtaudio::api::Core::getDeviceInfo: system error (" << getErrorCode(result) << ") getting output stream configuration info for device (" << device << ").");
|
ATA_ERROR("airtaudio::api::Core::getDeviceInfo: system error (" << getErrorCode(result) << ") getting output stream configuration info for device (" << _device << ").");
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
// Allocate the AudioBufferList.
|
// Allocate the AudioBufferList.
|
||||||
@ -390,8 +390,8 @@ static OSStatus callbackHandler(AudioDeviceID _inDevice,
|
|||||||
AudioBufferList* _outOutputData,
|
AudioBufferList* _outOutputData,
|
||||||
const AudioTimeStamp* _inOutputTime,
|
const AudioTimeStamp* _inOutputTime,
|
||||||
void* _infoPointer) {
|
void* _infoPointer) {
|
||||||
CallbackInfo* info = (CallbackInfo*)_infoPointer;
|
airtaudio::CallbackInfo* info = (airtaudio::CallbackInfo*)_infoPointer;
|
||||||
RtApiCore* object = (RtApiCore*)info->object;
|
airtaudio::api::Core* object = (airtaudio::api::Core*)info->object;
|
||||||
if (object->callbackEvent(_inDevice, _inInputData, _outOutputData) == false) {
|
if (object->callbackEvent(_inDevice, _inInputData, _outOutputData) == false) {
|
||||||
return kAudioHardwareUnspecifiedError;
|
return kAudioHardwareUnspecifiedError;
|
||||||
} else {
|
} else {
|
||||||
@ -551,7 +551,7 @@ bool airtaudio::api::Core::probeDeviceOpen(uint32_t _device,
|
|||||||
}
|
}
|
||||||
firstStream = iStream;
|
firstStream = iStream;
|
||||||
channelOffset = offsetCounter;
|
channelOffset = offsetCounter;
|
||||||
Int32 channelCounter = _channels + offsetCounter - streamChannels;
|
int32_t channelCounter = _channels + offsetCounter - streamChannels;
|
||||||
if (streamChannels > 1) {
|
if (streamChannels > 1) {
|
||||||
monoMode = false;
|
monoMode = false;
|
||||||
}
|
}
|
||||||
@ -580,7 +580,7 @@ bool airtaudio::api::Core::probeDeviceOpen(uint32_t _device,
|
|||||||
*_bufferSize = (uint64_t) bufferRange.mMaximum;
|
*_bufferSize = (uint64_t) bufferRange.mMaximum;
|
||||||
}
|
}
|
||||||
if ( _options != NULL
|
if ( _options != NULL
|
||||||
&& _options->flags & RTAUDIO_MINIMIZE_LATENCY) {
|
&& _options->flags & MINIMIZE_LATENCY) {
|
||||||
*_bufferSize = (uint64_t) bufferRange.mMinimum;
|
*_bufferSize = (uint64_t) bufferRange.mMinimum;
|
||||||
}
|
}
|
||||||
// Set the buffer size. For multiple streams, I'm assuming we only
|
// Set the buffer size. For multiple streams, I'm assuming we only
|
||||||
@ -606,7 +606,7 @@ bool airtaudio::api::Core::probeDeviceOpen(uint32_t _device,
|
|||||||
m_stream.nBuffers = 1;
|
m_stream.nBuffers = 1;
|
||||||
// Try to set "hog" mode ... it's not clear to me this is working.
|
// Try to set "hog" mode ... it's not clear to me this is working.
|
||||||
if ( _options != NULL
|
if ( _options != NULL
|
||||||
&& _options->flags & RTAUDIO_HOG_DEVICE) {
|
&& _options->flags & HOG_DEVICE) {
|
||||||
pid_t hog_pid;
|
pid_t hog_pid;
|
||||||
dataSize = sizeof(hog_pid);
|
dataSize = sizeof(hog_pid);
|
||||||
property.mSelector = kAudioDevicePropertyHogMode;
|
property.mSelector = kAudioDevicePropertyHogMode;
|
||||||
@ -764,7 +764,7 @@ bool airtaudio::api::Core::probeDeviceOpen(uint32_t _device,
|
|||||||
m_stream.latency[ _mode ] = latency;
|
m_stream.latency[ _mode ] = latency;
|
||||||
} else {
|
} else {
|
||||||
ATA_ERROR("airtaudio::api::Core::probeDeviceOpen: system error (" << getErrorCode(result) << ") getting device latency for device (" << _device << ").");
|
ATA_ERROR("airtaudio::api::Core::probeDeviceOpen: system error (" << getErrorCode(result) << ") getting device latency for device (" << _device << ").");
|
||||||
error(airtaudio::errorWarning);
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Byte-swapping: According to AudioHardware.h, the stream data will
|
// Byte-swapping: According to AudioHardware.h, the stream data will
|
||||||
@ -784,7 +784,7 @@ bool airtaudio::api::Core::probeDeviceOpen(uint32_t _device,
|
|||||||
m_stream.nUserChannels[_mode] = _channels;
|
m_stream.nUserChannels[_mode] = _channels;
|
||||||
m_stream.channelOffset[_mode] = channelOffset; // offset within a CoreAudio stream
|
m_stream.channelOffset[_mode] = channelOffset; // offset within a CoreAudio stream
|
||||||
if ( _options != NULL
|
if ( _options != NULL
|
||||||
&& _options->flags & RTAUDIO_NONINTERLEAVED) {
|
&& _options->flags & NONINTERLEAVED) {
|
||||||
m_stream.userInterleaved = false;
|
m_stream.userInterleaved = false;
|
||||||
} else {
|
} else {
|
||||||
m_stream.userInterleaved = true;
|
m_stream.userInterleaved = true;
|
||||||
@ -813,9 +813,9 @@ bool airtaudio::api::Core::probeDeviceOpen(uint32_t _device,
|
|||||||
CoreHandle *handle = 0;
|
CoreHandle *handle = 0;
|
||||||
if (m_stream.apiHandle == 0) {
|
if (m_stream.apiHandle == 0) {
|
||||||
handle = new CoreHandle;
|
handle = new CoreHandle;
|
||||||
if (handle == NULL);
|
if (handle == NULL) {
|
||||||
ATA_ERROR("airtaudio::api::Core::probeDeviceOpen: error allocating CoreHandle memory.");
|
ATA_ERROR("airtaudio::api::Core::probeDeviceOpen: error allocating CoreHandle memory.");
|
||||||
goto error;
|
return false;
|
||||||
}
|
}
|
||||||
m_stream.apiHandle = (void *) handle;
|
m_stream.apiHandle = (void *) handle;
|
||||||
} else {
|
} else {
|
||||||
@ -984,7 +984,6 @@ enum airtaudio::errorType airtaudio::api::Core::startStream(void) {
|
|||||||
result = AudioDeviceStart(handle->id[0], callbackHandler);
|
result = AudioDeviceStart(handle->id[0], callbackHandler);
|
||||||
if (result != noErr) {
|
if (result != noErr) {
|
||||||
ATA_ERROR("airtaudio::api::Core::startStream: system error (" << getErrorCode(result) << ") starting callback procedure on device (" << m_stream.device[0] << ").");
|
ATA_ERROR("airtaudio::api::Core::startStream: system error (" << getErrorCode(result) << ") starting callback procedure on device (" << m_stream.device[0] << ").");
|
||||||
m_errorText = m_errorStream.str();
|
|
||||||
goto unlock;
|
goto unlock;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -993,8 +992,7 @@ enum airtaudio::errorType airtaudio::api::Core::startStream(void) {
|
|||||||
&& m_stream.device[0] != m_stream.device[1])) {
|
&& m_stream.device[0] != m_stream.device[1])) {
|
||||||
result = AudioDeviceStart(handle->id[1], callbackHandler);
|
result = AudioDeviceStart(handle->id[1], callbackHandler);
|
||||||
if (result != noErr) {
|
if (result != noErr) {
|
||||||
m_errorStream << "airtaudio::api::Core::startStream: system error starting input callback procedure on device (" << m_stream.device[1] << ").";
|
ATA_ERROR("airtaudio::api::Core::startStream: system error starting input callback procedure on device (" << m_stream.device[1] << ").");
|
||||||
m_errorText = m_errorStream.str();
|
|
||||||
goto unlock;
|
goto unlock;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1067,8 +1065,8 @@ enum airtaudio::errorType airtaudio::api::Core::abortStream(void) {
|
|||||||
// callbackEvent() function probably should return before the AudioDeviceStop()
|
// callbackEvent() function probably should return before the AudioDeviceStop()
|
||||||
// function is called.
|
// function is called.
|
||||||
static void coreStopStream(void *_ptr) {
|
static void coreStopStream(void *_ptr) {
|
||||||
CallbackInfo* info = (CallbackInfo*)_ptr;
|
airtaudio::CallbackInfo* info = (airtaudio::CallbackInfo*)_ptr;
|
||||||
RtApiCore* object = (RtApiCore*)info->object;
|
airtaudio::api::Core* object = (airtaudio::api::Core*)info->object;
|
||||||
object->stopStream();
|
object->stopStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1103,15 +1101,15 @@ bool airtaudio::api::Core::callbackEvent(AudioDeviceID _deviceId,
|
|||||||
if (handle->drainCounter == 0 && (m_stream.mode != DUPLEX || _deviceId == outputDevice)) {
|
if (handle->drainCounter == 0 && (m_stream.mode != DUPLEX || _deviceId == outputDevice)) {
|
||||||
airtaudio::AirTAudioCallback callback = (airtaudio::AirTAudioCallback) info->callback;
|
airtaudio::AirTAudioCallback callback = (airtaudio::AirTAudioCallback) info->callback;
|
||||||
double streamTime = getStreamTime();
|
double streamTime = getStreamTime();
|
||||||
rtaudio::streamStatus status = 0;
|
airtaudio::streamStatus status = 0;
|
||||||
if ( m_stream.mode != INPUT
|
if ( m_stream.mode != INPUT
|
||||||
&& handle->xrun[0] == true) {
|
&& handle->xrun[0] == true) {
|
||||||
status |= RTAUDIO_OUTPUT_UNDERFLOW;
|
status |= OUTPUT_UNDERFLOW;
|
||||||
handle->xrun[0] = false;
|
handle->xrun[0] = false;
|
||||||
}
|
}
|
||||||
if ( m_stream.mode != OUTPUT
|
if ( m_stream.mode != OUTPUT
|
||||||
&& handle->xrun[1] == true) {
|
&& handle->xrun[1] == true) {
|
||||||
status |= RTAUDIO_INPUT_OVERFLOW;
|
status |= INPUT_OVERFLOW;
|
||||||
handle->xrun[1] = false;
|
handle->xrun[1] = false;
|
||||||
}
|
}
|
||||||
int32_t cbReturnValue = callback(m_stream.userBuffer[0],
|
int32_t cbReturnValue = callback(m_stream.userBuffer[0],
|
||||||
@ -1318,7 +1316,7 @@ bool airtaudio::api::Core::callbackEvent(AudioDeviceID _deviceId,
|
|||||||
|
|
||||||
unlock:
|
unlock:
|
||||||
//m_stream.mutex.unlock();
|
//m_stream.mutex.unlock();
|
||||||
RtApi::tickStreamTime();
|
airtaudio::Api::tickStreamTime();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,11 +6,14 @@
|
|||||||
* @license like MIT (see license file)
|
* @license like MIT (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if !defined(__AIRTAUDIO_API_CORE_H__) && defined(__MACOSX_CORE__)
|
#if !defined(__AIRTAUDIO_API_CORE_H__) && (defined(__MACOSX_CORE__) || defined(__IOS_CORE__))
|
||||||
#define __AIRTAUDIO_API_CORE_H__
|
#define __AIRTAUDIO_API_CORE_H__
|
||||||
|
|
||||||
#include <CoreAudio/AudioHardware.h>
|
#if defined(__IOS_CORE__)
|
||||||
|
#include <CoreAudio/CoreAudioTypes.h>
|
||||||
|
#else
|
||||||
|
#include <CoreAudio/AudioHardware.h>
|
||||||
|
#endif
|
||||||
namespace airtaudio {
|
namespace airtaudio {
|
||||||
namespace api {
|
namespace api {
|
||||||
class Core: public airtaudio::Api {
|
class Core: public airtaudio::Api {
|
||||||
|
@ -47,7 +47,11 @@ def create(target):
|
|||||||
# MacOsX core
|
# MacOsX core
|
||||||
myModule.add_export_flag_CC(['-D__MACOSX_CORE__'])
|
myModule.add_export_flag_CC(['-D__MACOSX_CORE__'])
|
||||||
myModule.add_export_flag_LD("-framework CoreAudio")
|
myModule.add_export_flag_LD("-framework CoreAudio")
|
||||||
myModule.add_export_flag_LD("-framework CoreMIDI")
|
elif target.name=="IOs":
|
||||||
|
# IOsX core
|
||||||
|
#myModule.add_export_flag_CC(['-D__IOS_CORE__'])
|
||||||
|
#myModule.add_export_flag_LD("-framework CoreAudio")
|
||||||
|
pass
|
||||||
elif target.name=="Android":
|
elif target.name=="Android":
|
||||||
# MacOsX core
|
# MacOsX core
|
||||||
myModule.add_export_flag_CC(['-D__ANDROID_JAVA__'])
|
myModule.add_export_flag_CC(['-D__ANDROID_JAVA__'])
|
||||||
|
Loading…
Reference in New Issue
Block a user