1

オーディオ データに余分な録音を追加した後、オーディオ データの再生に問題があります。エラーを返さないイベントの一般的なシーケンスは次のとおりです。

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 を移動して魔法の Cookie をリセットするさまざまな組み合わせを試しましたが、役に立ちませんでした。

私が使用しているオーディオ形式は次のとおりです。

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

ここで何が起こっているのですか?AudioFileID を再度開いた後、追加されたオーディオが再生されないのはなぜですか?

4

1 に答える 1

1

AudioFileClose を呼び出す必要があります。詳細については、http: //lists.apple.com/archives/Coreaudio-api/2011/Oct/msg00014.htmlを参照してください。

于 2011-10-04T17:00:52.937 に答える