updating to ios5 recorder doesn't work anymore

Posts: 164
Joined: 2010.10
Post: #1
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);

        NSURL *url = [NSURL fileURLWithPath:@"/dev/null"];
        NSDictionary *audioSettings = [NSDictionary dictionaryWithObjectsAndKeys:
                                       [NSNumber numberWithFloat: 44100.0],                 AVSampleRateKey,
                                       [NSNumber numberWithInt: kAudioFormatAppleLossless], AVFormatIDKey,
                                       [NSNumber numberWithInt: 1],                         AVNumberOfChannelsKey,
                                       [NSNumber numberWithInt: AVAudioQualityMax],         AVEncoderAudioQualityKey,
        NSError *error;    
        bool b;
        recorder = [[AVAudioRecorder alloc] initWithURL:url settings:audioSettings error:&error];
        if (recorder) {
            b=[recorder prepareToRecord];
            //NSLog(@"%@",(b ? @"OK" : @"NO"));
            recorder.meteringEnabled = YES;
            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?
Quote this message in a reply
Posts: 446
Joined: 2002.09
Post: #2
I'm not sure it should ever have worked with the session set to kAudioSessionCategory_MediaPlayback.
Quote this message in a reply
Posts: 164
Joined: 2010.10
Post: #3
another strange thing: if i terminate the app then restart, it works...
Quote this message in a reply
Posts: 164
Joined: 2010.10
Post: #4
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?
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  About object creation, updating, interactions, Unity Najdorf 26 17,348 Jan 12, 2010 04:40 PM
Last Post: AnotherJake
  Updating Map Annotations - coordinates PHANTOMIAS 0 3,785 Dec 8, 2009 08:39 AM
  Browser Based.. Updating turn times? guest_05 1 4,424 May 24, 2007 04:03 PM
Last Post: Tobs_
  Updating only parts of the screen Josh 1 4,186 Dec 18, 2002 02:38 AM
Last Post: kelvin