【发布时间】:2013-08-22 14:09:29
【问题描述】:
我在 mac os x 上使用 vpio 音频单元进行捕获和播放。
一切顺利,直到我在 vpio 单元上设置输入/输出格式。
我想要的格式是这样的:
AudioStreamBasicDescription audio_format ;
audio_format.mSampleRate = 8000.0 ;
audio_format.mBitsPerChannel = 16 ;
audio_format.mChannelsPerFrame = 1 ;
audio_format.mBytesPerFrame = (audio_format.mBitsPerChannel >> 3) * audio_format.mChannelsPerFrame ;
audio_format.mFramesPerPacket = 1 ;
audio_format.mBytesPerPacket = audio_format.mBytesPerFrame * audio_format.mFramesPerPacket ;
audio_format.mFormatID = kAudioFormatLlinearPCM ;
audio_format.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked ;
我可以在 vpio 的(输入总线/输出范围)上设置这种格式,但我不能在 vpio 的(输出总线/输入范围)上设置它
我会得到错误代码(kAudioUnitErr_FormatNotSupported)。
但是当我改用AUHAL unit 时,我可以同时设置格式
在 AUHAL(输入总线/输出范围)和 AUHAL(输出总线/输入范围)上。
我想知道这两个单元之间的区别是什么?
经过一番尝试,我终于在vpio的(输出总线/输入范围)上找到了一种可用的格式,就像这样:
AudioStreamBasicDescription audio_format ;
audio_format.mSampleRate = 8000.0 ;
audio_format.mBitsPerChannel = 32 ;
audio_format.mChannelsPerFrame = 1 ;
audio_format.mBytesPerFrame = (audio_format.mBitsPerChannel >> 3) * audio_format.mChannelsPerFrame ;
audio_format.mFramesPerPacket = 1 ;
audio_format.mBytesPerPacket = audio_format.mBytesPerFrame * audio_format.mFramesPerPacket ;
audio_format.mFormatID = kAudioFormatLlinearPCM ;
audio_format.mFormatFlags = kLinearPCMFormatFlagIsFloat | kLinearPCMFormatFlagIsPacked ;
但让我感到困惑的是 vpio 的(输入总线/输出范围)和(输出总线/输入范围)上的格式不匹配。我想知道如何获得the available formats information of the vpio unit?我在 Apple 网站上找不到任何有关可用格式的文档。
有人可以回答我的问题吗?
感谢和尊重。
【问题讨论】:
标签: macos core-audio audiounit