2011-09-27 2 views
0

추가 레코딩을 추가 한 후 오디오 데이터를 재생할 때 문제가 있습니다. 다음은 오류를 반환하지 않는 일반적인 이벤트 순서입니다.AudioFileOpenURL 이후에 오디오를 추가 할 때의 문제

AudioQueueNewInput  // Start audio queue 
AudioFileCreateWithURL // Create audio file 
AudioFileSetProperty  // Set magic cookie 

AudioQueueAllocateBuffer // Allocate buffers 
AudioQueueEnqueueBuffer // Prime buffer 
AudioQueueStart   // Start the audio queue 

// Record some audio in the audio queue callback... 
AudioQueueWritePackets 
AudioQueueEnqueueBuffer 

AudioQueueStop   // Stop the queue 
AudioQueueFlush   // Flush remaining buffers in the queue 
AudioFileSetProperty  // Set magic cookie again (needed for some formats?) 
AudioQueueDispose  // Dispose queue 
AudioFileClose   // Close the file 

녹음을 추가하기 위해 대기열을 시작 및 중지 할 수 있습니다. 정상적으로 작동합니다. 오디오가 완벽하게 추가되며 예상대로 재생할 수 있습니다.

AudioQueueNewInput  // Start audio queue 
AudioFileOpenURL   // Re-open audio file 
AudioFileGetProperty  // Get packet count and resume recording at last packet 
AudioFileOptimize  // "Optimize" the file for appending 
AudioFileSetProperty  // Set magic cookie 

AudioQueueAllocateBuffer // Allocate buffers 
AudioQueueEnqueueBuffer // Prime buffer 
AudioQueueStart   // Start the audio queue 

// Record some audio in the audio queue callback... 
AudioQueueWritePackets 
AudioQueueEnqueueBuffer 

AudioQueueStop   // Stop the queue 
AudioQueueFlush   // Flush remaining buffers in the queue 

나는 오디오의 마지막 패킷에서 녹화 재개하는데주의를 기울여야하고, 내가 볼 수 있기 때문에 실제로 데이터가 파일에 추가되는 : 문제는 그 때 파일을 다시 열고 추가하려고 온다 파일 크기가 커집니다. 그러나 파일을 재생할 때 추가 된 오디오가 들리지 않습니다. 원래 오디오는 재생되지만 추가 오디오가 들리기 전에 중단됩니다.

나는 AudioFileOptimize를 돌아 다니면서 마법의 쿠키를 무용지물로 재설정하는 다양한 조합을 시도해 보았습니다.

다음과 같이 내가 사용하는 오디오 형식은 다음과 같습니다 여기 무슨 일

static const AudioStreamBasicDescription kMyAudioFormat = { 
    .mFormatID = kAudioFormatAppleIMA4, 
    .mSampleRate = 44100.0, 
    .mChannelsPerFrame = 2, 
    .mBitsPerChannel = 0, 
    .mBytesPerPacket = 68, 
    .mBytesPerFrame = 0, 
    .mFramesPerPacket = 64, 
    .mFormatFlags = 0 
}; 

? AudioFileID를 다시 연 후 왜 추가 오디오가 재생되지 않습니까?

+0

나는 이것을 알아 냈다고 생각합니다. 어쨌든, 제대로 작동합니다. 내 변경 사항은 1. AudioQueueDispose보다 먼저 AudioFileClose를 호출하고 2. 오디오 대기열이 중지되면 AudioFileClose를 호출합니다 (IsRunning의 속성 수신기에서). 큐를 시작하고 멈추는 사이에 파일을 열어 놓지 않고 최대한 빨리 파일을 열고 닫습니다. – Donald

답변

관련 문제