flutter_soloud
flutter_soloud copied to clipboard
fix: A constant stream of messages in console
Description
I replaced in my App "audioplayers" with SoLoud and it works realy great. But on Android there is a permanent Stream of Messages in the console and the performance is bad so i think i did something wromg or there is a problem. The message is
V/AudioTrack(28092): processAudioBuffer(5684): obtainBuffer(30) returned 882 = 30 + 852 err 0
V/AudioTrack(28092): processAudioBuffer(5684): obtainBuffer(882) returned 852 = 852 + 0 err 0
V/AudioTrack(28092): processAudioBuffer(5684): obtainBuffer(882) returned 852 = 852 + 0 err 0
V/AudioTrack(28092): processAudioBuffer(5684): obtainBuffer(30) returned 0 = 0 + 0 err -11
Steps To Reproduce
- add SoLoud to my Project
- Init in main
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await SoLoud().startIsolate().then((PlayerErrors value) {
if (value != PlayerErrors.noError) {
return;
}
});
[...]
- See Massage in console.
Expected Behavior
Expect no messages
Screenshots
Additional Context
Developing under Linux for Android.
To clarify: The Problem does NOT appear on Linux, only on Android
Hi, that log comes from the OS not from the plugin. I guess the device is not fast enough to read or decode the file to fill the audio buffer when it needs samples to output. For this reason, you may notice audio glitches.
- On which device are you noticing this problem and which Android version does it have?
- I tried (the example audio samples) on a bunch of devices without seeing that log. Can you provide me the audio you used?
- Does it happen also when running the plugin example?
- Does it happens also by pressing a note for a long time in the waveform tab in the example? (There, is not used an audio file but the wave data is generated)
Thanks for reporting this, hope we will resolve it!
Thanks for your answer.
- its a Xiaomi Redmi note 7 with Android 10 QKQ1.190910.002
- Thats the curios part. The error occurs immidiatly after the init. I have not loaded any audio.file at this time. The init does not get any error.
- I have not tested this yet. Sorry. 4.) Not tested this either, but i think it is not relevant because the output is there without giving it a audio-output at all.
Thank you very much for anserwing so quick. I hope we find the problem :)
There is an unaswered Question on stackoverflow... https://stackoverflow.com/questions/63910496/many-times-in-the-log-i-get-the-same-error-processaudiobuffer34-obtainbuffe
I found that too! :) I read this also which is, more or less, old as the other one.
I am trying on some devices but with no luck seeing that log!
Maybe worth trying to call SoLoud().startIsolate()
somewhere else in the code, ie when you need to play a file and see if that happens. Because I am trying now on a Xiaomi Redmi Note 8 Pro and I see:
I/AudioTrack(27834): isLongTimeZeroData zero date time 2 Seconds
I mean, don't start isolate before the runApp
in main
I just checked on a samsung galaxy s8 running android 9 and the problem does not appear. Thanks for the hint, i will try this.
Changing the position in the code where it is called is not relevant. It happens everytime the init is called.
I tried on these devices without seeing the problem: Xiaomi Mi 6 Xiaomi Mi Max 3 Xiaomi Note 8 Pro Samsung Galaxy s9 Samsung Galaxy Note S10 and S20 Huawei P smart Z
I leave this issue open, maybe we will find something, or maybe someone else can help!
I posted this question on the mini audio discord. I got this reply:
Not sure what's going on there. Never seen that error before. Do you know what backend SoLoud is using? If it's using it's stock OpenSL backend, do you know if it's possible to switch to SoLoud's miniaudio backend instead?
I don't have the most experience with Android, but just from bug reports I hear through miniaudio it seems like Android is very inconsistent. You'll just get random errors on random hardware across different versions of Android. It's very annoying.
Can you answer the questions? Thanks
This plugin uses Soloud with miniaudio enabled on all platforms with this C code
SoLoud::result result = soloud.init(
SoLoud::Soloud::CLIP_ROUNDOFF,
SoLoud::Soloud::MINIAUDIO, 44100, 2048, 2U);
If I remember well, miniaudio makes use of OpenSL on Android < 8 and AAudio on Android >= 8 where AAudio was introduced.
The only thing I could think for now, is that the loop in the audio_isolate can cause a CPU overload. Could you please try to raise the Duration from 10 to maybe 50 or 100, or maybe comment all the Future.delayed in audio_isolate.dart? And then try to play a sound
Changing the delay does not change the consoleoutput.