1
我試圖在iOS的核心音頻中部分文件緩衝區,爲了做到這一點,我需要更改開始我傳遞給memcpy的地址。我的代碼看起來像這樣...無法初始化類型爲'void *'的類型爲'void * const *'的變量
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 * const *'
在「* srcStart」的行上。
這條語句中的方括號是什麼NSData * subRange = [self ... mean? –
這是一個Objective-C消息發送表達式,@Vlad。大部分''也是。 –
你爲什麼要在該行上的'inBuffer'上輸入地址? –