[wdmaudiodev] Re: AERT_Allocate "size" parameter & how to use AERT_x with std::vector

  • From: Martin Ordell Sørensen <odl@xxxxxxxxxxx>
  • To: "wdmaudiodev@xxxxxxxxxxxxx" <wdmaudiodev@xxxxxxxxxxxxx>
  • Date: Wed, 24 Oct 2018 10:03:10 +0000

Hi,

I have assumed that the size parameter is the size of the allocated buffer in 
bytes just like if you were calling malloc() but you are right that the 
documentation is not very clear on that.

I have experienced some undocumented limitations with AERT_ALLOCATE() though 
which you might find useful. If I specify size>32767 it will fail and return an 
error code. You can call it multiple times with size=32767 to create multiple 
buffers successfully however there is no guarantee that they are allocated 
back-to-back, so I have yet to find a good solution/workaround for this for 
situations where you would prefer a large contiguous buffers, e.g. delay 
buffers.

On earlier Windows versions it would eventually fail if you called 
AERT_ALLOCATE() many times (way before any system free memory limit), however I 
have not been able to reproduce this on newer Windows 10 versions. On Win8 and 
early Win10 builds, it would fail after allocating a total of between 5-10M 
(which is not unreasonable in case of needing long buffers/delay lines running 
at 192kHz sample rate and with 8+ channels) but I recently tried this again and 
had no problems allocating a total of 100M (still only 32K buffers) so this 
seems to have been improved.

Regarding your question regarding std::vector, I am not sure it is possible 
since it uses the new operator to allocate memory and I do not think this can 
be overridden. You do not need/want the array size to change during runtime 
anyway so I find it just as easy to just use plain C style arrays.

Best regards, Martin

From: wdmaudiodev-bounce@xxxxxxxxxxxxx <wdmaudiodev-bounce@xxxxxxxxxxxxx> On 
Behalf Of Culann mac Cabe
Sent: 24. oktober 2018 11:10
To: wdmaudiodev@xxxxxxxxxxxxx
Subject: [wdmaudiodev] AERT_Allocate "size" parameter & how to use AERT_x with 
std::vector

Hello wdmaudiodev people.

I am developing an APO and am doing some cleaning up work, including 
implementing  AERT_Allocate for all my memory allocation.  I have a compound 
question:

  1.  The doc 
https://docs.microsoft.com/en-us/windows/desktop/api/baseaudioprocessingobject/nf-baseaudioprocessingobject-aert_allocate
 defines the "size" parameter as " The number of input connections."  Is this 
correct?  It seems to me to be incomplete, as in without other info (eg audio 
sample data format) this can't evaluate to a byte size... so can someone please 
clarify what this paremeter should really mean?  (I'm guessing Bytes?)
  2.  I am currently using std:vector and std:queue for convenience to manage 
IO buffering.  Now that I am converting everything to use AERT_Allocate, can 
someone please provide guidance/code snippet as to how I can use AERT_Allocate 
in conjunction with eg std::vector - or do I have to revert to pure C arrays in 
this case?
Thanks!
Culann

Other related posts: