CAFAudioDescription
的mSampleRate
成员是一种Float64
类型,但是要为其分配一个像 44100.0 这样的值,我需要先将其转换为大端。该函数CFConvertFloat64HostToSwapped
返回 a CFSwappedFloat64
,它是 a uint64_t
,而不是Float64
。
为什么它返回一个 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