2010-06-23 6 views
0

나는 다음과 같은 코드가 있습니다AudioFileWriteBytes 반환 오류 -50 무작위로

OSStatus status = AudioFileWriteBytes(self.audioFile, FALSE, self.startingByte, &ioNumBytes, theData); 

상태 코드가 무작위로 아이폰 시뮬레이터에 NOERR -50을 반환합니다.

다시 실행하면 작동합니다.

위의 코드가 무작위로 행동하는 이유는 무엇이든 감사 할 것입니다.

미리 도움을 주셔서 감사합니다.

답변

1

내 문제를 발견했다고 생각합니다.

문제와 원래 코드 :

// Start 
OSStatus status = AudioOutputUnitStart(self.ioUnit); 

// Record the audio samples and save it to a file 
[self createFile]; 

문제를 해결 새로운 코드입니다. 은 "CreateFile에"이 AudioOutputUnitStart 파일로 오디오 샘플 내용을 기록하는 콜백 메소드를 호출 AudioOutputUnitStart

// Record the audio samples and save it to a file 
[self createFile]; 

// Start 
// Once AudioOutputUnitStart is called, it will start calling callback method quickly. We need to call the above [self createFile] first. 
OSStatus status = AudioOutputUnitStart(self.ioUnit); 

를 호출하기 전에 먼저라고 알 수 있습니다. 파일이 AudioOutputUnitStart 전에 작성되었거나 열렸으므로 오디오 샘플이 오류없이 파일에 기록됩니다.

관련 문제