status _af_wave_update (AFfilehandle file) { _Track *track; track = _af_filehandle_get_track(file, AF_DEFAULT_TRACK); if (track->fpos_first_frame != 0) { size_t dataLength, fileLength; /* We call _af_format_frame_size to calculate the frame size of normal PCM data or compressed data. */ dataLength = track->totalfframes * _af_format_frame_size(&track->f, AF_FALSE); dataLength = HOST_TO_LENDIAN_INT32(dataLength); af_fseek(file->fh, track->fpos_first_frame - 4, SEEK_SET); af_fwrite(&dataLength, 4, 1, file->fh); fileLength = 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); } return AF_SUCCEED; }
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; }