|
1 | | -# Audio-Echo |
| 1 | +# Sample removed |
2 | 2 |
|
3 | | -The sample demos how to use OpenSL ES to create a player and recorder in Android |
4 | | -Fast Audio Path, and connect them to loopback audio. On most android devices, |
5 | | -there is a optimized audio path that is tuned up for low latency purpose. The |
6 | | -sample creates player/recorder to work in this highly optimized audio |
7 | | -path(sometimes called native audio path, |
8 | | -[low latency path](http://stackoverflow.com/questions/14842803/low-latency-audio-playback-on-android?rq=1), |
9 | | -or fast audio path). |
| 3 | +This sample has been removed because the API it demonstrated (OpenSLES) is |
| 4 | +deprecated. New apps should instead use [Oboe], which has its own samples. |
10 | 5 |
|
11 | | -***Note that OpenSL ES is |
12 | | -[deprecated from Android 11](https://developer.android.com/preview/features#deprecate-opensl), |
13 | | -developers are recommended to use [Oboe](https://github.com/google/oboe) library |
14 | | -instead.*** |
15 | | - |
16 | | -## Usage |
17 | | - |
18 | | -App will capture audio from android devices and playback on the same device; the |
19 | | -playback on speaker will be captured immediately and played back...! So to |
20 | | -verify it, it is recommended to "mute" the playback audio with a |
21 | | -earspeaker/earphone/earbug so it does not get looped back. Some device like |
22 | | -Nexus 9, once you plug in an external headphone/headspeaker, it stops to use |
23 | | -onboard microphone AND speaker anymore -- in this case, you need turn on the |
24 | | -microphone coming with your headphone. Another point, when switching between |
25 | | -external headphone and internal one, the volume is sometimes very low/muted; |
26 | | -recommend to increase the playback volume with volume buttons on the phone/pad |
27 | | -after plugging external headphone. |
28 | | - |
29 | | -## Low Latency Verification |
30 | | - |
31 | | -1. execute "adb shell dumpsys media.audio_flinger". Find a list of the running |
32 | | - processes |
33 | | - |
34 | | - Name Active Client Type Fmt Chn mask Session fCount S F SRate L dB R dB |
35 | | - Server Main buf Aux Buf Flags UndFrmCnt\ |
36 | | - F 2 no 704 1 00000001 00000003 562 |
37 | | - 13248 S 1 48000 -inf -inf 000033C0 0xabab8480 0x0 0x600 0\ |
38 | | - F 6 yes 9345 3 |
39 | | - 00000001 00000001 576 128 A 1 48000 0 0 0376AA00 0xabab8480 0x0 0x400 256 |
40 | | - |
41 | | -1. execute adb shell ps | grep echo |
42 | | - |
43 | | -- find the sample app pid |
44 | | -- check with result on step 1.\ |
45 | | - if there is one "F" in the front of your echo |
46 | | - pid, **player** is on fast audio path\ |
47 | | - For fast audio capture \[it is totally |
48 | | - different story\], if you do **NOT** see\ |
49 | | - com.example.nativeaudio |
50 | | - W/AudioRecord﹕ AUDIO_INPUT_FLAG_FAST denied by client\ |
51 | | - in your logcat output |
52 | | - when you are creating audio recorder, you could "assume" you are on the fast |
53 | | - path.\ |
54 | | - If your system image was built with muted ALOGW, you will not be able |
55 | | - to see the above warning message. |
56 | | - |
57 | | -## Tune-ups |
58 | | - |
59 | | -A couple of knobs in the code for lower latency purpose: |
60 | | - |
61 | | -- audio buffer size |
62 | | -- number of audio buffers cached before kicking start player The lower you go |
63 | | - with them, the lower latency you get and also the lower budget for audio |
64 | | - processing. All audio processing has to be completed in the time period they |
65 | | - are captured / played back, plus extra time needed for: |
66 | | -- audio driver |
67 | | -- audio flinger framework, |
68 | | -- bufferqueue callbacks etc Besides those, the irregularity of the buffer queue |
69 | | - player/capture callback time is another factor. The callback from openSL may |
70 | | - not as regular as you assumed, the more irregularity it is, the more likely |
71 | | - have choopy audio. To fight that, more buffering is needed, which defeats the |
72 | | - low-latency purpose! The low latency path is highly tuned up so you have |
73 | | - better chance to get more regular callbacks. You may experiment with your |
74 | | - platform to find the best parameters for lower latency and continuously |
75 | | - playback audio experience. The app capture and playback on the same device |
76 | | - \[most of times the same chip\], capture and playback clocks are assumed |
77 | | - synchronized naturally \[so we are not dealing with it\] |
| 6 | +[Oboe]: https://github.com/google/oboe |
0 commit comments