Objective c 无法初始化类型为';void*';具有类型为';void*const*';

Objective c 无法初始化类型为';void*';具有类型为';void*const*';,objective-c,c,core-audio,pointer-arithmetic,Objective C,C,Core Audio,Pointer Arithmetic,我正在尝试在iOS核心音频中部分归档一个缓冲区,为此,我需要更改传递给memcpy的起始地址。我的代码看起来像这样 UInt32 bytesToRead = inBuffer->mAudioDataBytesCapacity; int srcOffset = 0; while (bytesToRead > 0) { UInt32 maxBytesFromCurrentPiece = self.currentAudioPiece.audioData.length - self.

我正在尝试在iOS核心音频中部分归档一个缓冲区,为此,我需要更改传递给memcpy的起始地址。我的代码看起来像这样

UInt32 bytesToRead = inBuffer->mAudioDataBytesCapacity;
int srcOffset = 0;
while (bytesToRead > 0) {
    UInt32 maxBytesFromCurrentPiece = self.currentAudioPiece.audioData.length - self.currentAudioPieceIndex;
    //Take the min of what the current piece can provide OR what is needed to be read
    UInt32 bytesToReadNow = MIN(maxBytesFromCurrentPiece, bytesToRead);

    NSData *subRange = [self.currentAudioPiece.audioData subdataWithRange:NSMakeRange(self.currentAudioPieceIndex, bytesToReadNow)];
    //Copy what you can before continuing loop

    void *srcStart = (&inBuffer->mAudioData + srcOffset);
    memcpy(srcStart, subRange.bytes, subRange.length);
    srcOffset += subRange.length;
    bytesToRead -= bytesToReadNow;
Appcode未显示错误,但编译器显示:

“语义问题”-无法使用初始化“void*”类型的变量 类型为“void*const*”的右值

在带有“*srcStart”的行上尝试更改

void *srcStart = (&inBuffer->mAudioData + srcOffset);


这将跳过适当的字节数。

此语句中的方括号NSData*子范围=[self…mean?这是一个Objective-C消息发送表达式,@Vlad。大多数
也是。你为什么要在那一行的
inBuffer
上取地址?如何定义
inBuffer
inBuffer->mAudioData
呢?如果后者是数组,则取地址是有意义的,但如果它是指针,则不取地址
char *srcStart = ((char *)inBuffer->mAudioData) + srcOffset;