Skip to content

Commit

Permalink
Fix input always being disabled after ARC refactor. #50
Browse files Browse the repository at this point in the history
  • Loading branch information
ndonald2 committed Jul 1, 2013
1 parent 438a692 commit 0f7dd5b
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions Novocaine/Novocaine.m
Expand Up @@ -211,11 +211,14 @@ - (void)setupAudioSession
// Initialize and configure the audio session, and add an interuption listener

#if defined ( USING_IOS )

// Set the audio session active
NSError *err = nil;
if (![[AVAudioSession sharedInstance] setActive:YES error:&err]){
NSLog(@"Could not activate audio session: %@", err);
NSLog(@"Couldn't activate audio session: %@", err);
}
[self checkAudioSource];
[
self checkAudioSource];
#elif defined ( USING_OSX )
// TODO: grab the audio device
[self enumerateAudioDevices];
Expand All @@ -232,6 +235,7 @@ - (void)setupAudioUnits

#if defined ( USING_IOS )

// TODO: Move this somewhere more dynamic - should update category as appropriate to current application behavior
UInt32 sessionCategory = kAudioSessionCategory_PlayAndRecord;
CheckError( AudioSessionSetProperty (kAudioSessionProperty_AudioCategory,
sizeof (sessionCategory),
Expand All @@ -247,25 +251,12 @@ - (void)setupAudioUnits
Float32 preferredBufferSize = 0.0232;
CheckError( AudioSessionSetProperty(kAudioSessionProperty_PreferredHardwareIOBufferDuration, sizeof(preferredBufferSize), &preferredBufferSize), "Couldn't set the preferred buffer duration");
#endif


// Set the audio session active
NSError *err = nil;
if (![[AVAudioSession sharedInstance] setActive:YES error:&err]){
NSLog(@"Couldn't activate audio session: %@", err);
}



[self checkSessionProperties];

#elif defined ( USING_OSX )



#endif



// ----- Audio Unit Setup -----
// ----------------------------

Expand Down Expand Up @@ -302,6 +293,16 @@ - (void)setupAudioUnits
CheckError( AudioComponentInstanceNew(outputComponent, &_outputUnit), "Couldn't create the output audio unit");
#endif

// Enable input
// TODO: Conditionally disable input if option has not been specified
UInt32 one = 1;
CheckError( AudioUnitSetProperty(_inputUnit,
kAudioOutputUnitProperty_EnableIO,
kAudioUnitScope_Input,
kInputBus,
&one,
sizeof(one)), "Couldn't enable IO on the input scope of output unit");


#if defined ( USING_OSX )
// Disable output on the input unit
Expand All @@ -315,7 +316,6 @@ - (void)setupAudioUnits
sizeof(UInt32)), "Couldn't disable output on the audio unit");

// Enable output
UInt32 one = 1;
CheckError( AudioUnitSetProperty(_outputUnit,
kAudioOutputUnitProperty_EnableIO,
kAudioUnitScope_Output,
Expand Down

0 comments on commit 0f7dd5b

Please sign in to comment.