【发布时间】:2014-09-05 15:27:05
【问题描述】:
我已经尝试 OpenSL 几个星期了。我试图通过 SL_DATALOCATOR_URI 作为源在 sdcard 上播放文件时访问缓冲区。我想自己写几个效果,需要缓冲。
目前在代码中,我正在创建两个音频播放器。一种是将文件读取到缓冲区,另一种是将缓冲区写入输出。当我用麦克风(录音机)测试代码时,一切都很好。声音输入输出按预期工作。
当我用 uri 音频播放器切换录音机时,队列变得混乱。流不监听线程锁(据我了解,它发生异步)并且缓冲区调用未正确触发,时间飞逝。
我已经为每个方法添加了日志,所以结果看起来像这样:
V/PDecoder( 1292): Position : 15023
V/PDecoder( 1292): Position : 16044
V/PDecoder( 1292): Position : 17043
V/PDecoder Native PL1( 1292): bqPlayerCallback
V/PDecoder Native PL1( 1292): Notify thread lock
V/PDecoder Native PL1( 1292): android_AudioIn 32768
V/PDecoder Native PL1( 1292): Wait thread lock
V/PDecoder Native PL1( 1292): android_AudioOut 32768
V/PDecoder Native PL1( 1292): android_AudioIn 32768
V/PDecoder Native PL1( 1292): android_AudioOut 32768
V/PDecoder Native PL1( 1292): Wait thread lock
V/PDecoder Native PL1( 1292): bqRecorderCallback
V/PDecoder Native PL1( 1292): Notify thread lock
V/PDecoder( 1708): Position : 18041
V/PDecoder( 1708): Position : 19040
V/PDecoder( 1708): Position : 20038
甚至在队列回调被触发之前几秒钟就飞走了。
所以问题是,我该如何解决这个问题?有没有办法让音频播放器 > 缓冲区 > uri 播放的输出解决方案?我究竟做错了什么?如果有人能指出我正确的方向,不胜感激。
代码有点长,这里贴一下,这里是要点
【问题讨论】:
标签: android audio android-ndk java-native-interface opensl