gpt4 book ai didi

iphone - AudioQueueStart 报告不支持的格式

转载 作者:行者123 更新时间:2023-12-03 20:12:18 26 4
gpt4 key购买 nike

我试图让音频队列在 iPhone 应用程序上工作,每当调用 AudioQueueStart 时,它都会给出“fmt?”结果代码(kAudioFormatUnsupportedDataFormatError)。在下面的代码中,我将格式设置为 kAudioFormatLinearPCM,这肯定是受支持的。我做错了什么?

data.mDataFormat.mSampleRate = 44100;
data.mDataFormat.mFormatID = kAudioFormatLinearPCM;
data.mDataFormat.mFormatFlags = 0;
data.mDataFormat.mBytesPerPacket = 4;
data.mDataFormat.mFramesPerPacket = 1;
data.mDataFormat.mBytesPerFrame = 4;
data.mDataFormat.mChannelsPerFrame = 2;
data.mDataFormat.mBitsPerChannel = 16;

OSStatus status;

status = AudioQueueNewOutput(&data.mDataFormat, audioCallback, &data, CFRunLoopGetCurrent (), kCFRunLoopCommonModes, 0, &data.mQueue);

for (int i = 0; i < NUMBUFFERS; ++i)
{
status = AudioQueueAllocateBuffer (data.mQueue, BUFFERSIZE, &data.mBuffers[i] );
audioCallback (&data, data.mQueue, data.mBuffers[i]);
}

Float32 gain = 1.0;
status = AudioQueueSetParameter (data.mQueue, kAudioQueueParam_Volume, gain);

status = AudioQueueStart(data.mQueue, NULL);

数据的类型为audioData,如下所示:

typedef struct _audioData {
AudioQueueRef mQueue;
AudioQueueBufferRef mBuffers[NUMBUFFERS];
AudioStreamBasicDescription mDataFormat;

} 音频数据;

谢谢

最佳答案

错误的原因实际上是 AudioQueueNewOutput 而不是 AudioQueueStart。请参阅此相关问题 audio streaming services failing to recognize file type

关于iphone - AudioQueueStart 报告不支持的格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1459689/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com