Soloud + OpenSLES 后端,非活动音轨

Posted

技术标签:

【中文标题】Soloud + OpenSLES 后端,非活动音轨【英文标题】:Soloud + OpenSLES backend, inactive audio track 【发布时间】:2018-12-26 00:12:16 【问题描述】:

我将 soloud 用作音频库,并带有用于播放的 opensles 后端。一切似乎都运行良好,但只有 9/10 次。在那些半罕见的情况下,启动似乎很正常,但应用程序没有音频。尝试更改活动应用程序的音量会调高铃声音量(而不是媒体音量)。 “Fliger”输出为我的应用显示了这一点:

工作:

Output thread 0xf2540000 type 0 (MIXER):
Thread name: AudioOut_6
I/O handle: 6
TID: 31533
Standby: no
Sample rate: 48000 Hz
HAL frame count: 960
HAL format: 0x1 (pcm16)
HAL buffer size: 3840 bytes
Channel count: 2
Channel mask: 0x00000003 (front-left, front-right)
Format: 0x1 (pcm16)
Frame size: 4 bytes
Pending config events: none
Output device: 0x3 (EARPIECE|SPEAKER)
Input device: 0 (NONE)
Audio source: 0 (default)
Normal frame count: 960
Last write occurred (msecs): 7
Total writes: 858683
Delayed writes: 0
Blocked in write: yes
Suspend count: 0
Sink buffer : 0xf59e4000
Mixer buffer: 0xf27f6000
Effect buffer: 0xf27e4000
Fast track availMask=0xfe
AudiostreamOut: 0xf5982e70 flags 0x2 (PRIMARY)
Thread throttle time (msecs): 12438
AudioMixer tracks: 0x0000000b
FastMixer not initialized
Stream volumes in dB: 0:-24, 1:-19, 2:-22, 3:-22, 4:-22, 5:-22, 6:0, 7:-6, 8:-19, 9:-96, 10:-22, 11:0, 12:0
Normal mixer raw underrun counters: partial=0 empty=0
3 Tracks of which 1 are active
Name Active Client Type      Fmt Chn mask Session fCount S F SRate  L dB  R dB    Server Main buf  Aux Buf Flags UndFrmCnt
0     no  31508    1 00000001 00000003    2643  24000 S 1 48000     0     0  00008BAB 0xf59e4000 0x0 0x601       725
1     no   1480    1 00000001 00000003    2801  10081 S 1 44100  -inf  -inf  00002761 0xf59e4000 0x0 0x600         0
3    yes    903    3 00000001 00000003    2824   1924 A 3 48000     0     0  00032A00 0xf59e4000 0x0 0x000         0
0 Effect Chains

破碎:

Output thread 0xf2540000 type 0 (MIXER):
Thread name: AudioOut_6
I/O handle: 6
TID: 31533
Standby: yes
Sample rate: 48000 Hz
HAL frame count: 960
HAL format: 0x1 (pcm16)
HAL buffer size: 3840 bytes
Channel count: 2
Channel mask: 0x00000003 (front-left, front-right)
Format: 0x1 (pcm16)
Frame size: 4 bytes
Pending config events: none
Output device: 0x3 (EARPIECE|SPEAKER)
Input device: 0 (NONE)
Audio source: 0 (default)
Normal frame count: 960
Last write occurred (msecs): 141220
Total writes: 858467
Delayed writes: 0
Blocked in write: no
Suspend count: 0
Sink buffer : 0xf59e4000
Mixer buffer: 0xf27f6000
Effect buffer: 0xf27e4000
Fast track availMask=0xfe
AudioStreamOut: 0xf5982e70 flags 0x2 (PRIMARY)
Thread throttle time (msecs): 12428
AudioMixer tracks: 0x0000000b
FastMixer not initialized
Stream volumes in dB: 0:-4.7, 1:-19, 2:-22, 3:-22, 4:-22, 5:-22, 6:0, 7:-6, 8:-19, 9:-96, 10:-22, 11:0, 12:0
Normal mixer raw underrun counters: partial=0 empty=0
3 Tracks of which 0 are active
Name Active Client Type      Fmt Chn mask Session fCount S F SRate  L dB  R dB    Server Main buf  Aux Buf Flags UndFrmCnt
0     no  31508    1 00000001 00000003    2643  24000 S 1 48000     0     0  00008BAB 0xf59e4000 0x0 0x601       725
1     no   1480    1 00000001 00000003    2801  10081 S 1 44100  -inf  -inf  00002761 0xf59e4000 0x0 0x600         0
3     no    748    3 00000001 00000003    2813   1924 S 1 48000     0     0  00000B40 0xf59e4000 0x0 0x600      2886
0 Effect Chains

我尝试过使用缓冲区大小(遵循 android 低延迟指南),但没有效果。

我知道这很难,但有人知道要看什么吗?

【问题讨论】:

【参考方案1】:

嗯,我发现了问题:) 线程启动很慢,在线程池启动之前触发了 sles 回调。

【讨论】:

以上是关于Soloud + OpenSLES 后端,非活动音轨的主要内容,如果未能解决你的问题,请参考以下文章

后端开发分析抖音后台架构

Facebook - 错误代码 - 2500 非活动访问令牌

字节跳动内推-杭州-后端开发(高级)工程师-电商运营赋能

Android音乐播放器-使用FFmpeg及OpenSLES

Android音乐播放器-使用FFmpeg及OpenSLES

抖音秒杀会出现超售吗?