/** * Updates the marker chunk. * * Note: The file must have been opened read / write and the maker chunk * must be the last chunk in the BWF file. * * @throws IOException * @throws RcBwfException */ public void updateMarkerChunk() throws IOException, RcBwfException { if (!this.canUpdateMarkerChunk()) { throw new IOException("The marker chunk is not updatable."); } // Overwrite marker chunk long sizeBefore = this.rcRiffMarkerChunk.getChunkSize(); this.in.seek(this.rcRiffMarkerChunk.getPtr()); this.rcRiffMarkerChunk.write(in); long sizeAfter = this.rcRiffMarkerChunk.getChunkSize(); long sizeDiff = sizeAfter - sizeBefore; this.rcRiffHeaderChunk.setChunkSize(this.rcRiffHeaderChunk.getChunkSize() + sizeDiff); // Update header this.in.seek(4); RcRiffFile.writeUnsignedInt(in, this.rcRiffHeaderChunk.getChunkSize()); // Trim file length if necessary if (sizeDiff < 0) { long length = this.in.length(); this.in.setLength(length + sizeDiff); } }