From 3f1afeeb4050773598e9222c834e33d84f671aa7 Mon Sep 17 00:00:00 2001 From: Justin Maggard Date: Sat, 4 Apr 2009 01:13:14 +0000 Subject: [PATCH] * Log which file has extra-long vorbis comments. * Gather duration and bitrate information from FLAC files. --- metadata.c | 2 +- tagutils/tagutils-flc.c | 10 ++++++++++ tagutils/tagutils-misc.c | 4 ++-- tagutils/tagutils.c | 6 +++--- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/metadata.c b/metadata.c index 97b4deb..f3e1d47 100644 --- a/metadata.c +++ b/metadata.c @@ -611,7 +611,7 @@ GetVideoMetadata(const char * path, char * name) (ctx->streams[audio_stream]->codec->codec_id < CODEC_ID_ADPCM_IMA_QT) ) audio_profile = PCM; else - DPRINTF(E_DEBUG, L_METADATA, "Unhandled audio codec [%X]\n", ctx->streams[audio_stream]->codec->codec_id); + DPRINTF(E_DEBUG, L_METADATA, "Unhandled audio codec [0x%X]\n", ctx->streams[audio_stream]->codec->codec_id); break; } asprintf(&m.frequency, "%u", ctx->streams[audio_stream]->codec->sample_rate); diff --git a/tagutils/tagutils-flc.c b/tagutils/tagutils-flc.c index d6b2dff..61f8927 100644 --- a/tagutils/tagutils-flc.c +++ b/tagutils/tagutils-flc.c @@ -27,6 +27,7 @@ _get_flctags(char *filename, struct song_metadata *psong) FLAC__Metadata_SimpleIterator *iterator = 0; FLAC__StreamMetadata *block; int block_number; + unsigned int sec, ms; int i; int err = 0; @@ -54,6 +55,15 @@ _get_flctags(char *filename, struct song_metadata *psong) switch(block->type) { case FLAC__METADATA_TYPE_STREAMINFO: + sec = (unsigned int)(block->data.stream_info.total_samples / + block->data.stream_info.sample_rate); + ms = (unsigned int)(((block->data.stream_info.total_samples % + block->data.stream_info.sample_rate) * 1000) / + block->data.stream_info.sample_rate); + if ((sec == 0) && (ms == 0)) + break; /* Info is crap, escape div-by-zero. */ + psong->song_length = (sec * 1000) + ms; + psong->bitrate = (((uint64_t)(psong->file_size) * 1000) / (psong->song_length / 8)); psong->samplerate = block->data.stream_info.sample_rate; psong->channels = block->data.stream_info.channels; break; diff --git a/tagutils/tagutils-misc.c b/tagutils/tagutils-misc.c index eb91ff6..b29b2ac 100644 --- a/tagutils/tagutils-misc.c +++ b/tagutils/tagutils-misc.c @@ -174,11 +174,11 @@ _get_utf8_text(const id3_ucs4_t* native_text) static void vc_scan(struct song_metadata *psong, const char *comment, const size_t length) { - char strbuf[1024]; + char strbuf[2048]; if(length > (sizeof(strbuf) - 1)) { - DPRINTF(E_ERROR, L_SCANNER, "Vorbis Comment too long\n"); + DPRINTF(E_WARN, L_SCANNER, "Vorbis Comment too long [%s]\n", psong->path); return; } strncpy(strbuf, comment, length); diff --git a/tagutils/tagutils.c b/tagutils/tagutils.c index e5783b9..bb93099 100644 --- a/tagutils/tagutils.c +++ b/tagutils/tagutils.c @@ -263,9 +263,6 @@ readtags(char *path, struct song_metadata *psong, struct stat *stat, char *lang, fname = strrchr(psong->path, '/'); psong->basename = fname ? fname + 1 : psong->path; - // get tag - found |= _get_tags(path, psong); - if(stat) { if(!psong->time_modified) @@ -273,6 +270,9 @@ readtags(char *path, struct song_metadata *psong, struct stat *stat, char *lang, psong->file_size = stat->st_size; } + // get tag + found |= _get_tags(path, psong); + // get fileinfo found |= _get_fileinfo(path, psong);