Add level 0 Ogg reading capability to tests and docs

This commit is contained in:
Martijn van Beurden 2024-07-17 08:19:22 +02:00
parent f94d34ffba
commit 8c244b8389
2 changed files with 42 additions and 30 deletions

View File

@ -62,9 +62,9 @@
* This module provides functions for creating and manipulating FLAC
* metadata blocks in memory, and three progressively more powerful
* interfaces for traversing and editing metadata in native FLAC files.
* Note that currently only the Chain interface (level 2) supports Ogg
* FLAC files, and it is read-only i.e. no writing back changed
* metadata to file.
* Note that currently only the Chain interface (level 2) and some
* functions in level 0 supports Ogg FLAC files, and they are
* read-only i.e. no writing back changed metadata to file.
*
* There are three metadata interfaces of increasing complexity:
*
@ -144,10 +144,11 @@ extern "C" {
* \{
*/
/** Read the STREAMINFO metadata block of the given FLAC file. This function
* will try to skip any ID3v2 tag at the head of the file.
/** Read the STREAMINFO metadata block of the given FLAC or Ogg FLAC
* file. This function will try to skip any ID3v2 tag at the head
* of the file.
*
* \param filename The path to the FLAC file to read.
* \param filename The path to the FLAC or Ogg FLAC file to read.
* \param streaminfo A pointer to space for the STREAMINFO block. Since
* FLAC__StreamMetadata is a simple structure with no
* memory allocation involved, you pass the address of
@ -163,10 +164,11 @@ extern "C" {
*/
FLAC_API FLAC__bool FLAC__metadata_get_streaminfo(const char *filename, FLAC__StreamMetadata *streaminfo);
/** Read the VORBIS_COMMENT metadata block of the given FLAC file. This
* function will try to skip any ID3v2 tag at the head of the file.
/** Read the VORBIS_COMMENT metadata block of the given FLAC or Ogg FLAC
* file. This function will try to skip any ID3v2 tag at the head
* of the file.
*
* \param filename The path to the FLAC file to read.
* \param filename The path to the FLAC or Ogg FLAC file to read.
* \param tags The address where the returned pointer will be
* stored. The \a tags object must be deleted by
* the caller using FLAC__metadata_object_delete().
@ -182,10 +184,11 @@ FLAC_API FLAC__bool FLAC__metadata_get_streaminfo(const char *filename, FLAC__St
*/
FLAC_API FLAC__bool FLAC__metadata_get_tags(const char *filename, FLAC__StreamMetadata **tags);
/** Read the CUESHEET metadata block of the given FLAC file. This
* function will try to skip any ID3v2 tag at the head of the file.
/** Read the CUESHEET metadata block of the given FLAC or Ogg FLAC
* file. This function will try to skip any ID3v2 tag at the head
* of the file.
*
* \param filename The path to the FLAC file to read.
* \param filename The path to the FLAC or Ogg FLAC file to read.
* \param cuesheet The address where the returned pointer will be
* stored. The \a cuesheet object must be deleted by
* the caller using FLAC__metadata_object_delete().
@ -207,7 +210,8 @@ FLAC_API FLAC__bool FLAC__metadata_get_cuesheet(const char *filename, FLAC__Stre
* function takes a number of parameters that act as constraints to
* the search. The PICTURE block with the largest area matching all
* the constraints will be returned, or \a *picture will be set to
* \c NULL if there was no such block.
* \c NULL if there was no such block. This function does not
* currently support reading from Ogg FLAC files.
*
* \param filename The path to the FLAC file to read.
* \param picture The address where the returned pointer will be

View File

@ -693,7 +693,7 @@ static FLAC__bool remove_file_(const char *filename)
return true;
}
static FLAC__bool test_level_0_(void)
static FLAC__bool test_level_0_(FLAC__bool is_ogg)
{
FLAC__StreamMetadata streaminfo;
FLAC__StreamMetadata *tags = 0;
@ -702,15 +702,15 @@ static FLAC__bool test_level_0_(void)
printf("\n\n++++++ testing level 0 interface\n");
if(!generate_file_(/*include_extras=*/true, /*is_ogg=*/false))
if(!generate_file_(/*include_extras=*/true, is_ogg))
return false;
if(!test_file_(/*is_ogg=*/false, decoder_metadata_callback_null_))
if(!test_file_(is_ogg, decoder_metadata_callback_null_))
return false;
printf("testing FLAC__metadata_get_streaminfo()... ");
if(!FLAC__metadata_get_streaminfo(flacfilename(/*is_ogg=*/false), &streaminfo))
if(!FLAC__metadata_get_streaminfo(flacfilename(is_ogg), &streaminfo))
return die_("during FLAC__metadata_get_streaminfo()");
/* check to see if some basic data matches (c.f. generate_file_()) */
@ -729,7 +729,7 @@ static FLAC__bool test_level_0_(void)
printf("testing FLAC__metadata_get_tags()... ");
if(!FLAC__metadata_get_tags(flacfilename(/*is_ogg=*/false), &tags))
if(!FLAC__metadata_get_tags(flacfilename(is_ogg), &tags))
return die_("during FLAC__metadata_get_tags()");
/* check to see if some basic data matches (c.f. generate_file_()) */
@ -742,7 +742,7 @@ static FLAC__bool test_level_0_(void)
printf("testing FLAC__metadata_get_cuesheet()... ");
if(!FLAC__metadata_get_cuesheet(flacfilename(/*is_ogg=*/false), &cuesheet))
if(!FLAC__metadata_get_cuesheet(flacfilename(is_ogg), &cuesheet))
return die_("during FLAC__metadata_get_cuesheet()");
/* check to see if some basic data matches (c.f. generate_file_()) */
@ -752,21 +752,23 @@ static FLAC__bool test_level_0_(void)
printf("OK\n");
FLAC__metadata_object_delete(cuesheet);
if(!is_ogg) {
/* FLAC__metadata_get_picture uses layer 1, which isn't ogg-capable yet */
printf("testing FLAC__metadata_get_picture()... ");
printf("testing FLAC__metadata_get_picture()... ");
if(!FLAC__metadata_get_picture(flacfilename(is_ogg), &picture, /*type=*/(FLAC__StreamMetadata_Picture_Type)(-1), /*mime_type=*/0, /*description=*/0, /*max_width=*/(uint32_t)(-1), /*max_height=*/(uint32_t)(-1), /*max_depth=*/(uint32_t)(-1), /*max_colors=*/(uint32_t)(-1)))
return die_("during FLAC__metadata_get_picture()");
if(!FLAC__metadata_get_picture(flacfilename(/*is_ogg=*/false), &picture, /*type=*/(FLAC__StreamMetadata_Picture_Type)(-1), /*mime_type=*/0, /*description=*/0, /*max_width=*/(uint32_t)(-1), /*max_height=*/(uint32_t)(-1), /*max_depth=*/(uint32_t)(-1), /*max_colors=*/(uint32_t)(-1)))
return die_("during FLAC__metadata_get_picture()");
/* check to see if some basic data matches (c.f. generate_file_()) */
if(picture->data.picture.type != FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER)
return die_("mismatch in picture->data.picture.type");
/* check to see if some basic data matches (c.f. generate_file_()) */
if(picture->data.picture.type != FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER)
return die_("mismatch in picture->data.picture.type");
printf("OK\n");
printf("OK\n");
FLAC__metadata_object_delete(picture);
}
FLAC__metadata_object_delete(picture);
if(!remove_file_(flacfilename(/*is_ogg=*/false)))
if(!remove_file_(flacfilename(is_ogg)))
return false;
return true;
@ -2117,8 +2119,14 @@ FLAC__bool test_metadata_file_manipulation(void)
our_metadata_.num_blocks = 0;
if(!test_level_0_())
if(!test_level_0_(/*is_ogg=*/false))
return false;
if(FLAC_API_SUPPORTS_OGG_FLAC) {
if(!test_level_0_(/*is_ogg=*/true))
return false;
}
if(!test_level_1_())
return false;