summaryrefslogtreecommitdiff
path: root/plugins/flac
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2011-10-06 18:32:51 +0200
committerGravatar waker <wakeroid@gmail.com>2011-10-06 18:32:51 +0200
commit53f4c8493065b902e989b7d5eee8f931cf009775 (patch)
tree46f35a087f165cda6999f54ae22d42b58e34e966 /plugins/flac
parent21e15c00392c79a7df54ffe2659e68ba33052869 (diff)
flac: ignore files with samplerate<=0; don't calculate bitrate on streams with unknown length
Diffstat (limited to 'plugins/flac')
-rw-r--r--plugins/flac/flac.c11
1 files changed, 9 insertions, 2 deletions
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");