I have data in the ShortBuffer
variable.
I want to push_back
in the std::vector<short>
input
variable. I have used the following code, but because of the long for loop the apps freeze.
Is there another way to do it?
ShortBuffer *pBuffer1 = pData->AsShortBufferN();
std::vector<short> input(BUFFER_SIZE);
for (int i = 0; i < BUFFER_SIZE-1; ++i) {
short out1;
pBuffer1->Get(out1);
input.push_back(out1);
}
If ShortBuffer
is what I think it is , this should work:
// Allocate enough space to avoid push_back
std::vector<short> input(BUFFER_SIZE, 0);
// Let the GetArray method do the copying
pBuffer1->GetArray(&input[0], 0, BUFFER_SIZE);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.