I trying to record aac audio stream to file.
i creating a AudioFileID
AudioStreamBasicDescription asbd2;
memset(&asbd2, 0, sizeof(asbd2));
asbd2.mSampleRate = [[AVAudioSession sharedInstance] sampleRate];
asbd2.mChannelsPerFrame = (UInt32)[[AVAudioSession sharedInstance] inputNumberOfChannels];
AudioFileID audioFile;
NSArray * dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString * docsDir = [dirPaths objectAtIndex:0];
NSString *pathForTheFile = [docsDir stringByAppendingPathComponent:@"test.caf"];
CFURLRef fileURL = (__bridge CFURLRef)[NSURL fileURLWithPath:pathForTheFile];
OSStatus status = AudioFileCreateWithURL(fileURL,
kAudioFileAAC_ADTSType,
&asbd2,
kAudioFileFlags_EraseFile,
&audioFile);
self.fileIDGlob = audioFile;
it creates without errors.
then i open a stream and parse it(works without errors). i use https://github.com/mattgallagher/AudioStreamer to read stream
err = AudioFileStreamOpen(self, ASPropertyListenerProc, ASPacketsProc,
fileTypeHint, &audioFileStream);
AudioFileStreamParseBytes(audioFileStream, length, bytes, kAudioFileStreamParseFlag_Discontinuity);
When i trying to write data to file
OSStatus status = AudioFileWriteBytes(self.fileIDGlob, false, 0, &length, &bytes);
in status i receive 1869627199, as i understand it is kAudioFileOperationNotSupportedError.
But i can't understand why i receive this error code.