aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/decoder/_flac_common.c21
-rw-r--r--src/decoder/_flac_common.h4
-rw-r--r--src/decoder/flac_plugin.c16
-rw-r--r--src/decoder/oggflac_plugin.c11
4 files changed, 27 insertions, 25 deletions
diff --git a/src/decoder/_flac_common.c b/src/decoder/_flac_common.c
index 33cfd9c3c..9b3272cf2 100644
--- a/src/decoder/_flac_common.c
+++ b/src/decoder/_flac_common.c
@@ -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)
{
diff --git a/src/decoder/_flac_common.h b/src/decoder/_flac_common.h
index 363f1ae8a..5f83acc70 100644
--- a/src/decoder/_flac_common.h
+++ b/src/decoder/_flac_common.h
@@ -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,
diff --git a/src/decoder/flac_plugin.c b/src/decoder/flac_plugin.c
index 1694f71fc..ee80d667a 100644
--- a/src/decoder/flac_plugin.c
+++ b/src/decoder/flac_plugin.c
@@ -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);
diff --git a/src/decoder/oggflac_plugin.c b/src/decoder/oggflac_plugin.c
index c139fd114..dff76be51 100644
--- a/src/decoder/oggflac_plugin.c
+++ b/src/decoder/oggflac_plugin.c
@@ -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 */