Compare commits

...
Sign in to create a new pull request.
Author SHA1 Message Date
Richard Cartwright
68ce920967 Update darwin build to use newer core audio frameworks.
Replaced references to core services audio component with equivalent
function calls in the AudioUnit/AudioComponent.h API.
2017-11-09 21:32:10 +00:00
2 changed files with 171 additions and 170 deletions

View file

@ -1173,8 +1173,8 @@ static PaError OpenAndSetupOneAudioUnit(
const double sampleRate, const double sampleRate,
void *refCon ) void *refCon )
{ {
ComponentDescription desc; AudioComponentDescription desc;
Component comp; AudioComponent comp;
/*An Apple TN suggests using CAStreamBasicDescription, but that is C++*/ /*An Apple TN suggests using CAStreamBasicDescription, but that is C++*/
AudioStreamBasicDescription desiredFormat; AudioStreamBasicDescription desiredFormat;
OSStatus result = noErr; OSStatus result = noErr;
@ -1245,7 +1245,7 @@ static PaError OpenAndSetupOneAudioUnit(
desc.componentFlags = 0; desc.componentFlags = 0;
desc.componentFlagsMask = 0; desc.componentFlagsMask = 0;
/* -- find the component -- */ /* -- find the component -- */
comp = FindNextComponent( NULL, &desc ); comp = AudioComponentFindNext( NULL, &desc );
if( !comp ) if( !comp )
{ {
DBUG( ( "AUHAL component not found." ) ); DBUG( ( "AUHAL component not found." ) );
@ -1254,7 +1254,7 @@ static PaError OpenAndSetupOneAudioUnit(
return paUnanticipatedHostError; return paUnanticipatedHostError;
} }
/* -- open it -- */ /* -- open it -- */
result = OpenAComponent( comp, audioUnit ); result = AudioComponentInstanceNew( comp, audioUnit );
if( result ) if( result )
{ {
DBUG( ( "Failed to open AUHAL component." ) ); DBUG( ( "Failed to open AUHAL component." ) );
@ -1607,7 +1607,7 @@ static PaError OpenAndSetupOneAudioUnit(
#undef ERR_WRAP #undef ERR_WRAP
error: error:
CloseComponent( *audioUnit ); AudioComponentInstanceDispose( *audioUnit );
*audioUnit = NULL; *audioUnit = NULL;
if( result ) if( result )
return PaMacCore_SetError( result, line, 1 ); return PaMacCore_SetError( result, line, 1 );
@ -2645,13 +2645,13 @@ static PaError CloseStream( PaStream* s )
} }
if( stream->outputUnit && stream->outputUnit != stream->inputUnit ) { if( stream->outputUnit && stream->outputUnit != stream->inputUnit ) {
AudioUnitUninitialize( stream->outputUnit ); AudioUnitUninitialize( stream->outputUnit );
CloseComponent( stream->outputUnit ); AudioComponentInstanceDispose( stream->outputUnit );
} }
stream->outputUnit = NULL; stream->outputUnit = NULL;
if( stream->inputUnit ) if( stream->inputUnit )
{ {
AudioUnitUninitialize( stream->inputUnit ); AudioUnitUninitialize( stream->inputUnit );
CloseComponent( stream->inputUnit ); AudioComponentInstanceDispose( stream->inputUnit );
stream->inputUnit = NULL; stream->inputUnit = NULL;
} }
if( stream->inputRingBuffer.buffer ) if( stream->inputRingBuffer.buffer )
@ -2711,12 +2711,12 @@ static PaError StartStream( PaStream *s )
// it's not clear from appl's docs that this really waits // it's not clear from appl's docs that this really waits
// until all data is flushed. // until all data is flushed.
static ComponentResult BlockWhileAudioUnitIsRunning( AudioUnit audioUnit, AudioUnitElement element ) static OSStatus BlockWhileAudioUnitIsRunning( AudioUnit audioUnit, AudioUnitElement element )
{ {
Boolean isRunning = 1; Boolean isRunning = 1;
while( isRunning ) { while( isRunning ) {
UInt32 s = sizeof( isRunning ); UInt32 s = sizeof( isRunning );
ComponentResult err = AudioUnitGetProperty( audioUnit, kAudioOutputUnitProperty_IsRunning, kAudioUnitScope_Global, element, &isRunning, &s ); OSStatus err = AudioUnitGetProperty( audioUnit, kAudioOutputUnitProperty_IsRunning, kAudioUnitScope_Global, element, &isRunning, &s );
if( err ) if( err )
return err; return err;
Pa_Sleep( 100 ); Pa_Sleep( 100 );

View file

@ -62,6 +62,7 @@
#define PA_MAC_CORE_INTERNAL_H__ #define PA_MAC_CORE_INTERNAL_H__
#include <CoreAudio/CoreAudio.h> #include <CoreAudio/CoreAudio.h>
#include <AudioUnit/AudioComponent.h>
#include <CoreServices/CoreServices.h> #include <CoreServices/CoreServices.h>
#include <AudioUnit/AudioUnit.h> #include <AudioUnit/AudioUnit.h>
#include <AudioToolbox/AudioToolbox.h> #include <AudioToolbox/AudioToolbox.h>