1 /* libFLAC - Free Lossless Audio Codec library
2 * Copyright (C) 2001,2002 Josh Coalson
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
20 #ifndef FLAC__METADATA_H
21 #define FLAC__METADATA_H
26 /******************************************************************************
27 (For an example of how all these routines are used, see the source
28 code for the unit tests in src/test_libFLAC/metadata_*.c, or metaflac
30 ******************************************************************************/
32 /** \file include/FLAC/metadata.h
35 * This module provides functions for creating and manipulating FLAC
36 * metadata blocks in memory, and three progressively more powerful
37 * interfaces for traversing and editing metadata in FLAC files.
39 * See the detailed documentation for each interface in the
40 * \link flac_metadata metadata \endlink module.
43 /** \defgroup flac_metadata FLAC/metadata.h: metadata interfaces
47 * This module provides functions for creating and manipulating FLAC
48 * metadata blocks in memory, and three progressively more powerful
49 * interfaces for traversing and editing metadata in FLAC files.
51 * There are three metadata interfaces of increasing complexity:
54 * Read-only access to the STREAMINFO block.
57 * Read-write access to all metadata blocks. This level is write-
58 * efficient in most cases (more on this below), and uses less memory
62 * Read-write access to all metadata blocks. This level is write-
63 * efficient in all cases, but uses more memory since all metadata for
64 * the whole file is read into memory and manipulated before writing
67 * What do we mean by efficient? When writing metadata back to a FLAC
68 * file it is possible to grow or shrink the metadata such that the entire
69 * file must be rewritten. However, if the size remains the same during
70 * changes or PADDING blocks are utilized, only the metadata needs to be
71 * overwritten, which is much faster.
73 * Efficient means the whole file is rewritten at most one time, and only
74 * when necessary. Level 1 is not efficient only in the case that you
75 * cause more than one metadata block to grow or shrink beyond what can
76 * be accomodated by padding. In this case you should probably use level
77 * 2, which allows you to edit all the metadata for a file in memory and
78 * write it out all at once.
80 * All levels know how to skip over and not disturb an ID3v2 tag at the
83 * In addition to the three interfaces, this module defines functions for
84 * creating and manipulating various metadata objects in memory. As we see
85 * from the Format module, FLAC metadata blocks in memory are very primitive
86 * structures for storing information in an efficient way. Reading
87 * information from the structures is easy but creating or modifying them
88 * directly is more complex. The metadata object routines here facilitate
89 * this by taking care of the consistency and memory management drudgery.
91 * Unless you will be using the level 1 or 2 interfaces to modify existing
92 * metadata however, you will not probably not need these.
94 * From a dependency standpoint, none of the encoders or decoders require
95 * the metadata module. This is so that embedded users can strip out the
96 * metadata module from libFLAC to reduce the size and complexity.
104 /** \defgroup flac_metadata_level0 FLAC/metadata.h: metadata level 0 interface
105 * \ingroup flac_metadata
108 * The level 0 interface consists of a single routine to read the
111 * It skips any ID3v2 tag at the head of the file.
116 /** Read the STREAMINFO metadata block of the given FLAC file. This function
117 * will skip any ID3v2 tag at the head of the file.
119 * \param filename The path to the FLAC file to read.
120 * \param streaminfo A pointer to space for the STREAMINFO block.
122 * \code filename != NULL \endcode
123 * \code streaminfo != NULL \endcode
125 * \c true if a valid STREAMINFO block was read from \a filename. Returns
126 * \c false if there was a memory allocation error, a file decoder error,
127 * or the file contained no STREAMINFO block.
129 FLAC_API FLAC__bool FLAC__metadata_get_streaminfo(const char *filename, FLAC__StreamMetadata *streaminfo);
134 /** \defgroup flac_metadata_level1 FLAC/metadata.h: metadata level 1 interface
135 * \ingroup flac_metadata
138 * The level 1 interface provides read-write access to FLAC file metadata and
139 * operates directly on the FLAC file.
141 * The general usage of this interface is:
143 * - Create an iterator using FLAC__metadata_simple_iterator_new()
144 * - Attach it to a file using FLAC__metadata_simple_iterator_init() and check
145 * the exit code. Call FLAC__metadata_simple_iterator_is_writable() to
146 * see if the file is writable, or read-only access is allowed.
147 * - Use FLAC__metadata_simple_iterator_next() and
148 * FLAC__metadata_simple_iterator_prev() to move around the blocks.
149 * This is does not read the actual blocks themselves.
150 * FLAC__metadata_simple_iterator_next() is relatively fast.
151 * FLAC__metadata_simple_iterator_prev() is slower since it needs to search
152 * forward from the front of the file.
153 * - Use FLAC__metadata_simple_iterator_get_block_type() or
154 * FLAC__metadata_simple_iterator_get_block() to access the actual data at
155 * the current iterator position. The returned object is yours to modify
157 * - Use FLAC__metadata_simple_iterator_set_block() to write a modified block
158 * back. You must have write permission to the original file. Make sure to
159 * read the whole comment to FLAC__metadata_simple_iterator_set_block()
161 * - Use FLAC__metadata_simple_iterator_insert_block_after() to add new blocks.
162 * Use the object creation functions from
163 * \link flac_metadata_object here \endlink to generate new objects.
164 * - Use FLAC__metadata_simple_iterator_delete_block() to remove the block
165 * currently referred to by the iterator, or replace it with padding.
166 * - Destroy the iterator with FLAC__metadata_simple_iterator_delete() when
170 * The FLAC file remains open the whole time between
171 * FLAC__metadata_simple_iterator_init() and
172 * FLAC__metadata_simple_iterator_delete(), so make sure you are not altering
173 * the file during this time.
176 * Do not modify the \a is_last, \a length, or \a type fields of returned
177 * FLAC__MetadataType objects. These are managed automatically.
180 * If any of the modification functions
181 * (FLAC__metadata_simple_iterator_set_block(),
182 * FLAC__metadata_simple_iterator_delete_block(),
183 * FLAC__metadata_simple_iterator_insert_block_after(), etc.) return \c false,
184 * you should delete the iterator as it may no longer be valid.
189 struct FLAC__Metadata_SimpleIterator;
190 /** The opaque structure definition for the level 1 iterator type.
192 * \link flac_metadata_level1 metadata level 1 module \endlink
193 * for a detailed description.
195 typedef struct FLAC__Metadata_SimpleIterator FLAC__Metadata_SimpleIterator;
197 /** Status type for FLAC__Metadata_SimpleIterator.
199 * The iterator's current status can be obtained by calling FLAC__metadata_simple_iterator_status().
203 FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK = 0,
204 /**< The iterator is in the normal OK state */
206 FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ILLEGAL_INPUT,
207 /**< The data passed into a function violated the function's usage criteria */
209 FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ERROR_OPENING_FILE,
210 /**< The iterator could not open the target file */
212 FLAC__METADATA_SIMPLE_ITERATOR_STATUS_NOT_A_FLAC_FILE,
213 /**< The iterator could not find the FLAC signature at the start of the file */
215 FLAC__METADATA_SIMPLE_ITERATOR_STATUS_NOT_WRITABLE,
216 /**< The iterator tried to write to a file that was not writable */
218 FLAC__METADATA_SIMPLE_ITERATOR_STATUS_BAD_METADATA,
219 /**< The iterator encountered input that does not conform to the FLAC metadata specification */
221 FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR,
222 /**< The iterator encountered an error while reading the FLAC file */
224 FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR,
225 /**< The iterator encountered an error while seeking in the FLAC file */
227 FLAC__METADATA_SIMPLE_ITERATOR_STATUS_WRITE_ERROR,
228 /**< The iterator encountered an error while writing the FLAC file */
230 FLAC__METADATA_SIMPLE_ITERATOR_STATUS_RENAME_ERROR,
231 /**< The iterator encountered an error renaming the FLAC file */
233 FLAC__METADATA_SIMPLE_ITERATOR_STATUS_UNLINK_ERROR,
234 /**< The iterator encountered an error removing the temporary file */
236 FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR,
237 /**< Memory allocation failed */
239 FLAC__METADATA_SIMPLE_ITERATOR_STATUS_INTERNAL_ERROR
240 /**< The caller violated an assertion or an unexpected error occurred */
242 } FLAC__Metadata_SimpleIteratorStatus;
244 /** Maps a FLAC__Metadata_SimpleIteratorStatus to a C string.
246 * Using a FLAC__Metadata_SimpleIteratorStatus as the index to this array
247 * will give the string equivalent. The contents should not be modified.
249 extern FLAC_API const char * const FLAC__Metadata_SimpleIteratorStatusString[];
252 /** Create a new iterator instance.
254 * \retval FLAC__Metadata_SimpleIterator*
255 * \c NULL if there was an error allocating memory, else the new instance.
257 FLAC_API FLAC__Metadata_SimpleIterator *FLAC__metadata_simple_iterator_new();
259 /** Free an iterator instance. Deletes the object pointed to by \a iterator.
261 * \param iterator A pointer to an existing iterator.
263 * \code iterator != NULL \endcode
265 FLAC_API void FLAC__metadata_simple_iterator_delete(FLAC__Metadata_SimpleIterator *iterator);
267 /** Get the current status of the iterator. Call this after a function
268 * returns \c false to get the reason for the error. Also resets the status
269 * to FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK.
271 * \param iterator A pointer to an existing iterator.
273 * \code iterator != NULL \endcode
274 * \retval FLAC__Metadata_SimpleIteratorStatus
275 * The current status of the iterator.
277 FLAC_API FLAC__Metadata_SimpleIteratorStatus FLAC__metadata_simple_iterator_status(FLAC__Metadata_SimpleIterator *iterator);
279 /** Initialize the iterator to point to the first metadata block in the
282 * \param iterator A pointer to an existing iterator.
283 * \param filename The path to the FLAC file.
284 * \param read_only If \c true, the FLAC file will be opened
285 * in read-only mode; if \c false, the FLAC
286 * file will be opened for edit even if no
287 * edits are performed.
288 * \param preserve_file_stats If \c true, the owner and modification
289 * time will be preserved even if the FLAC
290 * file is written to.
292 * \code iterator != NULL \endcode
293 * \code filename != NULL \endcode
295 * \c false if a memory allocation error occurs, the file can't be
296 * opened, or another error occurs, else \c true.
298 FLAC_API FLAC__bool FLAC__metadata_simple_iterator_init(FLAC__Metadata_SimpleIterator *iterator, const char *filename, FLAC__bool read_only, FLAC__bool preserve_file_stats);
300 /** Returns \c true if the FLAC file is writable. If \c false, calls to
301 * FLAC__metadata_simple_iterator_set_block() and
302 * FLAC__metadata_simple_iterator_insert_block_after() will fail.
304 * \param iterator A pointer to an existing iterator.
306 * \code iterator != NULL \endcode
310 FLAC_API FLAC__bool FLAC__metadata_simple_iterator_is_writable(const FLAC__Metadata_SimpleIterator *iterator);
312 /** Moves the iterator forward one metadata block, returning \c false if
313 * already at the end.
315 * \param iterator A pointer to an existing initialized iterator.
317 * \code iterator != NULL \endcode
318 * \a iterator has been successfully initialized with
319 * FLAC__metadata_simple_iterator_init()
321 * \c false if already at the last metadata block of the chain, else
324 FLAC_API FLAC__bool FLAC__metadata_simple_iterator_next(FLAC__Metadata_SimpleIterator *iterator);
326 /** Moves the iterator backward one metadata block, returning \c false if
327 * already at the beginning.
329 * \param iterator A pointer to an existing initialized iterator.
331 * \code iterator != NULL \endcode
332 * \a iterator has been successfully initialized with
333 * FLAC__metadata_simple_iterator_init()
335 * \c false if already at the first metadata block of the chain, else
338 FLAC_API FLAC__bool FLAC__metadata_simple_iterator_prev(FLAC__Metadata_SimpleIterator *iterator);
340 /** Get the type of the metadata block at the current position. This
341 * avoids reading the actual block data which can save time for large
344 * \param iterator A pointer to an existing initialized iterator.
346 * \code iterator != NULL \endcode
347 * \a iterator has been successfully initialized with
348 * FLAC__metadata_simple_iterator_init()
349 * \retval FLAC__MetadataType
350 * The type of the metadata block at the current iterator position.
353 FLAC_API FLAC__MetadataType FLAC__metadata_simple_iterator_get_block_type(const FLAC__Metadata_SimpleIterator *iterator);
355 /** Get the metadata block at the current position. You can modify the
356 * block but must use FLAC__metadata_simple_iterator_set_block() to
357 * write it back to the FLAC file.
359 * You must call FLAC__metadata_object_delete() on the returned object
360 * when you are finished with it.
362 * \param iterator A pointer to an existing initialized iterator.
364 * \code iterator != NULL \endcode
365 * \a iterator has been successfully initialized with
366 * FLAC__metadata_simple_iterator_init()
367 * \retval FLAC__StreamMetadata*
368 * The current metadata block.
370 FLAC_API FLAC__StreamMetadata *FLAC__metadata_simple_iterator_get_block(FLAC__Metadata_SimpleIterator *iterator);
372 /** Write a block back to the FLAC file. This function tries to be
373 * as efficient as possible; how the block is actually written is
374 * shown by the following:
376 * Existing block is a STREAMINFO block and the new block is a
377 * STREAMINFO block: the new block is written in place. Make sure
378 * you know what you're doing when changing the values of a
381 * Existing block is a STREAMINFO block and the new block is a
382 * not a STREAMINFO block: this is an error since the first block
383 * must be a STREAMINFO block. Returns \c false without altering the
386 * Existing block is not a STREAMINFO block and the new block is a
387 * STREAMINFO block: this is an error since there may be only one
388 * STREAMINFO block. Returns \c false without altering the file.
390 * Existing block and new block are the same length: the existing
391 * block will be replaced by the new block, written in place.
393 * Existing block is longer than new block: if use_padding is \c true,
394 * the existing block will be overwritten in place with the new
395 * block followed by a PADDING block, if possible, to make the total
396 * size the same as the existing block. Remember that a padding
397 * block requires at least four bytes so if the difference in size
398 * between the new block and existing block is less than that, the
399 * entire file will have to be rewritten, using the new block's
400 * exact size. If use_padding is \c false, the entire file will be
401 * rewritten, replacing the existing block by the new block.
403 * Existing block is shorter than new block: if use_padding is \c true,
404 * the function will try and expand the new block into the following
405 * PADDING block, if it exists and doing so won't shrink the PADDING
406 * block to less than 4 bytes. If there is no following PADDING
407 * block, or it will shrink to less than 4 bytes, or use_padding is
408 * \c false, the entire file is rewritten, replacing the existing block
409 * with the new block. Note that in this case any following PADDING
410 * block is preserved as is.
412 * After writing the block, the iterator will remain in the same
413 * place, i.e. pointing to the new block.
415 * \param iterator A pointer to an existing initialized iterator.
416 * \param block The block to set.
417 * \param use_padding See above.
419 * \code iterator != NULL \endcode
420 * \a iterator has been successfully initialized with
421 * FLAC__metadata_simple_iterator_init()
422 * \code block != NULL \endcode
424 * \c true if successful, else \c false.
426 FLAC_API FLAC__bool FLAC__metadata_simple_iterator_set_block(FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block, FLAC__bool use_padding);
428 /** This is similar to FLAC__metadata_simple_iterator_set_block()
429 * except that instead of writing over an existing block, it appends
430 * a block after the existing block. \a use_padding is again used to
431 * tell the function to try an expand into following padding in an
432 * attempt to avoid rewriting the entire file.
434 * This function will fail and return \c false if given a STREAMINFO
437 * After writing the block, the iterator will be pointing to the
440 * \param iterator A pointer to an existing initialized iterator.
441 * \param block The block to set.
442 * \param use_padding See above.
444 * \code iterator != NULL \endcode
445 * \a iterator has been successfully initialized with
446 * FLAC__metadata_simple_iterator_init()
447 * \code block != NULL \endcode
449 * \c true if successful, else \c false.
451 FLAC_API FLAC__bool FLAC__metadata_simple_iterator_insert_block_after(FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block, FLAC__bool use_padding);
453 /** Deletes the block at the current position. This will cause the
454 * entire FLAC file to be rewritten, unless \a use_padding is \c true,
455 * in which case the block will be replaced by an equal-sized PADDING
456 * block. The iterator will be left pointing to the block before the
459 * You may not delete the STREAMINFO block.
461 * \param iterator A pointer to an existing initialized iterator.
462 * \param use_padding See above.
464 * \code iterator != NULL \endcode
465 * \a iterator has been successfully initialized with
466 * FLAC__metadata_simple_iterator_init()
468 * \c true if successful, else \c false.
470 FLAC_API FLAC__bool FLAC__metadata_simple_iterator_delete_block(FLAC__Metadata_SimpleIterator *iterator, FLAC__bool use_padding);
475 /** \defgroup flac_metadata_level2 FLAC/metadata.h: metadata level 2 interface
476 * \ingroup flac_metadata
479 * The level 2 interface provides read-write access to FLAC file metadata;
480 * all metadata is read into memory, operated on in memory, and then written
481 * to file, which is more efficient than level 1 when editing multiple blocks.
483 * The general usage of this interface is:
485 * - Create a new chain using FLAC__metadata_chain_new(). A chain is a
486 * linked list of FLAC metadata blocks.
487 * - Read all metadata into the the chain from a FLAC file using
488 * FLAC__metadata_chain_read() and check the status.
489 * - Optionally, consolidate the padding using
490 * FLAC__metadata_chain_merge_padding() or
491 * FLAC__metadata_chain_sort_padding().
492 * - Create a new iterator using FLAC__metadata_iterator_new()
493 * - Initialize the iterator to point to the first element in the chain
494 * using FLAC__metadata_iterator_init()
495 * - Traverse the chain using FLAC__metadata_iterator_next and
496 * FLAC__metadata_iterator_prev().
497 * - Get a block for reading or modification using
498 * FLAC__metadata_iterator_get_block(). The pointer to the object
499 * inside the chain is returned, so the block is yours to modify.
500 * Changes will be reflected in the FLAC file when you write the
501 * chain. You can also add and delete blocks (see functions below).
502 * - When done, write out the chain using FLAC__metadata_chain_write().
503 * Make sure to read the whole comment to the function below.
504 * - Delete the chain using FLAC__metadata_chain_delete().
507 * Even though the FLAC file is not open while the chain is being
508 * manipulated, you must not alter the file externally during
509 * this time. The chain assumes the FLAC file will not change
510 * between the time of FLAC__metadata_chain_read() and
511 * FLAC__metadata_chain_write().
514 * Do not modify the is_last, length, or type fields of returned
515 * FLAC__MetadataType objects. These are managed automatically.
518 * The metadata objects returned by FLAC__metadata_iterator_get_block()
519 * are owned by the chain; do not FLAC__metadata_object_delete() them.
520 * In the same way, blocks passed to FLAC__metadata_iterator_set_block()
521 * become owned by the chain and they will be deleted when the chain is
527 struct FLAC__Metadata_Chain;
528 /** The opaque structure definition for the level 2 chain type.
530 typedef struct FLAC__Metadata_Chain FLAC__Metadata_Chain;
532 struct FLAC__Metadata_Iterator;
533 /** The opaque structure definition for the level 2 iterator type.
535 typedef struct FLAC__Metadata_Iterator FLAC__Metadata_Iterator;
538 FLAC__METADATA_CHAIN_STATUS_OK = 0,
539 /**< The chain is in the normal OK state */
541 FLAC__METADATA_CHAIN_STATUS_ILLEGAL_INPUT,
542 /**< The data passed into a function violated the function's usage criteria */
544 FLAC__METADATA_CHAIN_STATUS_ERROR_OPENING_FILE,
545 /**< The chain could not open the target file */
547 FLAC__METADATA_CHAIN_STATUS_NOT_A_FLAC_FILE,
548 /**< The chain could not find the FLAC signature at the start of the file */
550 FLAC__METADATA_CHAIN_STATUS_NOT_WRITABLE,
551 /**< The chain tried to write to a file that was not writable */
553 FLAC__METADATA_CHAIN_STATUS_BAD_METADATA,
554 /**< The chain encountered input that does not conform to the FLAC metadata specification */
556 FLAC__METADATA_CHAIN_STATUS_READ_ERROR,
557 /**< The chain encountered an error while reading the FLAC file */
559 FLAC__METADATA_CHAIN_STATUS_SEEK_ERROR,
560 /**< The chain encountered an error while seeking in the FLAC file */
562 FLAC__METADATA_CHAIN_STATUS_WRITE_ERROR,
563 /**< The chain encountered an error while writing the FLAC file */
565 FLAC__METADATA_CHAIN_STATUS_RENAME_ERROR,
566 /**< The chain encountered an error renaming the FLAC file */
568 FLAC__METADATA_CHAIN_STATUS_UNLINK_ERROR,
569 /**< The chain encountered an error removing the temporary file */
571 FLAC__METADATA_CHAIN_STATUS_MEMORY_ALLOCATION_ERROR,
572 /**< Memory allocation failed */
574 FLAC__METADATA_CHAIN_STATUS_INTERNAL_ERROR
575 /**< The caller violated an assertion or an unexpected error occurred */
577 } FLAC__Metadata_ChainStatus;
579 /** Maps a FLAC__Metadata_ChainStatus to a C string.
581 * Using a FLAC__Metadata_ChainStatus as the index to this array
582 * will give the string equivalent. The contents should not be modified.
584 extern FLAC_API const char * const FLAC__Metadata_ChainStatusString[];
586 /*********** FLAC__Metadata_Chain ***********/
588 /** Create a new chain instance.
590 * \retval FLAC__Metadata_Chain*
591 * \c NULL if there was an error allocating memory, else the new instance.
593 FLAC_API FLAC__Metadata_Chain *FLAC__metadata_chain_new();
595 /** Free a chain instance. Deletes the object pointed to by \a chain.
597 * \param chain A pointer to an existing chain.
599 * \code chain != NULL \endcode
601 FLAC_API void FLAC__metadata_chain_delete(FLAC__Metadata_Chain *chain);
603 /** Get the current status of the chain. Call this after a function
604 * returns \c false to get the reason for the error. Also resets the
605 * status to FLAC__METADATA_CHAIN_STATUS_OK.
607 * \param chain A pointer to an existing chain.
609 * \code chain != NULL \endcode
610 * \retval FLAC__Metadata_ChainStatus
611 * The current status of the chain.
613 FLAC_API FLAC__Metadata_ChainStatus FLAC__metadata_chain_status(FLAC__Metadata_Chain *chain);
615 /** Read all metadata from a FLAC file into the chain.
617 * \param chain A pointer to an existing chain.
618 * \param filename The path to the FLAC file to read.
620 * \code chain != NULL \endcode
621 * \code filename != NULL \endcode
623 * \c true if a valid list of metadata blocks was read from
624 * \a filename, else \c false. On failure, check the status with
625 * FLAC__metadata_chain_status().
627 FLAC_API FLAC__bool FLAC__metadata_chain_read(FLAC__Metadata_Chain *chain, const char *filename);
629 /** Write all metadata out to the FLAC file. This function tries to be as
630 * efficient as possible; how the metadata is actually written is shown by
633 * If the current chain is the same size as the existing metadata, the new
634 * data is written in place.
636 * If the current chain is longer than the existing metadata, and
637 * \a use_padding is \c true, and the last block is a PADDING block of
638 * sufficient length, the function will truncate the final padding block
639 * so that the overall size of the metadata is the same as the existing
640 * metadata, and then just rewrite the metadata. Otherwise, if not all of
641 * the above conditions are met, the entire FLAC file must be rewritten.
642 * If you want to use padding this way it is a good idea to call
643 * FLAC__metadata_chain_sort_padding() first so that you have the maximum
644 * amount of padding to work with, unless you need to preserve ordering
645 * of the PADDING blocks for some reason.
647 * If the current chain is shorter than the existing metadata, and
648 * \a use_padding is \c true, and the final block is a PADDING block, the padding
649 * is extended to make the overall size the same as the existing data. If
650 * \a use_padding is \c true and the last block is not a PADDING block, a new
651 * PADDING block is added to the end of the new data to make it the same
652 * size as the existing data (if possible, see the note to
653 * FLAC__metadata_simple_iterator_set_block() about the four byte limit)
654 * and the new data is written in place. If none of the above apply or
655 * \a use_padding is \c false, the entire FLAC file is rewritten.
657 * If \a preserve_file_stats is \c true, the owner and modification time will
658 * be preserved even if the FLAC file is written.
660 * \param chain A pointer to an existing chain.
661 * \param use_padding See above.
662 * \param preserve_file_stats See above.
664 * \code chain != NULL \endcode
666 * \c true if the write succeeded, else \c false. On failure,
667 * check the status with FLAC__metadata_chain_status().
669 FLAC_API FLAC__bool FLAC__metadata_chain_write(FLAC__Metadata_Chain *chain, FLAC__bool use_padding, FLAC__bool preserve_file_stats);
671 /** Merge adjacent PADDING blocks into a single block.
673 * \note This function does not write to the FLAC file, it only
674 * modifies the chain.
676 * \warning Any iterator on the current chain will become invalid after this
677 * call. You should delete the iterator and get a new one.
679 * \param chain A pointer to an existing chain.
681 * \code chain != NULL \endcode
683 FLAC_API void FLAC__metadata_chain_merge_padding(FLAC__Metadata_Chain *chain);
685 /** This function will move all PADDING blocks to the end on the metadata,
686 * then merge them into a single block.
688 * \note This function does not write to the FLAC file, it only
689 * modifies the chain.
691 * \warning Any iterator on the current chain will become invalid after this
692 * call. You should delete the iterator and get a new one.
694 * \param chain A pointer to an existing chain.
696 * \code chain != NULL \endcode
698 FLAC_API void FLAC__metadata_chain_sort_padding(FLAC__Metadata_Chain *chain);
701 /*********** FLAC__Metadata_Iterator ***********/
703 /** Create a new iterator instance.
705 * \retval FLAC__Metadata_Iterator*
706 * \c NULL if there was an error allocating memory, else the new instance.
708 FLAC_API FLAC__Metadata_Iterator *FLAC__metadata_iterator_new();
710 /** Free an iterator instance. Deletes the object pointed to by \a iterator.
712 * \param iterator A pointer to an existing iterator.
714 * \code iterator != NULL \endcode
716 FLAC_API void FLAC__metadata_iterator_delete(FLAC__Metadata_Iterator *iterator);
718 /** Initialize the iterator to point to the first metadata block in the
721 * \param iterator A pointer to an existing iterator.
722 * \param chain A pointer to an existing and initialized (read) chain.
724 * \code iterator != NULL \endcode
725 * \code chain != NULL \endcode
727 FLAC_API void FLAC__metadata_iterator_init(FLAC__Metadata_Iterator *iterator, FLAC__Metadata_Chain *chain);
729 /** Moves the iterator forward one metadata block, returning \c false if
730 * already at the end.
732 * \param iterator A pointer to an existing initialized iterator.
734 * \code iterator != NULL \endcode
735 * \a iterator has been successfully initialized with
736 * FLAC__metadata_iterator_init()
738 * \c false if already at the last metadata block of the chain, else
741 FLAC_API FLAC__bool FLAC__metadata_iterator_next(FLAC__Metadata_Iterator *iterator);
743 /** Moves the iterator backward one metadata block, returning \c false if
744 * already at the beginning.
746 * \param iterator A pointer to an existing initialized iterator.
748 * \code iterator != NULL \endcode
749 * \a iterator has been successfully initialized with
750 * FLAC__metadata_iterator_init()
752 * \c false if already at the first metadata block of the chain, else
755 FLAC_API FLAC__bool FLAC__metadata_iterator_prev(FLAC__Metadata_Iterator *iterator);
757 /** Get the type of the metadata block at the current position.
759 * \param iterator A pointer to an existing initialized iterator.
761 * \code iterator != NULL \endcode
762 * \a iterator has been successfully initialized with
763 * FLAC__metadata_iterator_init()
764 * \retval FLAC__MetadataType
765 * The type of the metadata block at the current iterator position.
767 FLAC_API FLAC__MetadataType FLAC__metadata_iterator_get_block_type(const FLAC__Metadata_Iterator *iterator);
769 /** Get the metadata block at the current position. You can modify
770 * the block in place but must write the chain before the changes
771 * are reflected to the FLAC file. You do not need to call
772 * FLAC__metadata_iterator_set_block() to reflect the changes;
773 * the pointer returned by FLAC__metadata_iterator_get_block()
774 * points directly into the chain.
777 * Do not call FLAC__metadata_object_delete() on the returned object;
778 * to delete a block use FLAC__metadata_iterator_delete_block().
780 * \param iterator A pointer to an existing initialized iterator.
782 * \code iterator != NULL \endcode
783 * \a iterator has been successfully initialized with
784 * FLAC__metadata_iterator_init()
785 * \retval FLAC__StreamMetadata*
786 * The current metadata block.
788 FLAC_API FLAC__StreamMetadata *FLAC__metadata_iterator_get_block(FLAC__Metadata_Iterator *iterator);
790 /** Set the metadata block at the current position, replacing the existing
791 * block. The new block passed in becomes owned by the chain and it will be
792 * deleted when the chain is deleted.
794 * \param iterator A pointer to an existing initialized iterator.
795 * \param block A pointer to a metadata block.
797 * \code iterator != NULL \endcode
798 * \a iterator has been successfully initialized with
799 * FLAC__metadata_iterator_init()
800 * \code block != NULL \endcode
802 * \c false if the conditions in the above description are not met, or
803 * a memory allocation error occurs, otherwise \c true.
805 FLAC_API FLAC__bool FLAC__metadata_iterator_set_block(FLAC__Metadata_Iterator *iterator, FLAC__StreamMetadata *block);
807 /** Removes the current block from the chain. If \a replace_with_padding is
808 * \c true, the block will instead be replaced with a padding block of equal
809 * size. You can not delete the STREAMINFO block. The iterator will be
810 * left pointing to the block before the one just "deleted", even if
811 * \a replace_with_padding is \c true.
813 * \param iterator A pointer to an existing initialized iterator.
814 * \param replace_with_padding See above.
816 * \code iterator != NULL \endcode
817 * \a iterator has been successfully initialized with
818 * FLAC__metadata_iterator_init()
820 * \c false if the conditions in the above description are not met,
823 FLAC_API FLAC__bool FLAC__metadata_iterator_delete_block(FLAC__Metadata_Iterator *iterator, FLAC__bool replace_with_padding);
825 /** Insert a new block before the current block. You cannot insert a block
826 * before the first STREAMINFO block. You cannot insert a STREAMINFO block
827 * as there can be only one, the one that already exists at the head when you
828 * read in a chain. The chain takes ownership of the new block and it will be
829 * deleted when the chain is deleted. The iterator will be left pointing to
832 * \param iterator A pointer to an existing initialized iterator.
833 * \param block A pointer to a metadata block to insert.
835 * \code iterator != NULL \endcode
836 * \a iterator has been successfully initialized with
837 * FLAC__metadata_iterator_init()
839 * \c false if the conditions in the above description are not met, or
840 * a memory allocation error occurs, otherwise \c true.
842 FLAC_API FLAC__bool FLAC__metadata_iterator_insert_block_before(FLAC__Metadata_Iterator *iterator, FLAC__StreamMetadata *block);
844 /** Insert a new block after the current block. You cannot insert a STREAMINFO
845 * block as there can be only one, the one that already exists at the head when
846 * you read in a chain. The chain takes ownership of the new block and it will
847 * be deleted when the chain is deleted. The iterator will be left pointing to
850 * \param iterator A pointer to an existing initialized iterator.
851 * \param block A pointer to a metadata block to insert.
853 * \code iterator != NULL \endcode
854 * \a iterator has been successfully initialized with
855 * FLAC__metadata_iterator_init()
857 * \c false if the conditions in the above description are not met, or
858 * a memory allocation error occurs, otherwise \c true.
860 FLAC_API FLAC__bool FLAC__metadata_iterator_insert_block_after(FLAC__Metadata_Iterator *iterator, FLAC__StreamMetadata *block);
865 /** \defgroup flac_metadata_object FLAC/metadata.h: metadata object methods
866 * \ingroup flac_metadata
869 * This module contains methods for manipulating FLAC metadata objects.
871 * Since many are variable length we have to be careful about the memory
872 * management. We decree that all pointers to data in the object are
873 * owned by the object and memory-managed by the object.
875 * Use the FLAC__metadata_object_new() and FLAC__metadata_object_delete()
876 * functions to create all instances. When using the
877 * FLAC__metadata_object_set_*() functions to set pointers to data, set
878 * \a copy to \c true to have the function make it's own copy of the data, or
879 * to \c false to give the object ownership of your data. In the latter case
880 * your pointer must be freeable by free() and will be free()d when the object
881 * is FLAC__metadata_object_delete()d. It is legal to pass a null pointer as
882 * the data pointer to a FLAC__metadata_object_set_*() function as long as
883 * the length argument is 0 and the \a copy argument is \c false.
885 * The FLAC__metadata_object_new() and FLAC__metadata_object_clone() function
886 * will return \c NULL in the case of a memory allocation error, otherwise a new
887 * object. The FLAC__metadata_object_set_*() functions return \c false in the
888 * case of a memory allocation error.
890 * We don't have the convenience of C++ here, so note that the library relies
891 * on you to keep the types straight. In other words, if you pass, for
892 * example, a FLAC__StreamMetadata* that represents a STREAMINFO block to
893 * FLAC__metadata_object_application_set_data(), you will get an assertion
896 * There is no need to recalculate the length field on metadata blocks you
897 * have modified. They will be calculated automatically before they are
898 * written back to a file.
904 /** Create a new metadata object instance of the given type.
906 * The object will be "empty"; i.e. values and data pointers will be \c 0.
908 * \param type Type of object to create
909 * \retval FLAC__StreamMetadata*
910 * \c NULL if there was an error allocating memory, else the new instance.
912 FLAC_API FLAC__StreamMetadata *FLAC__metadata_object_new(FLAC__MetadataType type);
914 /** Create a copy of an existing metadata object.
916 * The copy is a "deep" copy, i.e. dynamically allocated data within the
917 * object is also copied. The caller takes ownership of the new block and
918 * is responsible for freeing it with FLAC__metadata_object_delete().
920 * \param object Pointer to object to copy.
922 * \code object != NULL \endcode
923 * \retval FLAC__StreamMetadata*
924 * \c NULL if there was an error allocating memory, else the new instance.
926 FLAC_API FLAC__StreamMetadata *FLAC__metadata_object_clone(const FLAC__StreamMetadata *object);
928 /** Free a metadata object. Deletes the object pointed to by \a object.
930 * The delete is a "deep" delete, i.e. dynamically allocated data within the
931 * object is also deleted.
933 * \param object A pointer to an existing object.
935 * \code object != NULL \endcode
937 FLAC_API void FLAC__metadata_object_delete(FLAC__StreamMetadata *object);
939 /** Compares two metadata objects.
941 * The compare is "deep", i.e. dynamically allocated data within the
942 * object is also compared.
944 * \param block1 A pointer to an existing object.
945 * \param block2 A pointer to an existing object.
947 * \code block1 != NULL \endcode
948 * \code block2 != NULL \endcode
950 * \c true if objects are identical, else \c false.
952 FLAC_API FLAC__bool FLAC__metadata_object_is_equal(const FLAC__StreamMetadata *block1, const FLAC__StreamMetadata *block2);
954 /** Sets the application data of an APPLICATION block.
956 * If \a copy is \c true, a copy of the data is stored; otherwise, the object
957 * takes ownership of the pointer. Returns \c false if \a copy == \c true
960 * \param object A pointer to an existing APPLICATION object.
961 * \param data A pointer to the data to set.
962 * \param length The length of \a data in bytes.
963 * \param copy See above.
965 * \code object != NULL \endcode
966 * \code object->type == FLAC__METADATA_TYPE_APPLICATION \endcode
967 * \code (data != NULL && length > 0) ||
968 * (data == NULL && length == 0 && copy == false) \endcode
970 * \c false if \a copy is \c true and malloc fails, else \c true.
972 FLAC_API FLAC__bool FLAC__metadata_object_application_set_data(FLAC__StreamMetadata *object, FLAC__byte *data, unsigned length, FLAC__bool copy);
974 /** Resize the seekpoint array.
976 * If the size shrinks, elements will truncated; if it grows, new placeholder
977 * points will be added to the end.
979 * \param object A pointer to an existing SEEKTABLE object.
980 * \param new_num_points The desired length of the array; may be \c 0.
982 * \code object != NULL \endcode
983 * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode
984 * \code (object->data.seek_table.points == NULL && object->data.seek_table.num_points == 0) ||
985 * (object->data.seek_table.points != NULL && object->data.seek_table.num_points > 0) \endcode
987 * \c false if memory allocation error, else \c true.
989 FLAC_API FLAC__bool FLAC__metadata_object_seektable_resize_points(FLAC__StreamMetadata *object, unsigned new_num_points);
991 /** Set a seekpoint in a seektable.
993 * \param object A pointer to an existing SEEKTABLE object.
994 * \param point_num Index into seekpoint array to set.
995 * \param point The point to set.
997 * \code object != NULL \endcode
998 * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode
999 * \code object->data.seek_table.num_points > point_num \endcode
1001 FLAC_API void FLAC__metadata_object_seektable_set_point(FLAC__StreamMetadata *object, unsigned point_num, FLAC__StreamMetadata_SeekPoint point);
1003 /** Insert a seekpoint into a seektable.
1005 * \param object A pointer to an existing SEEKTABLE object.
1006 * \param point_num Index into seekpoint array to set.
1007 * \param point The point to set.
1009 * \code object != NULL \endcode
1010 * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode
1011 * \code object->data.seek_table.num_points >= point_num \endcode
1012 * \retval FLAC__bool
1013 * \c false if memory allocation error, else \c true.
1015 FLAC_API FLAC__bool FLAC__metadata_object_seektable_insert_point(FLAC__StreamMetadata *object, unsigned point_num, FLAC__StreamMetadata_SeekPoint point);
1017 /** Delete a seekpoint from a seektable.
1019 * \param object A pointer to an existing SEEKTABLE object.
1020 * \param point_num Index into seekpoint array to set.
1022 * \code object != NULL \endcode
1023 * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode
1024 * \code object->data.seek_table.num_points > point_num \endcode
1025 * \retval FLAC__bool
1026 * \c false if memory allocation error, else \c true.
1028 FLAC_API FLAC__bool FLAC__metadata_object_seektable_delete_point(FLAC__StreamMetadata *object, unsigned point_num);
1030 /** Check a seektable to see if it conforms to the FLAC specification.
1031 * See the format specification for limits on the contents of the
1034 * \param object A pointer to an existing SEEKTABLE object.
1036 * \code object != NULL \endcode
1037 * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode
1038 * \retval FLAC__bool
1039 * \c false if seek table is illegal, else \c true.
1041 FLAC_API FLAC__bool FLAC__metadata_object_seektable_is_legal(const FLAC__StreamMetadata *object);
1043 /** Append a number of placeholder points to the end of a seek table.
1046 * As with the other ..._seektable_template_... functions, you should
1047 * call FLAC__metadata_object_seektable_template_sort() when finished
1048 * to make the seek table legal.
1050 * \param object A pointer to an existing SEEKTABLE object.
1051 * \param num The number of placeholder points to append.
1053 * \code object != NULL \endcode
1054 * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode
1055 * \retval FLAC__bool
1056 * \c false if memory allocation fails, else \c true.
1058 FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_placeholders(FLAC__StreamMetadata *object, unsigned num);
1060 /** Append a specific seek point template to the end of a seek table.
1063 * As with the other ..._seektable_template_... functions, you should
1064 * call FLAC__metadata_object_seektable_template_sort() when finished
1065 * to make the seek table legal.
1067 * \param object A pointer to an existing SEEKTABLE object.
1068 * \param sample_number The sample number of the seek point template.
1070 * \code object != NULL \endcode
1071 * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode
1072 * \retval FLAC__bool
1073 * \c false if memory allocation fails, else \c true.
1075 FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_point(FLAC__StreamMetadata *object, FLAC__uint64 sample_number);
1077 /** Append specific seek point templates to the end of a seek table.
1080 * As with the other ..._seektable_template_... functions, you should
1081 * call FLAC__metadata_object_seektable_template_sort() when finished
1082 * to make the seek table legal.
1084 * \param object A pointer to an existing SEEKTABLE object.
1085 * \param sample_numbers An array of sample numbers for the seek points.
1086 * \param num The number of seek point templates to append.
1088 * \code object != NULL \endcode
1089 * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode
1090 * \retval FLAC__bool
1091 * \c false if memory allocation fails, else \c true.
1093 FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_points(FLAC__StreamMetadata *object, FLAC__uint64 sample_numbers[], unsigned num);
1095 /** Append a set of evenly-spaced seek point templates to the end of a
1099 * As with the other ..._seektable_template_... functions, you should
1100 * call FLAC__metadata_object_seektable_template_sort() when finished
1101 * to make the seek table legal.
1103 * \param object A pointer to an existing SEEKTABLE object.
1104 * \param num The number of placeholder points to append.
1105 * \param total_samples The total number of samples to be encoded;
1106 * the seekpoints will be spaced approximately
1107 * \a total_samples / \a num samples apart.
1109 * \code object != NULL \endcode
1110 * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode
1111 * \retval FLAC__bool
1112 * \c false if memory allocation fails, else \c true.
1114 FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_append_spaced_points(FLAC__StreamMetadata *object, unsigned num, FLAC__uint64 total_samples);
1116 /** Sort a seek table's seek points according to the format specification,
1117 * removing duplicates.
1119 * \param object A pointer to a seek table to be sorted.
1120 * \param compact If \c false, behaves like FLAC__format_seektable_sort().
1121 * If \c true, duplicates are deleted and the seek table is
1122 * shrunk appropriately; the number of placeholder points
1123 * present in the seek table will be the same after the call
1126 * \code object != NULL \endcode
1127 * \code object->type == FLAC__METADATA_TYPE_SEEKTABLE \endcode
1128 * \retval FLAC__bool
1129 * \c false if realloc fails, else \c true.
1131 FLAC_API FLAC__bool FLAC__metadata_object_seektable_template_sort(FLAC__StreamMetadata *object, FLAC__bool compact);
1133 /** Sets the vendor string in a VORBIS_COMMENT block.
1135 * If \a copy is \c true, a copy of the entry is stored; otherwise, the object
1136 * takes ownership of the \c entry->entry pointer. Returns \c false if
1137 * \a copy == \c true and malloc fails.
1139 * \param object A pointer to an existing VORBIS_COMMENT object.
1140 * \param entry The entry to set the vendor string to.
1141 * \param copy See above.
1143 * \code object != NULL \endcode
1144 * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode
1145 * \code (entry->entry != NULL && entry->length > 0) ||
1146 * (entry->entry == NULL && entry->length == 0 && copy == false) \endcode
1147 * \retval FLAC__bool
1148 * \c false if \a copy is \c true and malloc fails, else \c true.
1150 FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_set_vendor_string(FLAC__StreamMetadata *object, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool copy);
1152 /** Resize the comment array.
1154 * If the size shrinks, elements will truncated; if it grows, new empty
1155 * fields will be added to the end.
1157 * \param object A pointer to an existing VORBIS_COMMENT object.
1158 * \param new_num_comments The desired length of the array; may be \c 0.
1160 * \code object != NULL \endcode
1161 * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode
1162 * \code (object->data.vorbis_comment.comments == NULL && object->data.vorbis_comment.num_comments == 0) ||
1163 * (object->data.vorbis_comment.comments != NULL && object->data.vorbis_comment.num_comments > 0) \endcode
1164 * \retval FLAC__bool
1165 * \c false if memory allocation error, else \c true.
1167 FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_resize_comments(FLAC__StreamMetadata *object, unsigned new_num_comments);
1169 /** Sets a comment in a VORBIS_COMMENT block.
1171 * If \a copy is \c true, a copy of the entry is stored; otherwise, the object
1172 * takes ownership of the \c entry->entry pointer. Returns \c false if
1173 * \a copy == \c true and malloc fails.
1175 * \param object A pointer to an existing VORBIS_COMMENT object.
1176 * \param comment_num Index into comment array to set.
1177 * \param entry The entry to set the comment to.
1178 * \param copy See above.
1180 * \code object != NULL \endcode
1181 * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode
1182 * \code (entry->entry != NULL && entry->length > 0) ||
1183 * (entry->entry == NULL && entry->length == 0 && copy == false) \endcode
1184 * \retval FLAC__bool
1185 * \c false if \a copy is \c true and malloc fails, else \c true.
1187 FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_set_comment(FLAC__StreamMetadata *object, unsigned comment_num, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool copy);
1189 /** Insert a comment in a VORBIS_COMMENT block at the given index.
1191 * If \a copy is \c true, a copy of the entry is stored; otherwise, the object
1192 * takes ownership of the \c entry->entry pointer. Returns \c false if
1193 * \a copy == \c true and malloc fails.
1195 * \param object A pointer to an existing VORBIS_COMMENT object.
1196 * \param comment_num The index at which to insert the comment. The comments
1197 * at and after \a comment_num move right one position.
1198 * To append a comment to the end, set \a comment_num to
1199 * \c object->data.vorbis_comment.num_comments .
1200 * \param entry The comment to insert.
1201 * \param copy See above.
1203 * \code object != NULL \endcode
1204 * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode
1205 * \code object->data.vorbis_comment.num_comments >= comment_num \endcode
1206 * \code (entry->entry != NULL && entry->length > 0) ||
1207 * (entry->entry == NULL && entry->length == 0 && copy == false) \endcode
1208 * \retval FLAC__bool
1209 * \c false if \a copy is \c true and malloc fails, else \c true.
1211 FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_insert_comment(FLAC__StreamMetadata *object, unsigned comment_num, FLAC__StreamMetadata_VorbisComment_Entry entry, FLAC__bool copy);
1213 /** Delete a comment in a VORBIS_COMMENT block at the given index.
1215 * If \a copy is \c true, a copy of the entry is stored; otherwise, the object
1216 * takes ownership of the \c entry->entry pointer. Returns \c false if
1217 * \a copy == \c true and malloc fails.
1219 * \param object A pointer to an existing VORBIS_COMMENT object.
1220 * \param comment_num The index of the comment to delete.
1222 * \code object != NULL \endcode
1223 * \code object->type == FLAC__METADATA_TYPE_VORBIS_COMMENT \endcode
1224 * \code object->data.vorbis_comment.num_comments > comment_num \endcode
1225 * \code (entry->entry != NULL && entry->length > 0) ||
1226 * (entry->entry == NULL && entry->length == 0 && copy == false) \endcode
1227 * \retval FLAC__bool
1228 * \c false if realloc fails, else \c true.
1230 FLAC_API FLAC__bool FLAC__metadata_object_vorbiscomment_delete_comment(FLAC__StreamMetadata *object, unsigned comment_num);