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
I've just had the same issue. For whatever reason calling AudioQueueStart twice did the trick for me:
status = AudioQueueStart(_state.queue, NULL);
if (status == -50) {
status = AudioQueueStart(_state.queue, NULL);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With