Iphone 通过AudioQueueStart函数在iOS7中录音

Iphone 通过AudioQueueStart函数在iOS7中录音,iphone,audio,ios7,recording,Iphone,Audio,Ios7,Recording,我的代码在iOS 6上运行良好,但在iOS 7上运行不正常,请指导 UInt32 enableMetering = 0; status = AudioQueueSetProperty(recordState.queue, kAudioQueueProperty_EnableLevelMetering, &enableMetering,sizeof(enableMetering)); if (status) {fprintf(stderr, "Could not enabl

我的代码在iOS 6上运行良好,但在iOS 7上运行不正常,请指导

UInt32 enableMetering = 0;
    status = AudioQueueSetProperty(recordState.queue, kAudioQueueProperty_EnableLevelMetering, &enableMetering,sizeof(enableMetering));
    if (status) {fprintf(stderr, "Could not enable metering\n"); return NO;}

// this line giving error
**status = AudioQueueStart(recordState.queue, NULL);**
  if (status) {fprintf(stderr, "Could not start Audio Queue\n"); return NO;}
recordState.currentPacket = 0;
recordState.recording = YES;
return YES;
错误是

Could not start Audio Queue
Error starting recording

请引导…

@Kalaichelvan的
评论
完美的

我在iOS 7.1中遇到了类似的问题。在AppDelegate的didFinishLaunchingWithOptions中添加以下内容:

AVAudioSession * audioSession = [AVAudioSession sharedInstance]; 
[audioSession setCategory:AVAudioSessionCategoryPlayAndRecord error: nil]; 
[audioSession setActive:YES error: nil]; 

编辑:以上代码对我有效

使用选项在application DidFinishLaunching中添加以下代码:AVAudioSession*audioSession=[AVAudioSession sharedInstance];[audioSession setCategory:AvaudioSessionCategory播放和记录错误:无];[audioSession setActive:是错误:无];