From 53f4c8493065b902e989b7d5eee8f931cf009775 Mon Sep 17 00:00:00 2001 From: waker Date: Thu, 6 Oct 2011 18:32:51 +0200 Subject: flac: ignore files with samplerate<=0; don't calculate bitrate on streams with unknown length --- plugins/flac/flac.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'plugins/flac') diff --git a/plugins/flac/flac.c b/plugins/flac/flac.c index 440759e1..a577ad30 100644 --- a/plugins/flac/flac.c +++ b/plugins/flac/flac.c @@ -704,6 +704,11 @@ cflac_insert (ddb_playlist_t *plt, DB_playItem_t *after, const char *fname) { } FLAC__stream_decoder_delete(decoder); decoder = NULL; + + if (info.info.fmt.samplerate <= 0) { + goto cflac_insert_fail; + } + deadbeef->pl_add_meta (it, ":FILETYPE", isogg ? "OggFLAC" : "FLAC"); char s[100]; @@ -716,8 +721,10 @@ cflac_insert (ddb_playlist_t *plt, DB_playItem_t *after, const char *fname) { deadbeef->pl_add_meta (it, ":BPS", s); snprintf (s, sizeof (s), "%d", info.info.fmt.samplerate); deadbeef->pl_add_meta (it, ":SAMPLERATE", s); - snprintf (s, sizeof (s), "%d", (int)roundf((fsize-info.tagsize) / deadbeef->pl_get_item_duration (it) * 8 / 1000)); - deadbeef->pl_add_meta (it, ":BITRATE", s); + if ( deadbeef->pl_get_item_duration (it) > 0) { + snprintf (s, sizeof (s), "%d", (int)roundf((fsize-info.tagsize) / deadbeef->pl_get_item_duration (it) * 8 / 1000)); + deadbeef->pl_add_meta (it, ":BITRATE", s); + } // try embedded cue const char *cuesheet = deadbeef->pl_find_meta (it, "cuesheet"); -- cgit v1.2.3