CAFAudioDescription
的mSampleRate
成員是Float64
類型,但爲其賦值類似44100.0,我需要先將其轉換爲big-endian。函數CFConvertFloat64HostToSwapped
返回CFSwappedFloat64
這是一個uint64_t
,而不是Float64
。CAFAudioDescription成員類型和字節順序
爲什麼它返回一個int類型?我甚至不能把它當作Float64
。
// required file header
CAFFileHeader fileHeader;
fileHeader.mFileType = CFSwapInt32HostToBig('caff');
fileHeader.mFileVersion = CFSwapInt16HostToBig(1);
fileHeader.mFileFlags = CFSwapInt16HostToBig(0);
// required chunk header for audio description chunk below
CAFChunkHeader audioHeader;
audioHeader.mChunkType = CFSwapInt32HostToBig('desc');
audioHeader.mChunkSize = sizeof(CAFAudioDescription);
// required first chunk
CAFAudioDescription audioChunk;
audioChunk.mSampleRate = CFConvertFloat64HostToSwapped(44100.0); // type mismatch
謝謝。任何線索,我將如何分配uint64_t到Float64沒有編譯錯誤? – Morrowless