updating to ios5 recorder doesn't work anymore

Member
Posts: 164
Joined: 2010.10
Post: #1
i have an app always working till i have installed ios5 on device.
this is the code.

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
Quote this message in a reply
Member
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
Member
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
Member
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 8,761 Jan 12, 2010 04:40 PM
Last Post: AnotherJake
  Updating Map Annotations - coordinates PHANTOMIAS 0 2,479 Dec 8, 2009 08:39 AM
Last Post: PHANTOMIAS
  Browser Based.. Updating turn times? guest_05 1 2,910 May 24, 2007 04:03 PM
Last Post: Tobs_
  Updating only parts of the screen Josh 1 2,978 Dec 18, 2002 02:38 AM
Last Post: kelvin