Core Audio output: Add various minor changes
parent
c4c29be35a
commit
5c0a510848
|
@ -27,6 +27,7 @@
|
||||||
Semaphore * writeSemaphore;
|
Semaphore * writeSemaphore;
|
||||||
Semaphore * readSemaphore;
|
Semaphore * readSemaphore;
|
||||||
|
|
||||||
|
BOOL stopInvoked;
|
||||||
BOOL running;
|
BOOL running;
|
||||||
BOOL stopping;
|
BOOL stopping;
|
||||||
BOOL stopped;
|
BOOL stopped;
|
||||||
|
|
|
@ -20,9 +20,9 @@ static void fillBuffers(AudioBufferList *ioData, float * inbuffer, size_t count,
|
||||||
const size_t channels = ioData->mNumberBuffers;
|
const size_t channels = ioData->mNumberBuffers;
|
||||||
for (int i = 0; i < channels; ++i)
|
for (int i = 0; i < channels; ++i)
|
||||||
{
|
{
|
||||||
size_t maxCount = (ioData->mBuffers[i].mDataByteSize / sizeof(float)) - offset;
|
const size_t maxCount = (ioData->mBuffers[i].mDataByteSize / sizeof(float)) - offset;
|
||||||
float * output = ((float *)ioData->mBuffers[i].mData) + offset;
|
float * output = ((float *)ioData->mBuffers[i].mData) + offset;
|
||||||
float * input = inbuffer + i;
|
const float * input = inbuffer + i;
|
||||||
for (size_t j = 0, k = (count > maxCount) ? maxCount : count; j < k; ++j)
|
for (size_t j = 0, k = (count > maxCount) ? maxCount : count; j < k; ++j)
|
||||||
{
|
{
|
||||||
*output = *input;
|
*output = *input;
|
||||||
|
@ -276,7 +276,8 @@ default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const
|
||||||
[writeSemaphore timedWait:5000];
|
[writeSemaphore timedWait:5000];
|
||||||
}
|
}
|
||||||
stopped = YES;
|
stopped = YES;
|
||||||
[self stop];
|
if (!stopInvoked)
|
||||||
|
[self stop];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (OSStatus)setOutputDeviceByID:(AudioDeviceID)deviceID
|
- (OSStatus)setOutputDeviceByID:(AudioDeviceID)deviceID
|
||||||
|
@ -532,6 +533,7 @@ default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const
|
||||||
if (_au)
|
if (_au)
|
||||||
[self stop];
|
[self stop];
|
||||||
|
|
||||||
|
stopInvoked = NO;
|
||||||
running = NO;
|
running = NO;
|
||||||
stopping = NO;
|
stopping = NO;
|
||||||
stopped = NO;
|
stopped = NO;
|
||||||
|
@ -620,8 +622,8 @@ default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const
|
||||||
|
|
||||||
for (i = 0; i < channels; ++i) {
|
for (i = 0; i < channels; ++i) {
|
||||||
float * outBuffer = ((float*)inputData->mBuffers[0].mData) + i;
|
float * outBuffer = ((float*)inputData->mBuffers[0].mData) + i;
|
||||||
float * inBuffer = ((float*)ioData->mBuffers[i].mData);
|
const float * inBuffer = ((float*)ioData->mBuffers[i].mData);
|
||||||
int frameCount = ioData->mBuffers[i].mDataByteSize / sizeof(float);
|
const int frameCount = ioData->mBuffers[i].mDataByteSize / sizeof(float);
|
||||||
for (int j = 0; j < frameCount; ++j) {
|
for (int j = 0; j < frameCount; ++j) {
|
||||||
*outBuffer = *inBuffer;
|
*outBuffer = *inBuffer;
|
||||||
inBuffer++;
|
inBuffer++;
|
||||||
|
@ -692,6 +694,7 @@ default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const
|
||||||
|
|
||||||
- (void)stop
|
- (void)stop
|
||||||
{
|
{
|
||||||
|
stopInvoked = YES;
|
||||||
stopping = YES;
|
stopping = YES;
|
||||||
paused = NO;
|
paused = NO;
|
||||||
[writeSemaphore signal];
|
[writeSemaphore signal];
|
||||||
|
|
Loading…
Reference in New Issue