我按照以下步骤创建一个AudioQueue。
AudioQueueNewOutput创建一个新的输出kAudioQueueProperty_IsRunning属性添加属性侦听器AudioQueueAllocateBuffer分配我的缓冲区AudioQueuePrimeAudioQueueStart问题是,当我调用AudioQueuePrime时,它会输出控制台上的错误
AudioConverterNew returned -50
Prime failed (-50); will stop (11025/0 frames)这里怎么了?
PS:
AudioQueueNewOutput时安装的输出回调永远不会被调用!AudioStreamBasicDescription确实与格式(AAC)匹配。Init代码示例:
// 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 15:43:50
AudioConverterNew返回-50素数失败(-50);将停止(11025/0帧) 这里怎么了?
你做错了。
不,真的。这就是那个错误的含义,也是所有这些错误的含义。
这就是为什么paramErr (-50)是如此令人讨厌的错误代码的原因:它对你(或其他人)做错了什么没说什么。
对它抱怨的内容进行猜测的第一步是找出返回该错误的函数。更改_reportError:方法,使您能够记录返回错误的函数的名称。然后,记录您要传递给该函数的参数,并找出为什么认为该函数的那些参数没有意义。
我自己的猜测是,这是因为您强制进入ASBD的值与示例缓冲区的特性不匹配。在您的问题中包含的日志输出是“11025 /0帧”;11025是一个常见的抽样率(但与44100不同)。我想你应该知道0指的是什么吧。
https://stackoverflow.com/questions/4117776
复制相似问题