Start audio recording giving error sometimes and below method returns error
Error Domain=NSOSStatusErrorDomain Code=-50 "(null)" UserInfo= status = AudioQueueStart(_state.queue, NULL);
Followed below steps for recording audo -
Created a new audio queue for recording audio data.
status = AudioQueueNewInput(&_state.dataFormat, AudioInputCallback, &_state, CFRunLoopGetCurrent(), kCFRunLoopCommonModes, 0, &_state.queue);Sets an audio queue property value.
status = AudioQueueSetProperty(_state.queue,kAudioQueueProperty_EnableLevelMetering,&on,sizeof(on));an audio queue to allocate a buffer.
status = AudioQueueAllocateBuffer(_state.queue, buffer_size, &_state.buffers[i]);Assigns a buffer to an audio queue for recording or playback.
status = AudioQueueEnqueueBuffer (_state.queue, _state.buffers[i], 0, NULL);Added a listener callback for a property.
status = AudioQueueAddPropertyListener(_state.queue, kAudioQueueProperty_IsRunning, recordingRunningChangedCallback, &_state);Begins playing or recording audio.
status = AudioQueueStart(_state.queue, NULL);
And last steps returns error with
error code -50
As can be found here, this is
AVAudioSessionErrorCodeBadParam.So apparently one of the parameters you specify is invalid or a parameter is missing.
Does this help perhaps?
As setting up audio in iOS is rather intricate, I advice you to start from working sample code, or to follow a decent tutorial. From own experience I can tell that it's easy to miss something and get errors like this.
Good luck!