通过AudioQueueStart功能在iOS7中录音

时间:2014-02-12 12:52:15

标签: iphone audio ios7 recording

我的代码在iOS6上工作正常但在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

请指导......

1 个答案:

答案 0 :(得分:1)

@Kalaichelvan's commentperfect

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

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

编辑:上面的代码对我有用