我在ShortBuffer
变量中有数据。
我想在push_back
std::vector<short>
变量中input
。我使用了以下代码,但由于for循环很长,应用程序会冻结。
还有其他办法吗?
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);
}
答案 0 :(得分:1)
如果ShortBuffer
为what I think it is,则应该有效:
// 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);