• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

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

[复制链接]
菜鸟教程小白 发表于 2022-12-12 21:46:03 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

我正在尝试让 Adamson 和 Avila 的《Learning Core Audio》第 4 章中的录音程序正常工作。手动输入和从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");



Best Answer-推荐答案


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

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

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap