void Context::FinalSegment() { m_cues_pos = m_file.GetPosition(); //end of clusters WriteCues(); #if 0 m_second_seekhead_pos = m_file.GetPosition(); //end of cues WriteSecondSeekHead(); #else m_clusters.clear(); #endif const __int64 maxpos = m_file.GetPosition(); m_file.SetSize(maxpos); const __int64 size = maxpos - m_segment_pos - 12; assert(size >= 0); m_file.SetPosition(m_segment_pos); const ULONG id = m_file.ReadID4(); assert(id == 0x18538067); //Segment ID id; m_file.Write8UInt(size); //total size of the segment FinalFirstSeekHead(); FinalInfo(); //FinalClusters(m_cues_pos); }
status _af_wave_update (AFfilehandle file) { _Track *track; _WAVEInfo *wave = (_WAVEInfo *) file->formatSpecific; track = _af_filehandle_get_track(file, AF_DEFAULT_TRACK); if (track->fpos_first_frame != 0) { u_int32_t dataLength, fileLength; /* Update the frame count chunk if present. */ WriteFrameCount(file); /* Update the length of the data chunk. */ af_fseek(file->fh, wave->dataSizeOffset, SEEK_SET); /* We call _af_format_frame_size to calculate the frame size of normal PCM data or compressed data. */ dataLength = (u_int32_t) track->totalfframes * _af_format_frame_size(&track->f, AF_FALSE); dataLength = HOST_TO_LENDIAN_INT32(dataLength); af_fwrite(&dataLength, 4, 1, file->fh); /* Update the length of the RIFF chunk. */ fileLength = (u_int32_t) af_flength(file->fh); fileLength -= 8; fileLength = HOST_TO_LENDIAN_INT32(fileLength); af_fseek(file->fh, 4, SEEK_SET); af_fwrite(&fileLength, 4, 1, file->fh); } /* Write the actual data that was set after initializing the miscellaneous IDs. The size of the data will be unchanged. */ WriteMiscellaneous(file); /* Write the new positions; the size of the data will be unchanged. */ WriteCues(file); return AF_SUCCEED; }
status _af_wave_write_init (AFfilesetup setup, AFfilehandle filehandle) { uint32_t zero = 0; if (_af_filesetup_make_handle(setup, filehandle) == AF_FAIL) return AF_FAIL; filehandle->formatSpecific = waveinfo_new(); af_fseek(filehandle->fh, 0, SEEK_SET); af_fwrite("RIFF", 4, 1, filehandle->fh); af_fwrite(&zero, 4, 1, filehandle->fh); af_fwrite("WAVE", 4, 1, filehandle->fh); WriteMiscellaneous(filehandle); WriteCues(filehandle); WriteFormat(filehandle); WriteFrameCount(filehandle); WriteData(filehandle); return AF_SUCCEED; }