gpt4 book ai didi

ios - 学习核心音频的第 4 章由于 AudioQueueNewInput 因 fmt 失败而无法正常工作?

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:23:50 27 4
gpt4 key购买 nike

我正在尝试让 Adamson 和 Avila 编写的 Learning Core Audio 第 4 章中的 Recording 程序正常工作。手动输入和从 informit 网站下载的未修改版本都以同样的方式失败。它总是在创建队列时失败。

Error: AudioQueueNewInput failed ('fmt?')

还有其他人在 Mavericks 和 XCode5 上尝试过这个示例程序吗?这是从下载站点到故障点的那个。当我尝试使用一些硬编码参数的 LPCM 时,没问题,但我无法让 MPEG4AAC 工作。不过,AppleLossless 似乎可以正常工作。

// Code from download
int main(int argc, const char *argv[])
{
MyRecorder recorder = {0};
AudioStreamBasicDescription recordFormat = {0};
memset(&recordFormat, 0, sizeof(recordFormat));

// Configure the output data format to be AAC
recordFormat.mFormatID = kAudioFormatMPEG4AAC;
recordFormat.mChannelsPerFrame = 2;

// get the sample rate of the default input device
// we use this to adapt the output data format to match hardware capabilities
MyGetDefaultInputDeviceSampleRate(&recordFormat.mSampleRate);

// ProTip: Use the AudioFormat API to trivialize ASBD creation.
// input: at least the mFormatID, however, at this point we already have
// mSampleRate, mFormatID, and mChannelsPerFrame
// output: the remainder of the ASBD will be filled out as much as possible
// given the information known about the format
UInt32 propSize = sizeof(recordFormat);
CheckError(AudioFormatGetProperty(kAudioFormatProperty_FormatInfo, 0, NULL,
&propSize, &recordFormat), "AudioFormatGetProperty failed");

// create a input (recording) queue
AudioQueueRef queue = {0};
CheckError(AudioQueueNewInput(&recordFormat, // ASBD
MyAQInputCallback, // Callback
&recorder, // user data
NULL, // run loop
NULL, // run loop mode
0, // flags (always 0)
// &recorder.queue), // output: reference to AudioQueue object
&queue),
"AudioQueueNewInput failed");

最佳答案

我遇到了同样的问题。检查采样率。在你的情况下,它将是巨大的(96000)。只需尝试将其手动设置为 44100。

关于ios - 学习核心音频的第 4 章由于 AudioQueueNewInput 因 fmt 失败而无法正常工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23145345/

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