Core Audio Output: Add a check that should prevent it from attempting to output data through the callback during or after destruction
This commit is contained in:
parent
91473a11e9
commit
da96d2c21e
2 changed files with 11 additions and 0 deletions
|
@ -17,6 +17,8 @@
|
||||||
|
|
||||||
@interface OutputCoreAudio : NSObject {
|
@interface OutputCoreAudio : NSObject {
|
||||||
OutputNode * outputController;
|
OutputNode * outputController;
|
||||||
|
|
||||||
|
BOOL stopping;
|
||||||
|
|
||||||
AudioDeviceID outputDeviceID;
|
AudioDeviceID outputDeviceID;
|
||||||
AudioUnit outputUnit;
|
AudioUnit outputUnit;
|
||||||
|
|
|
@ -34,6 +34,13 @@ static OSStatus Sound_Renderer(void *inRefCon, AudioUnitRenderActionFlags *ioAc
|
||||||
void *readPointer = ioData->mBuffers[0].mData;
|
void *readPointer = ioData->mBuffers[0].mData;
|
||||||
|
|
||||||
int amountToRead, amountRead;
|
int amountToRead, amountRead;
|
||||||
|
|
||||||
|
if (output->stopping == YES)
|
||||||
|
{
|
||||||
|
// *shrug* At least this will stop it from trying to emit data post-shutdown
|
||||||
|
ioData->mBuffers[0].mDataByteSize = 0;
|
||||||
|
return eofErr;
|
||||||
|
}
|
||||||
|
|
||||||
if ([output->outputController shouldContinue] == NO)
|
if ([output->outputController shouldContinue] == NO)
|
||||||
{
|
{
|
||||||
|
@ -384,6 +391,7 @@ static OSStatus Sound_Renderer(void *inRefCon, AudioUnitRenderActionFlags *ioAc
|
||||||
size);
|
size);
|
||||||
|
|
||||||
//setup render callbacks
|
//setup render callbacks
|
||||||
|
stopping = NO;
|
||||||
renderCallback.inputProc = Sound_Renderer;
|
renderCallback.inputProc = Sound_Renderer;
|
||||||
renderCallback.inputProcRefCon = (__bridge void * _Nullable)(self);
|
renderCallback.inputProcRefCon = (__bridge void * _Nullable)(self);
|
||||||
|
|
||||||
|
@ -413,6 +421,7 @@ static OSStatus Sound_Renderer(void *inRefCon, AudioUnitRenderActionFlags *ioAc
|
||||||
{
|
{
|
||||||
if (outputUnit)
|
if (outputUnit)
|
||||||
{
|
{
|
||||||
|
stopping = YES;
|
||||||
AudioOutputUnitStop(outputUnit);
|
AudioOutputUnitStop(outputUnit);
|
||||||
AudioUnitUninitialize (outputUnit);
|
AudioUnitUninitialize (outputUnit);
|
||||||
AudioComponentInstanceDispose(outputUnit);
|
AudioComponentInstanceDispose(outputUnit);
|
||||||
|
|
Loading…
Reference in a new issue