我在以下步骤中创建了一个AudioQueue。AudioQueue无法启动
- 创建
AudioQueueNewOutput
- 一个新的输出添加的属性侦听器
kAudioQueueProperty_IsRunning
财产 - 分配我的缓冲区与
AudioQueueAllocateBuffer
- 呼叫
AudioQueuePrime
- 呼叫
AudioQueueStart
的问题是,当我打电话AudioQueuePrime
它在控制台上输出以下错误
AudioConverterNew returned -50
Prime failed (-50); will stop (11025/0 frames)
这里有什么问题?
PS:
- 我在iOS上得到这个错误(设备&模拟器)
- 调用
AudioQueueNewOutput
安装时的输出回调不会被调用! - 该文件是有效的,
AudioStreamBasicDescription
不匹配的格式(AAC) - 我测试了垫的AudioStreamer文件,它似乎在那里工作
示例初始化代码:
// Get the stream description from the first sample buffer
OSStatus err = noErr;
EDSampleBuffer *firstBuf = [sampleBufs objectAtIndex:0];
AudioStreamBasicDescription asbd = firstBuf.streamDescription;
// TODO: remove temporary format setup, just to ensure format for now
asbd.mSampleRate = 44100.00;
asbd.mFramesPerPacket = 1024; // AAC default
asbd.mChannelsPerFrame = 2;
pfcc(asbd.mFormatID);
// -----------------------------------
// Create a new output
err = AudioQueueNewOutput(&asbd, _audioQueueOutputCallback, self, NULL, NULL, 0, &audioQueue);
if (err) {
[self _reportError:kASAudioQueueInitializationError];
goto bail;
}
// Add property listener for queue state
err = AudioQueueAddPropertyListener(audioQueue, kAudioQueueProperty_IsRunning, _audioQueueIsRunningCallback, self);
if (err) {
[self _reportError:kASAudioQueuePropertyListenerError];
goto bail;
}
// Allocate a queue buffers
for (int i=0; i<kAQNumBufs; i++) {
err = AudioQueueAllocateBuffer(audioQueue, kAQDefaultBufSize, &queueBuffer[i]);
if (err) {
[self _reportError:kASAudioQueueBufferAllocationError];
goto bail;
}
}
// Prime and start
err = AudioQueuePrime(audioQueue, 0, NULL);
if (err) {
printf("failed to prime audio queue %ld\n", err);
goto bail;
}
err = AudioQueueStart(audioQueue, NULL);
if (err) {
printf("failed to start audio queue %ld\n", err);
goto bail;
}
这些是来自音频文件流的格式标志
rate: 44100.000000
framesPerPacket: 1024
format: aac
bitsPerChannel: 0
reserved: 0
channelsPerFrame: 2
bytesPerFrame: 0
bytesPerPacket: 0
formatFlags: 0
cookieSize 39
你能提供我们的代码吗?谢谢。 – 2010-11-07 12:54:27
@Jacob这不是很多,但我现在附上它 – 2010-11-07 12:59:42