Frames left in buffer after stopping playback #452
Replies: 6 comments 1 reply
-
It'll be because the backend hasn't yet processed the data from the last data callback. When the device is resumed, that leftover data is pushed through to the speakers. That said, the ALSA backend is support to drop any pending audio so I'm not entirely sure what's going on there. Is it possible to try the PulseAudio backend to see if you're getting the same results? |
Beta Was this translation helpful? Give feedback.
-
Thank you for the quick response! I just did a test using PulseAudio, so using these flags:
But unfortunately I got the exact same result. |
Beta Was this translation helpful? Give feedback.
-
@mackron First of all I noticed that even though I use the So then I had a look at the In the
So naturally I tried adding a call to But unfortunately I really need to use ALSA for my embedded application. So I'm still digging for a way to fix this. If you have an idea about what could go wrong or where I could look, please let me know! Also, is there any internal buffer that is made and maintained by miniaudio itself that might be causing the problem? Kind regards! |
Beta Was this translation helpful? Give feedback.
-
@mackron I tried enabling
But when running the program, no miniaudio logs show (the only things you see are the commands I type in): Could I be that just nothing goes wrong, so no logs show? |
Beta Was this translation helpful? Give feedback.
-
Well the comment there in Regarding the printing problem, it's probably due to miniaudio not detecting the presence of |
Beta Was this translation helpful? Give feedback.
-
@mackron thank you for the answer. When using ALSA there are also still some samples audible, which is very strange since you correctly call the I am currently solving the problem by re-initializing the |
Beta Was this translation helpful? Give feedback.
-
Hi, back with another question.
In my application I've built a simple audio-player class which is supposed to play, pause and stop files. I've noticed something strange however. If I call my method
AudioPlayer::playFile("file1")
"file1" will start playing, then I call theAudioPlayer::unInit()
which will essentially stop thema_device
and uninit the data source in thema_resource_manager
. Finally I callAudioPlayer::playFile("file2")
again in order to start playing "file2". But just before "file2" starts playing, some samples of "file1" are audible.Furthermore I noticed that the
deviceConfig.periodSizeInMilliseconds
-attribute has an influence on how many samples of the previous file are still audible. So it seems to me that when the device is stopped, there are still some frames left in some kind of buffer.I was thinking about using a
onStopCallback
which could then clear the buffer when a file is stopped. But I have no idea which buffer to clear of what function to call.Thanks you advance for the help!
I'm testing the application on Ubuntu 20.04.4 using ALSA as the back-end.
Here is my code:
Beta Was this translation helpful? Give feedback.
All reactions