V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
iOS 开发实用技术导航
NSHipster 中文版
http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
http://www.cocos2d-iphone.org/
CocoaPods
http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
http://code.google.com/mobile/analytics/
WWDC
https://developer.apple.com/wwdc/
Design Guides and Resources
https://developer.apple.com/design/
Transcripts of WWDC sessions
http://asciiwwdc.com
Cocoa with Love
http://cocoawithlove.com/
Cocoa Dev Central
http://cocoadevcentral.com/
NSHipster
http://nshipster.com/
Style Guides
Google Objective-C Style Guide
NYTimes Objective-C Style Guide
Useful Tools and Services
Charles Web Debugging Proxy
Smore
laobaozi
V2EX  ›  iDev

求助: AudioQueue 播放 pcm 流,缓冲区(AudioQueueBufferRef)小于某个值时播放没有声音

  •  
  •   laobaozi · 2019-01-13 14:38:23 +08:00 · 4167 次点击
    这是一个创建于 1901 天前的主题,其中的信息可能已经有所发展或是发生改变。

    相关代码如下

    //缓冲区个数
    const static NSUInteger kQueueBufferNumber = 3;
    
    //配置 AudioStreamBasicDescription
    _audioDescription.mBytesPerFrame = 2;  //每一个帧包含 2 字节
    _audioDescription.mFramesPerPacket = 1;//每一个 packet 一帧数据
    _audioDescription.mBytesPerPacket = 2; //每一个 packet 包含 2 个字节的数据
    
    
    //计算每个缓冲区大小,只有大于 2^15 时播放才有声音
    _everyBufferSize = (NSUInteger) pow(_audioDescription.mBytesPerPacket, 15);
    
    for (int i = 0; i < kQueueBufferNumber; i++) {
        OSStatus allocResult = AudioQueueAllocateBuffer(_audioQueue, _everyBufferSize, &_audioQueueBuffers[i]);
        if (allocResult != noErr) {
            NSLog(@"SSTAudioQueuePlayer AudioQueueAllocateBuffer 失败");
            return nil;
        }
    }
    
    
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1024 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 19:21 · PVG 03:21 · LAX 12:21 · JFK 15:21
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.