Core Audio Output: Add a check that should prevent it from attempting to output data through the callback during or after destruction
parent
91473a11e9
commit
da96d2c21e
|
@ -17,6 +17,8 @@
|
|||
|
||||
@interface OutputCoreAudio : NSObject {
|
||||
OutputNode * outputController;
|
||||
|
||||
BOOL stopping;
|
||||
|
||||
AudioDeviceID outputDeviceID;
|
||||
AudioUnit outputUnit;
|
||||
|
|
|
@ -34,6 +34,13 @@ static OSStatus Sound_Renderer(void *inRefCon, AudioUnitRenderActionFlags *ioAc
|
|||
void *readPointer = ioData->mBuffers[0].mData;
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -384,6 +391,7 @@ static OSStatus Sound_Renderer(void *inRefCon, AudioUnitRenderActionFlags *ioAc
|
|||
size);
|
||||
|
||||
//setup render callbacks
|
||||
stopping = NO;
|
||||
renderCallback.inputProc = Sound_Renderer;
|
||||
renderCallback.inputProcRefCon = (__bridge void * _Nullable)(self);
|
||||
|
||||
|
@ -413,6 +421,7 @@ static OSStatus Sound_Renderer(void *inRefCon, AudioUnitRenderActionFlags *ioAc
|
|||
{
|
||||
if (outputUnit)
|
||||
{
|
||||
stopping = YES;
|
||||
AudioOutputUnitStop(outputUnit);
|
||||
AudioUnitUninitialize (outputUnit);
|
||||
AudioComponentInstanceDispose(outputUnit);
|
||||
|
|
Loading…
Reference in New Issue