RetroArch
Typedefs | Enumerations | Functions | Variables
FLAC/metadata.h: metadata level 1 interface

The level 1 interface provides read-write access to FLAC file metadata and operates directly on the FLAC file. More...

Collaboration diagram for FLAC/metadata.h: metadata level 1 interface:

Typedefs

typedef struct FLAC__Metadata_SimpleIterator FLAC__Metadata_SimpleIterator
 

Enumerations

enum  FLAC__Metadata_SimpleIteratorStatus {
  FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK = 0, FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ILLEGAL_INPUT, FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ERROR_OPENING_FILE, FLAC__METADATA_SIMPLE_ITERATOR_STATUS_NOT_A_FLAC_FILE,
  FLAC__METADATA_SIMPLE_ITERATOR_STATUS_NOT_WRITABLE, FLAC__METADATA_SIMPLE_ITERATOR_STATUS_BAD_METADATA, FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR, FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR,
  FLAC__METADATA_SIMPLE_ITERATOR_STATUS_WRITE_ERROR, FLAC__METADATA_SIMPLE_ITERATOR_STATUS_RENAME_ERROR, FLAC__METADATA_SIMPLE_ITERATOR_STATUS_UNLINK_ERROR, FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR,
  FLAC__METADATA_SIMPLE_ITERATOR_STATUS_INTERNAL_ERROR
}
 

Functions

FLAC_API FLAC__Metadata_SimpleIteratorFLAC__metadata_simple_iterator_new (void)
 
FLAC_API void FLAC__metadata_simple_iterator_delete (FLAC__Metadata_SimpleIterator *iterator)
 
FLAC_API FLAC__Metadata_SimpleIteratorStatus FLAC__metadata_simple_iterator_status (FLAC__Metadata_SimpleIterator *iterator)
 
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)
 
FLAC_API FLAC__bool FLAC__metadata_simple_iterator_is_writable (const FLAC__Metadata_SimpleIterator *iterator)
 
FLAC_API FLAC__bool FLAC__metadata_simple_iterator_next (FLAC__Metadata_SimpleIterator *iterator)
 
FLAC_API FLAC__bool FLAC__metadata_simple_iterator_prev (FLAC__Metadata_SimpleIterator *iterator)
 
FLAC_API FLAC__bool FLAC__metadata_simple_iterator_is_last (const FLAC__Metadata_SimpleIterator *iterator)
 
FLAC_API off_t FLAC__metadata_simple_iterator_get_block_offset (const FLAC__Metadata_SimpleIterator *iterator)
 
FLAC_API FLAC__MetadataType FLAC__metadata_simple_iterator_get_block_type (const FLAC__Metadata_SimpleIterator *iterator)
 
FLAC_API unsigned FLAC__metadata_simple_iterator_get_block_length (const FLAC__Metadata_SimpleIterator *iterator)
 
FLAC_API FLAC__bool FLAC__metadata_simple_iterator_get_application_id (FLAC__Metadata_SimpleIterator *iterator, FLAC__byte *id)
 
FLAC_API FLAC__StreamMetadataFLAC__metadata_simple_iterator_get_block (FLAC__Metadata_SimpleIterator *iterator)
 
FLAC_API FLAC__bool FLAC__metadata_simple_iterator_set_block (FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block, FLAC__bool use_padding)
 
FLAC_API FLAC__bool FLAC__metadata_simple_iterator_insert_block_after (FLAC__Metadata_SimpleIterator *iterator, FLAC__StreamMetadata *block, FLAC__bool use_padding)
 
FLAC_API FLAC__bool FLAC__metadata_simple_iterator_delete_block (FLAC__Metadata_SimpleIterator *iterator, FLAC__bool use_padding)
 

Variables

FLAC_API const char *const FLAC__Metadata_SimpleIteratorStatusString []
 

Detailed Description

The level 1 interface provides read-write access to FLAC file metadata and operates directly on the FLAC file.

The general usage of this interface is:

Note
The FLAC file remains open the whole time between FLAC__metadata_simple_iterator_init() and FLAC__metadata_simple_iterator_delete(), so make sure you are not altering the file during this time.
Do not modify the is_last, length, or type fields of returned FLAC__StreamMetadata objects. These are managed automatically.
If any of the modification functions (FLAC__metadata_simple_iterator_set_block(), FLAC__metadata_simple_iterator_delete_block(), FLAC__metadata_simple_iterator_insert_block_after(), etc.) return false, you should delete the iterator as it may no longer be valid.

