iDevGames Forums
updating to ios5 recorder doesn't work anymore - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Programming Fundamentals (/forum-7.html)
+--- Thread: updating to ios5 recorder doesn't work anymore (/thread-9547.html)



updating to ios5 recorder doesn't work anymore - sefiroths - Nov 17, 2011 01:42 PM

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


RE: updating to ios5 recorder doesn't work anymore - Frank C. - Nov 17, 2011 09:50 PM

I'm not sure it should ever have worked with the session set to kAudioSessionCategory_MediaPlayback.


RE: updating to ios5 recorder doesn't work anymore - sefiroths - Nov 18, 2011 06:29 AM

another strange thing: if i terminate the app then restart, it works...


RE: updating to ios5 recorder doesn't work anymore - sefiroths - Nov 21, 2011 03:56 AM

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?