Skip to content

Commit

Permalink
Add IOMutex to IO Operations
Browse files Browse the repository at this point in the history
  • Loading branch information
devinroth committed Aug 8, 2020
1 parent e7a0615 commit ba30813
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions BlackHole/BlackHole.c
Original file line number Diff line number Diff line change
Expand Up @@ -3885,6 +3885,9 @@ static OSStatus BlackHole_DoIOOperation(AudioServerPlugInDriverRef inDriver, Aud
FailWithAction(inDeviceObjectID != kObjectID_Device, theAnswer = kAudioHardwareBadObjectError, Done, "BlackHole_DoIOOperation: bad device ID");
FailWithAction((inStreamObjectID != kObjectID_Stream_Input) && (inStreamObjectID != kObjectID_Stream_Output), theAnswer = kAudioHardwareBadObjectError, Done, "BlackHole_DoIOOperation: bad stream ID");

// IO Lock
pthread_mutex_lock(&gDevice_IOMutex);

/* READ INPUT */
if(inOperationID == kAudioServerPlugInIOOperationReadInput)
{
Expand Down Expand Up @@ -3960,6 +3963,8 @@ static OSStatus BlackHole_DoIOOperation(AudioServerPlugInDriverRef inDriver, Aud
// clear the io buffer
memset(ioMainBuffer, 0, inIOBufferByteSize);
}

pthread_mutex_unlock(&gDevice_IOMutex);

Done:
return theAnswer;
Expand Down

0 comments on commit ba30813

Please sign in to comment.