i have an app always working till i have installed ios5 on device.
this is the code.
UInt32 sessionCategory = kAudioSessionCategory_MediaPlayback;
AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(sessionCategory), &sessionCategory);
UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker;
AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute,sizeof (audioRouteOverride),&audioRouteOverride);
//NSLog(@"url");
NSURL *url = [NSURL fileURLWithPath:@"/dev/null"];
//NSLog(@"dizionario");
NSDictionary *audioSettings = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithFloat: 44100.0], AVSampleRateKey,
[NSNumber numberWithInt: kAudioFormatAppleLossless], AVFormatIDKey,
[NSNumber numberWithInt: 1], AVNumberOfChannelsKey,
[NSNumber numberWithInt: AVAudioQualityMax], AVEncoderAudioQualityKey,
nil];
NSError *error;
bool b;
//NSLog(@"audio");
recorder = [[AVAudioRecorder alloc] initWithURL:url settings:audioSettings error:&error];
//NSLog(@"audio");
if (recorder) {
//NSLog(@"prepara");
b=[recorder prepareToRecord];
//NSLog(@"%@",(b ? @"OK" : @"NO"));
//NSLog(@"meter");
recorder.meteringEnabled = YES;
//NSLog(@"recorder");
b=[recorder record];
//NSLog(@"%@", (b ? @"OK" : @"NO"));
// NSLog(@"leveltimer");
// levelTimer = [NSTimer scheduledTimerWithTimeInterval: 0.03 target: self selector: @selector(levelTimerCallback:) userInfo: nil repeats: YES];
} else {
NSLog(@"************** ERRORE: ****************");
NSLog([error description]);
}
the result is that recorder record silence, no peak power, no avarage power.
i use xcode4 (ios inxcode4 is till 4.3, i have not downloaded the latest xcode)
why in ios5 doesn’t work anymore?
is not compatible?
thanks
i have downloaded the latest xcode, tryed
Documents or Cache instead of /dev/null but no luck
i have solved but don’t know why it stopped working.
the code above was putted in a singleton class loaded and initialized once at start of the app.
seems that records only one voice power then stops (even if i have controlled that recording=true, metering enabled=true ecc…in logs)
now i have putted the same code in a method of the singleton class and called that method from the file of the screen “ingame” and works…
mmm…….any ideas why it happens?