Typedef Documentation

◆ FLAC__Metadata_SimpleIterator

The opaque structure definition for the level 1 iterator type. See the metadata level 1 module for a detailed description.

Enumeration Type Documentation

◆ FLAC__Metadata_SimpleIteratorStatus

Status type for FLAC__Metadata_SimpleIterator.

The iterator's current status can be obtained by calling FLAC__metadata_simple_iterator_status().

Enumerator
FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK 

The iterator is in the normal OK state

FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ILLEGAL_INPUT 

The data passed into a function violated the function's usage criteria

FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ERROR_OPENING_FILE 

The iterator could not open the target file

FLAC__METADATA_SIMPLE_ITERATOR_STATUS_NOT_A_FLAC_FILE 

The iterator could not find the FLAC signature at the start of the file

FLAC__METADATA_SIMPLE_ITERATOR_STATUS_NOT_WRITABLE 

The iterator tried to write to a file that was not writable

FLAC__METADATA_SIMPLE_ITERATOR_STATUS_BAD_METADATA 

The iterator encountered input that does not conform to the FLAC metadata specification

FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR 

The iterator encountered an error while reading the FLAC file

FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR 

The iterator encountered an error while seeking in the FLAC file

FLAC__METADATA_SIMPLE_ITERATOR_STATUS_WRITE_ERROR 

The iterator encountered an error while writing the FLAC file

FLAC__METADATA_SIMPLE_ITERATOR_STATUS_RENAME_ERROR 

The iterator encountered an error renaming the FLAC file

FLAC__METADATA_SIMPLE_ITERATOR_STATUS_UNLINK_ERROR 

The iterator encountered an error removing the temporary file

FLAC__METADATA_SIMPLE_ITERATOR_STATUS_MEMORY_ALLOCATION_ERROR 

Memory allocation failed

FLAC__METADATA_SIMPLE_ITERATOR_STATUS_INTERNAL_ERROR 

The caller violated an assertion or an unexpected error occurred

Function Documentation

◆ FLAC__metadata_simple_iterator_delete()

FLAC_API void FLAC__metadata_simple_iterator_delete ( FLAC__Metadata_SimpleIterator iterator)

Free an iterator instance. Deletes the object pointed to by iterator.

Parameters
iteratorA pointer to an existing iterator.
iterator != NULL

◆ FLAC__metadata_simple_iterator_delete_block()

FLAC_API FLAC__bool FLAC__metadata_simple_iterator_delete_block ( FLAC__Metadata_SimpleIterator iterator,
FLAC__bool  use_padding 
)

Deletes the block at the current position. This will cause the entire FLAC file to be rewritten, unless use_padding is true, in which case the block will be replaced by an equal-sized PADDING block. The iterator will be left pointing to the block before the one just deleted.

You may not delete the STREAMINFO block.

Parameters
iteratorA pointer to an existing initialized iterator.
use_paddingSee above.
iterator != NULL
iterator has been successfully initialized with FLAC__metadata_simple_iterator_init()
Return values
FLAC__booltrue if successful, else false.

◆ FLAC__metadata_simple_iterator_get_application_id()

FLAC_API FLAC__bool FLAC__metadata_simple_iterator_get_application_id ( FLAC__Metadata_SimpleIterator iterator,
FLAC__byte id 
)

Get the application ID of the APPLICATION block at the current position. This avoids reading the actual block data which can save time for large blocks.

Parameters
iteratorA pointer to an existing initialized iterator.
idA pointer to a buffer of at least 4 bytes where the ID will be stored.
iterator != NULL
id != NULL
iterator has been successfully initialized with FLAC__metadata_simple_iterator_init()
Return values
FLAC__booltrue if the ID was successfully read, else false, in which case you should check FLAC__metadata_simple_iterator_status() to find out why. If the status is FLAC__METADATA_SIMPLE_ITERATOR_STATUS_ILLEGAL_INPUT, then the current metadata block is not an APPLICATION block. Otherwise if the status is FLAC__METADATA_SIMPLE_ITERATOR_STATUS_READ_ERROR or FLAC__METADATA_SIMPLE_ITERATOR_STATUS_SEEK_ERROR, an I/O error occurred and the iterator can no longer be used.

◆ FLAC__metadata_simple_iterator_get_block()

FLAC_API FLAC__StreamMetadata* FLAC__metadata_simple_iterator_get_block ( FLAC__Metadata_SimpleIterator iterator)

