SampleBuffer reuse #219
GeoffClements
started this conversation in
General
Replies: 2 comments
-
Nope, there is no deeper reason. It's just a suggestion to avoid the overhead of the extra allocation. :) |
Beta Was this translation helpful? Give feedback.
0 replies
-
That's great to know, thank-you. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am wondering why there is this recommendation in GETTING_STARTED.md:
A SampleBuffer should be reused for the life of the decoder.
Is the recommendation simply because it avoids new allocations or is there a deeper reason?
I ask because in my current code which seems to work ok ,I have the the format read and decode taking place inside a pulseaudio mainloop callback. Because creation of the SampleBuffer needs parameters from the decoded frame then the creation of the SampleBuffer happens in the callback as well and so is transient between call-backs.
There are ways to overcome this such as decoding the first frame outside of the call-back and then inside the call-back checking for the existence of this first frame but is this added complication really necessary just to comply with the recommendation?
Beta Was this translation helpful? Give feedback.
All reactions