static status next_write_header (AFfilehandle file) { _Track *track; int frameSize; uint32_t offset, length, encoding, sampleRate, channelCount; track = _af_filehandle_get_track(file, AF_DEFAULT_TRACK); frameSize = _af_format_frame_size(&track->f, false); offset = track->fpos_first_frame; length = track->totalfframes * frameSize; encoding = nextencodingtype(&track->f); sampleRate = track->f.sampleRate; channelCount = track->f.channelCount; if (af_fseek(file->fh, 0, SEEK_SET) != 0) _af_error(AF_BAD_LSEEK, "bad seek"); af_fwrite(".snd", 4, 1, file->fh); af_write_uint32_be(&offset, file->fh); af_write_uint32_be(&length, file->fh); af_write_uint32_be(&encoding, file->fh); af_write_uint32_be(&sampleRate, file->fh); af_write_uint32_be(&channelCount, file->fh); return AF_SUCCEED; }
static status next_write_header (AFfilehandle file) { _Track *track; int frameSize; u_int32_t offset, length, encoding, sampleRate, channelCount; track = _af_filehandle_get_track(file, AF_DEFAULT_TRACK); frameSize = _af_format_frame_size(&track->f, AF_FALSE); if (track->f.compressionType == AF_COMPRESSION_G711_ULAW || track->f.compressionType == AF_COMPRESSION_G711_ALAW) frameSize = frameSize / 2; offset = HOST_TO_BENDIAN_INT32(track->fpos_first_frame); length = HOST_TO_BENDIAN_INT32(track->totalfframes * frameSize); encoding = HOST_TO_BENDIAN_INT32(nextencodingtype(&track->f)); sampleRate = HOST_TO_BENDIAN_INT32(track->f.sampleRate); channelCount = HOST_TO_BENDIAN_INT32(track->f.channelCount); if (af_fseek(file->fh, 0, SEEK_SET) != 0) _af_error(AF_BAD_LSEEK, "bad seek"); af_fwrite(".snd", 4, 1, file->fh); af_fwrite(&offset, 4, 1, file->fh); af_fwrite(&length, 4, 1, file->fh); af_fwrite(&encoding, 4, 1, file->fh); af_fwrite(&sampleRate, 4, 1, file->fh); af_fwrite(&channelCount, 4, 1, file->fh); return AF_SUCCEED; }
status NeXTFile::writeHeader() { Track *track = getTrack(); if (fh->seek(0, File::SeekFromBeginning) != 0) _af_error(AF_BAD_LSEEK, "bad seek"); uint32_t offset = track->fpos_first_frame; uint32_t length = track->data_size; uint32_t encoding = nextencodingtype(&track->f); uint32_t sampleRate = track->f.sampleRate; uint32_t channelCount = track->f.channelCount; fh->write(".snd", 4); writeU32(&offset); writeU32(&length); writeU32(&encoding); writeU32(&sampleRate); writeU32(&channelCount); return AF_SUCCEED; }