Get the metadata block at the current position. You can modify the block but must use FLAC__metadata_simple_iterator_set_block() to write it back to the FLAC file.

You must call FLAC__metadata_object_delete() on the returned object when you are finished with it.

Parameters
iteratorA pointer to an existing initialized iterator.
iterator != NULL
iterator has been successfully initialized with FLAC__metadata_simple_iterator_init()
Return values
FLAC__StreamMetadata*The current metadata block, or NULL if there was a memory allocation error.

◆ FLAC__metadata_simple_iterator_get_block_length()

FLAC_API unsigned FLAC__metadata_simple_iterator_get_block_length ( const FLAC__Metadata_SimpleIterator iterator)

Get the length of the metadata block at the current position. This avoids reading the actual block data which can save time for large blocks.

Parameters
iteratorA pointer to an existing initialized iterator.
iterator != NULL
iterator has been successfully initialized with FLAC__metadata_simple_iterator_init()
Return values
unsignedThe length of the metadata block at the current iterator position. The is same length as that in the metadata block header, i.e. the length of the metadata body that follows the header.

◆ FLAC__metadata_simple_iterator_get_block_offset()

FLAC_API off_t FLAC__metadata_simple_iterator_get_block_offset ( const FLAC__Metadata_SimpleIterator iterator)

Get the offset of the metadata block at the current position. This avoids reading the actual block data which can save time for large blocks.

Parameters
iteratorA pointer to an existing initialized iterator.
iterator != NULL
iterator has been successfully initialized with FLAC__metadata_simple_iterator_init()
Return values
off_tThe offset of the metadata block at the current iterator position. This is the byte offset relative to the beginning of the file of the current metadata block's header.

◆ FLAC__metadata_simple_iterator_get_block_type()

FLAC_API FLAC__MetadataType FLAC__metadata_simple_iterator_get_block_type ( const FLAC__Metadata_SimpleIterator iterator)

Get the type of the metadata block at the current position. This avoids reading the actual block data which can save time for large blocks.

Parameters
iteratorA pointer to an existing initialized iterator.
iterator != NULL
iterator has been successfully initialized with FLAC__metadata_simple_iterator_init()
Return values
FLAC__MetadataTypeThe type of the metadata block at the current iterator position.

◆ FLAC__metadata_simple_iterator_init()

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 
)

Initialize the iterator to point to the first metadata block in the given FLAC file.

Parameters
iteratorA pointer to an existing iterator.
filenameThe path to the FLAC file.
read_onlyIf true, the FLAC file will be opened in read-only mode; if false, the FLAC file will be opened for edit even if no edits are performed.
preserve_file_statsIf true, the owner and modification time will be preserved even if the FLAC file is written to.
iterator != NULL
filename != NULL
Return values
FLAC__boolfalse if a memory allocation error occurs, the file can't be opened, or another error occurs, else true.

◆ FLAC__metadata_simple_iterator_insert_block_after()

FLAC_API FLAC__bool FLAC__metadata_simple_iterator_insert_block_after ( FLAC__Metadata_SimpleIterator iterator,
FLAC__StreamMetadata block,
FLAC__bool  use_padding 
)

This is similar to FLAC__metadata_simple_iterator_set_block() except that instead of writing over an existing block, it appends a block after the existing block. use_padding is again used to tell the function to try an expand into following padding in an attempt to avoid rewriting the entire file.

This function will fail and return false if given a STREAMINFO block.

After writing the block, the iterator will be pointing to the new block.

Parameters
iteratorA pointer to an existing initialized iterator.
blockThe block to set.
use_paddingSee above.
iterator != NULL
iterator has been successfully initialized with FLAC__metadata_simple_iterator_init()
Return values
FLAC__booltrue if successful, else false.

◆ FLAC__metadata_simple_iterator_is_last()

FLAC_API FLAC__bool FLAC__metadata_simple_iterator_is_last ( const FLAC__Metadata_SimpleIterator iterator)

Returns a flag telling if the current metadata block is the last.

Parameters
iteratorA pointer to an existing initialized iterator.
iterator != NULL
iterator has been successfully initialized with FLAC__metadata_simple_iterator_init()
Return values
FLAC__booltrue if the current metadata block is the last in the file, else false.

◆ FLAC__metadata_simple_iterator_is_writable()

FLAC_API FLAC__bool FLAC__metadata_simple_iterator_is_writable ( const FLAC__Metadata_SimpleIterator iterator)

Returns true if the FLAC file is writable. If false, calls to FLAC__metadata_simple_iterator_set_block() and FLAC__metadata_simple_iterator_insert_block_after() will fail.

