decoder/flac: eliminate the obsolete "track number" code
This has been deprecated by the "embcue" playlist plugin.
This commit is contained in:
parent
ade0483641
commit
9c1d1ef268
@ -133,7 +133,7 @@ void flac_metadata_common_cb(const FLAC__StreamMetadata * block,
|
|||||||
mixramp_start, mixramp_end);
|
mixramp_start, mixramp_end);
|
||||||
|
|
||||||
if (data->tag != nullptr)
|
if (data->tag != nullptr)
|
||||||
flac_vorbis_comments_to_tag(data->tag, nullptr,
|
flac_vorbis_comments_to_tag(data->tag,
|
||||||
&block->data.vorbis_comment);
|
&block->data.vorbis_comment);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -176,7 +176,7 @@ static bool
|
|||||||
flac_scan_file(const char *file,
|
flac_scan_file(const char *file,
|
||||||
const struct tag_handler *handler, void *handler_ctx)
|
const struct tag_handler *handler, void *handler_ctx)
|
||||||
{
|
{
|
||||||
return flac_scan_file2(file, nullptr, handler, handler_ctx);
|
return flac_scan_file2(file, handler, handler_ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -382,8 +382,7 @@ oggflac_scan_file(const char *file,
|
|||||||
if (!(block = FLAC__metadata_iterator_get_block(it)))
|
if (!(block = FLAC__metadata_iterator_get_block(it)))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
flac_scan_metadata(nullptr, block,
|
flac_scan_metadata(block, handler, handler_ctx);
|
||||||
handler, handler_ctx);
|
|
||||||
} while (FLAC__metadata_iterator_next(it));
|
} while (FLAC__metadata_iterator_next(it));
|
||||||
FLAC__metadata_iterator_delete(it);
|
FLAC__metadata_iterator_delete(it);
|
||||||
|
|
||||||
|
@ -133,30 +133,15 @@ flac_parse_mixramp(char **mixramp_start, char **mixramp_end,
|
|||||||
*/
|
*/
|
||||||
static const char *
|
static const char *
|
||||||
flac_comment_value(const FLAC__StreamMetadata_VorbisComment_Entry *entry,
|
flac_comment_value(const FLAC__StreamMetadata_VorbisComment_Entry *entry,
|
||||||
const char *name, const char *char_tnum, size_t *length_r)
|
const char *name, size_t *length_r)
|
||||||
{
|
{
|
||||||
size_t name_length = strlen(name);
|
size_t name_length = strlen(name);
|
||||||
size_t char_tnum_length = 0;
|
|
||||||
const char *comment = (const char*)entry->entry;
|
const char *comment = (const char*)entry->entry;
|
||||||
|
|
||||||
if (entry->length <= name_length ||
|
if (entry->length <= name_length ||
|
||||||
g_ascii_strncasecmp(comment, name, name_length) != 0)
|
g_ascii_strncasecmp(comment, name, name_length) != 0)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
if (char_tnum != nullptr) {
|
|
||||||
char_tnum_length = strlen(char_tnum);
|
|
||||||
if (entry->length > name_length + char_tnum_length + 2 &&
|
|
||||||
comment[name_length] == '[' &&
|
|
||||||
g_ascii_strncasecmp(comment + name_length + 1,
|
|
||||||
char_tnum, char_tnum_length) == 0 &&
|
|
||||||
comment[name_length + char_tnum_length + 1] == ']')
|
|
||||||
name_length = name_length + char_tnum_length + 2;
|
|
||||||
else if (entry->length > name_length + char_tnum_length &&
|
|
||||||
g_ascii_strncasecmp(comment + name_length,
|
|
||||||
char_tnum, char_tnum_length) == 0)
|
|
||||||
name_length = name_length + char_tnum_length;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (comment[name_length] == '=') {
|
if (comment[name_length] == '=') {
|
||||||
*length_r = entry->length - name_length - 1;
|
*length_r = entry->length - name_length - 1;
|
||||||
return comment + name_length + 1;
|
return comment + name_length + 1;
|
||||||
@ -172,13 +157,12 @@ flac_comment_value(const FLAC__StreamMetadata_VorbisComment_Entry *entry,
|
|||||||
static bool
|
static bool
|
||||||
flac_copy_comment(const FLAC__StreamMetadata_VorbisComment_Entry *entry,
|
flac_copy_comment(const FLAC__StreamMetadata_VorbisComment_Entry *entry,
|
||||||
const char *name, enum tag_type tag_type,
|
const char *name, enum tag_type tag_type,
|
||||||
const char *char_tnum,
|
|
||||||
const struct tag_handler *handler, void *handler_ctx)
|
const struct tag_handler *handler, void *handler_ctx)
|
||||||
{
|
{
|
||||||
const char *value;
|
const char *value;
|
||||||
size_t value_length;
|
size_t value_length;
|
||||||
|
|
||||||
value = flac_comment_value(entry, name, char_tnum, &value_length);
|
value = flac_comment_value(entry, name, &value_length);
|
||||||
if (value != nullptr) {
|
if (value != nullptr) {
|
||||||
char *p = g_strndup(value, value_length);
|
char *p = g_strndup(value, value_length);
|
||||||
tag_handler_invoke_tag(handler, handler_ctx, tag_type, p);
|
tag_handler_invoke_tag(handler, handler_ctx, tag_type, p);
|
||||||
@ -190,8 +174,7 @@ flac_copy_comment(const FLAC__StreamMetadata_VorbisComment_Entry *entry,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
flac_scan_comment(const char *char_tnum,
|
flac_scan_comment(const FLAC__StreamMetadata_VorbisComment_Entry *entry,
|
||||||
const FLAC__StreamMetadata_VorbisComment_Entry *entry,
|
|
||||||
const struct tag_handler *handler, void *handler_ctx)
|
const struct tag_handler *handler, void *handler_ctx)
|
||||||
{
|
{
|
||||||
if (handler->pair != nullptr) {
|
if (handler->pair != nullptr) {
|
||||||
@ -208,36 +191,33 @@ flac_scan_comment(const char *char_tnum,
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const struct tag_table *i = xiph_tags; i->name != nullptr; ++i)
|
for (const struct tag_table *i = xiph_tags; i->name != nullptr; ++i)
|
||||||
if (flac_copy_comment(entry, i->name, i->type, char_tnum,
|
if (flac_copy_comment(entry, i->name, i->type,
|
||||||
handler, handler_ctx))
|
handler, handler_ctx))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; ++i)
|
for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; ++i)
|
||||||
if (flac_copy_comment(entry,
|
if (flac_copy_comment(entry,
|
||||||
tag_item_names[i], (enum tag_type)i,
|
tag_item_names[i], (enum tag_type)i,
|
||||||
char_tnum,
|
|
||||||
handler, handler_ctx))
|
handler, handler_ctx))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
flac_scan_comments(const char *char_tnum,
|
flac_scan_comments(const FLAC__StreamMetadata_VorbisComment *comment,
|
||||||
const FLAC__StreamMetadata_VorbisComment *comment,
|
|
||||||
const struct tag_handler *handler, void *handler_ctx)
|
const struct tag_handler *handler, void *handler_ctx)
|
||||||
{
|
{
|
||||||
for (unsigned i = 0; i < comment->num_comments; ++i)
|
for (unsigned i = 0; i < comment->num_comments; ++i)
|
||||||
flac_scan_comment(char_tnum, &comment->comments[i],
|
flac_scan_comment(&comment->comments[i],
|
||||||
handler, handler_ctx);
|
handler, handler_ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
flac_scan_metadata(const char *track,
|
flac_scan_metadata(const FLAC__StreamMetadata *block,
|
||||||
const FLAC__StreamMetadata *block,
|
|
||||||
const struct tag_handler *handler, void *handler_ctx)
|
const struct tag_handler *handler, void *handler_ctx)
|
||||||
{
|
{
|
||||||
switch (block->type) {
|
switch (block->type) {
|
||||||
case FLAC__METADATA_TYPE_VORBIS_COMMENT:
|
case FLAC__METADATA_TYPE_VORBIS_COMMENT:
|
||||||
flac_scan_comments(track, &block->data.vorbis_comment,
|
flac_scan_comments(&block->data.vorbis_comment,
|
||||||
handler, handler_ctx);
|
handler, handler_ctx);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -253,15 +233,14 @@ flac_scan_metadata(const char *track,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
flac_vorbis_comments_to_tag(struct tag *tag, const char *char_tnum,
|
flac_vorbis_comments_to_tag(struct tag *tag,
|
||||||
const FLAC__StreamMetadata_VorbisComment *comment)
|
const FLAC__StreamMetadata_VorbisComment *comment)
|
||||||
{
|
{
|
||||||
flac_scan_comments(char_tnum, comment,
|
flac_scan_comments(comment, &add_tag_handler, tag);
|
||||||
&add_tag_handler, tag);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
flac_scan_file2(const char *file, const char *char_tnum,
|
flac_scan_file2(const char *file,
|
||||||
const struct tag_handler *handler, void *handler_ctx)
|
const struct tag_handler *handler, void *handler_ctx)
|
||||||
{
|
{
|
||||||
FLAC__Metadata_SimpleIterator *it;
|
FLAC__Metadata_SimpleIterator *it;
|
||||||
@ -298,7 +277,7 @@ flac_scan_file2(const char *file, const char *char_tnum,
|
|||||||
if (!block)
|
if (!block)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
flac_scan_metadata(char_tnum, block, handler, handler_ctx);
|
flac_scan_metadata(block, handler, handler_ctx);
|
||||||
FLAC__metadata_object_delete(block);
|
FLAC__metadata_object_delete(block);
|
||||||
} while (FLAC__metadata_simple_iterator_next(it));
|
} while (FLAC__metadata_simple_iterator_next(it));
|
||||||
|
|
||||||
|
@ -46,16 +46,15 @@ flac_parse_mixramp(char **mixramp_start, char **mixramp_end,
|
|||||||
const FLAC__StreamMetadata *block);
|
const FLAC__StreamMetadata *block);
|
||||||
|
|
||||||
void
|
void
|
||||||
flac_vorbis_comments_to_tag(struct tag *tag, const char *char_tnum,
|
flac_vorbis_comments_to_tag(struct tag *tag,
|
||||||
const FLAC__StreamMetadata_VorbisComment *comment);
|
const FLAC__StreamMetadata_VorbisComment *comment);
|
||||||
|
|
||||||
void
|
void
|
||||||
flac_scan_metadata(const char *track,
|
flac_scan_metadata(const FLAC__StreamMetadata *block,
|
||||||
const FLAC__StreamMetadata *block,
|
|
||||||
const struct tag_handler *handler, void *handler_ctx);
|
const struct tag_handler *handler, void *handler_ctx);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
flac_scan_file2(const char *file, const char *char_tnum,
|
flac_scan_file2(const char *file,
|
||||||
const struct tag_handler *handler, void *handler_ctx);
|
const struct tag_handler *handler, void *handler_ctx);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user