jjzjj

Android NDK、OpenSL ES - 知道缓冲区何时被填满

coder 2023-12-29 原文

如果我将一个用于记录的缓冲区排入缓冲区队列 - 是否有办法知道该缓冲区何时实际已满,以便我可以使用它?

同样,有没有办法知道缓冲区何时播放?

对于上下文: 我正在修改名为“native-audio”的 NDK 示例。 它使用 SLAndroidSimpleBufferQueueItf 进行播放,并评论说,对于我想做的流记录,也应该使用这样的队列。 现在我想知道,因为根据我记得在某处读到的内容,不能保证在下一次调用录音回调时缓冲区已经被填充(或者在播放回调中播放,就此而言) - 人们怎么知道什么时候缓冲区已被使用? 肯定有办法,否则这一切就有点没用了? ^^

最佳答案

对于记录,如果您使用 IBufferQueue_RegisterCallback 注册一个 slBufferQueueCallback,您应该在缓冲区已填满时获得回调。

另见 this discussion在 android-ndk 列表中:

If I understand well, the recorder will call back each time a buffer in the queue is filled in, and these buffers are filled in in the order that they are enqueued. But the callback does not seem to expose a pointer to the corresponding filled buffer. So what would be the way to retreive this? A sample code in the OpenSL ES specs shows an example for playback with a struct passed in as context of the callback to keep track of these, is that the way to do?
...
Right. This is a known deficiency in the OpenSL ES 1.0.1 spec. OpenSL ES 1.1 adds an explicit parameter to identify the buffer, but Android is currently based on the 1.0.1 spec. A workaround is to maintain an index yourself to indicate which buffer is being completed.

关于Android NDK、OpenSL ES - 知道缓冲区何时被填满,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13955397/

有关Android NDK、OpenSL ES - 知道缓冲区何时被填满的更多相关文章

  1. ruby-on-rails - Sphinx - 何时对字段使用 'has' 和 'indexes' - 2

    我几天前在我的ruby​​onrails2.3.2上安装了Sphinx和Thinking-Sphinx,基本搜索效果很好。这意味着,没有任何条件。现在,我想用一些条件过滤搜索。我有公告模型,索引如下所示:define_indexdoindexestitle,:as=>:title,:sortable=>trueindexesdescription,:as=>:description,:sortable=>trueend也许我错了,但我注意到只有当我将:sortable=>true语法添加到这些属性时,我才能将它们用作搜索条件。否则它找不到任何东西。现在,我还在使用acts_as_tag

  2. ruby - EventMachine - 你怎么知道你是否落后了? - 2

    我正在研究使用EventMachine支持的twitter-streamruby​​gem来跟踪和捕获推文。我对整个事件编程有点陌生。我如何判断我在事件循环中所做的任何处理是否导致我落后?有没有简单的检查方法? 最佳答案 您可以通过使用周期性计时器并打印出耗时来确定延迟。如果您使用的是1秒的计时器,您应该已经过了大约1秒,如果它更长,您就知道您正在减慢react器的速度。@last=Time.now.to_fEM.add_periodic_timer(1)doputs"LATENCY:#{Time.now.to_f-@last}"@

  3. ruby-on-rails - Ruby 如何知道在哪里可以找到所需的文件? - 2

    这里还有一个新手问题:require'tasks/rails'我在每个Rails项目的根路径中的Rakefile中看到了这一行。我猜这行用于要求vendor/rails/railties/lib/tasks/rails.rb加载所有rake任务:$VERBOSE=nil#LoadRailsrakefileextensionsDir["#{File.dirname(__FILE__)}/*.rake"].each{|ext|loadext}#LoadanycustomrakefileextensionsDir["#{RAILS_ROOT}/lib/tasks/**/*.rake"].so

  4. ruby - 如何知道通过 ruby​​ 上传 ftp 是否成功? - 2

    下面的代码通过ftp上传文件并且它有效。require'net/ftp'ftp=Net::FTP.newftp.passive=trueftp.connect("***")ftp.login("***","***")ftp.chdir"claimsecure-xml-files"ftp.putbinaryfile("file.xls",File.basename("file.xls"))ftp.quit但是如何确定上传是否成功呢? 最佳答案 之后ftp.putbinaryfile("file.xls",File.basename("

  5. Unity 血条及“掉血”缓冲效果 - 2

     视频教程:https://www.bilibili.com/video/BV1WJ411778C/?spm_id_from=333.999.0.0&vd_source=4a4c35da6aef7094d5990c213c39aa09使用素材(推荐使用GitZipforgithub下载):https://github.com/zheyuanzhou/Youtube-Unity-Tutorial/tree/master/EP45_Health%20Bar/Sprites效果如下图所示:首先在场景中创建一个新的Canvas,并命名为HeathBar,并创建三个Image作为前者的子物体,分别命名为

  6. ruby - 何时使用隐式或显式代码块 - 2

    我试图理解什么时候应该隐式或显式地编写代码块。给定以下代码块:隐式deftwo_times_implicitreturn"Noblock"unlessblock_given?yieldyieldendputstwo_times_implicit{print"Hello"}putstwo_times_implicit明确deftwo_times_explicit(&i_am_a_block)return"Noblock"ifi_am_a_block.nil?i_am_a_block.calli_am_a_block.callendputstwo_times_explicit{puts"H

  7. ruby-on-rails - 何时使用关联扩展与命名范围? - 2

    粗略地看一下,它们似乎只是解决同一组问题的两种不同方法,除了命名作用域是可链接的,而关联扩展不是。谁能进一步解释或提供一个比命名范围更适合关联扩展的示例? 最佳答案 关联扩展对于创建用于创建、更新等(不一定是查找)的自定义方法非常有用。因为您可以访问proxy_owner、proxy_reflection、proxy_target,所以您可以很好地了解这种关系。查看Rails文档的关联扩展部分:http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMeth

  8. ruby - 任何人都知道字符串开头的 "weird"字符是怎么回事? - 2

    我在尝试从它们的数组中检测某个字符串时遇到了一个奇怪的问题。有人知道这里发生了什么吗?(rdb:1)pmagic_string"TimePeriod"(rdb:1)pmagic_string.classString(rdb:1)pmagic_string=="TimePeriod"false(rdb:1)p"TimePeriod".length11(rdb:1)pmagic_string.length14(rdb:1)pmagic_string[0].chr"\357"(rdb:1)pmagic_string[1].chr"\273"(rdb:1)pmagic_string[2].c

  9. ruby - 有没有办法知道调用方法? - 2

    我知道类方法告诉对象类的名称是什么,我怎么知道调用方法的名称?有办法知道吗? 最佳答案 ExaminingtheRubyCallStack共享此信息:您有没有想过在不引发异常的情况下查看调用堆栈?caller.each{|c|putsc} 关于ruby-有没有办法知道调用方法?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/1859979/

  10. ruby:如何知道脚本是否在第 3 次重试? - 2

    begin#someroutinerescueretry#onthirdretry,output"nodice!"end我想让它在“第三次”重试时打印一条消息。 最佳答案 可能不是最好的解决方案,但一个简单的方法就是制作一个tries变量。tries=0begin#someroutinerescuetries+=1retryiftries 关于ruby:如何知道脚本是否在第3次重试?,我们在StackOverflow上找到一个类似的问题: https://st

随机推荐