Parameters
iteratorA pointer to an existing iterator.
iterator != NULL
Return values
FLAC__boolSee above.

◆ FLAC__metadata_simple_iterator_new()

FLAC_API FLAC__Metadata_SimpleIterator* FLAC__metadata_simple_iterator_new ( void  )

Create a new iterator instance.

Return values
FLAC__Metadata_SimpleIterator*NULL if there was an error allocating memory, else the new instance.

◆ FLAC__metadata_simple_iterator_next()

FLAC_API FLAC__bool FLAC__metadata_simple_iterator_next ( FLAC__Metadata_SimpleIterator iterator)

Moves the iterator forward one metadata block, returning false if already at the end.

Parameters
iteratorA pointer to an existing initialized iterator.
iterator != NULL
iterator has been successfully initialized with FLAC__metadata_simple_iterator_init()
Return values
FLAC__boolfalse if already at the last metadata block of the chain, else true.

◆ FLAC__metadata_simple_iterator_prev()

FLAC_API FLAC__bool FLAC__metadata_simple_iterator_prev ( FLAC__Metadata_SimpleIterator iterator)

Moves the iterator backward one metadata block, returning false if already at the beginning.

Parameters
iteratorA pointer to an existing initialized iterator.
iterator != NULL
iterator has been successfully initialized with FLAC__metadata_simple_iterator_init()
Return values
FLAC__boolfalse if already at the first metadata block of the chain, else true.

◆ FLAC__metadata_simple_iterator_set_block()

FLAC_API FLAC__bool FLAC__metadata_simple_iterator_set_block ( FLAC__Metadata_SimpleIterator iterator,
FLAC__StreamMetadata block,
FLAC__bool  use_padding 
)

Write a block back to the FLAC file. This function tries to be as efficient as possible; how the block is actually written is shown by the following:

Existing block is a STREAMINFO block and the new block is a STREAMINFO block: the new block is written in place. Make sure you know what you're doing when changing the values of a STREAMINFO block.

Existing block is a STREAMINFO block and the new block is a not a STREAMINFO block: this is an error since the first block must be a STREAMINFO block. Returns false without altering the file.

Existing block is not a STREAMINFO block and the new block is a STREAMINFO block: this is an error since there may be only one STREAMINFO block. Returns false without altering the file.

Existing block and new block are the same length: the existing block will be replaced by the new block, written in place.

Existing block is longer than new block: if use_padding is true, the existing block will be overwritten in place with the new block followed by a PADDING block, if possible, to make the total size the same as the existing block. Remember that a padding block requires at least four bytes so if the difference in size between the new block and existing block is less than that, the entire file will have to be rewritten, using the new block's exact size. If use_padding is false, the entire file will be rewritten, replacing the existing block by the new block.

Existing block is shorter than new block: if use_padding is true, the function will try and expand the new block into the following PADDING block, if it exists and doing so won't shrink the PADDING block to less than 4 bytes. If there is no following PADDING block, or it will shrink to less than 4 bytes, or use_padding is false, the entire file is rewritten, replacing the existing block with the new block. Note that in this case any following PADDING block is preserved as is.

After writing the block, the iterator will remain in the same place, i.e. pointing to the new block.

Parameters
iteratorA pointer to an existing initialized iterator.
blockThe block to set.
use_paddingSee above.
iterator != NULL
iterator has been successfully initialized with FLAC__metadata_simple_iterator_init()
Return values
FLAC__booltrue if successful, else false.

◆ FLAC__metadata_simple_iterator_status()

FLAC_API FLAC__Metadata_SimpleIteratorStatus FLAC__metadata_simple_iterator_status ( FLAC__Metadata_SimpleIterator iterator)

Get the current status of the iterator. Call this after a function returns false to get the reason for the error. Also resets the status to FLAC__METADATA_SIMPLE_ITERATOR_STATUS_OK.

Parameters
iteratorA pointer to an existing iterator.
iterator != NULL
Return values
FLAC__Metadata_SimpleIteratorStatusThe current status of the iterator.

Variable Documentation

◆ FLAC__Metadata_SimpleIteratorStatusString

FLAC_API const char* const FLAC__Metadata_SimpleIteratorStatusString[]

Maps a FLAC__Metadata_SimpleIteratorStatus to a C string.

Using a FLAC__Metadata_SimpleIteratorStatus as the index to this array will give the string equivalent. The contents should not be modified.