简体   繁体   English

如何在iOS中为缓冲区分配内存

[英]how do you allocate memory for a buffer in iOS

I have an AudioQueueBufferRef datatype and I want to allocate memory for the buffers but I don't want to associate it with the queue. 我有一个AudioQueueBufferRef数据类型,我想为缓冲区分配内存,但是我不想将其与队列关联。 Hence, I can't use AudioQueueAllocateBufferWithPacketDescription. 因此,我不能使用AudioQueueAllocateBufferWithPacketDescription。 What is the general way of allocating memory to any buffer? 将内存分配给任何缓冲区的一般方法是什么?

I tried malloc but it didn't work 我尝试了malloc但没有用

        for(i=0;i<numBuffers;i++){
          AudBuf[i] = (AudioQueueBufferRef)malloc(sizeof(AudioQueueBuffer));

} }

AudioQueueBuffer dummyAQB;
audioQueueBuffer = malloc(sizeof(dummyAQB)*kNumAQBufs);

看一下Apple的AudioFileStreamExample

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM