decoder/flac: merged some code into flac_tag_apply_metadata()

This commit is contained in:
Max Kellermann 2009-11-11 00:05:14 +01:00
parent 305de100a7
commit 884be8e2b3
4 changed files with 27 additions and 25 deletions

View File

@ -197,7 +197,7 @@ flac_parse_comment(struct tag *tag, const char *char_tnum,
return;
}
void
static void
flac_vorbis_comments_to_tag(struct tag *tag, const char *char_tnum,
const FLAC__StreamMetadata_VorbisComment *comment)
{
@ -205,6 +205,25 @@ flac_vorbis_comments_to_tag(struct tag *tag, const char *char_tnum,
flac_parse_comment(tag, char_tnum, &comment->comments[i]);
}
void
flac_tag_apply_metadata(struct tag *tag, const char *track,
const FLAC__StreamMetadata *block)
{
switch (block->type) {
case FLAC__METADATA_TYPE_VORBIS_COMMENT:
flac_vorbis_comments_to_tag(tag, track,
&block->data.vorbis_comment);
break;
case FLAC__METADATA_TYPE_STREAMINFO:
tag->time = flac_duration(&block->data.stream_info);
break;
default:
break;
}
}
void flac_metadata_common_cb(const FLAC__StreamMetadata * block,
struct flac_data *data)
{

View File

@ -182,8 +182,8 @@ void flac_error_common_cb(const char *plugin,
struct flac_data *data);
void
flac_vorbis_comments_to_tag(struct tag *tag, const char *char_tnum,
const FLAC__StreamMetadata_VorbisComment *comment);
flac_tag_apply_metadata(struct tag *tag, const char *track,
const FLAC__StreamMetadata *block);
FLAC__StreamDecoderWriteStatus
flac_common_write(struct flac_data *data, const FLAC__Frame * frame,

View File

@ -268,12 +268,8 @@ flac_tag_load(const char *file, const char *char_tnum)
block = FLAC__metadata_simple_iterator_get_block(it);
if (!block)
break;
if (block->type == FLAC__METADATA_TYPE_VORBIS_COMMENT) {
flac_vorbis_comments_to_tag(tag, char_tnum,
&block->data.vorbis_comment);
} else if (block->type == FLAC__METADATA_TYPE_STREAMINFO) {
tag->time = flac_duration(&block->data.stream_info);
}
flac_tag_apply_metadata(tag, char_tnum, block);
FLAC__metadata_object_delete(block);
} while (FLAC__metadata_simple_iterator_next(it));
@ -848,12 +844,8 @@ oggflac_tag_dup(const char *file)
do {
if (!(block = FLAC__metadata_iterator_get_block(it)))
break;
if (block->type == FLAC__METADATA_TYPE_VORBIS_COMMENT) {
flac_vorbis_comments_to_tag(ret, NULL,
&block->data.vorbis_comment);
} else if (block->type == FLAC__METADATA_TYPE_STREAMINFO) {
ret->time = flac_duration(&block->data.stream_info);
}
flac_tag_apply_metadata(ret, NULL, block);
} while (FLAC__metadata_iterator_next(it));
FLAC__metadata_iterator_delete(it);

View File

@ -170,16 +170,7 @@ static void of_metadata_dup_cb(G_GNUC_UNUSED const OggFLAC__SeekableStreamDecode
assert(data->tag != NULL);
switch (block->type) {
case FLAC__METADATA_TYPE_STREAMINFO:
data->tag->time = flac_duration(&block->data.stream_info);
return;
case FLAC__METADATA_TYPE_VORBIS_COMMENT:
flac_vorbis_comments_to_tag(data->tag, NULL,
&block->data.vorbis_comment);
default:
break;
}
flac_tag_apply_metadata(data->tag, NULL, block);
}
/* used by decode */