From d4d92ac1a70203b6f686e66ca43e0c0817ba28e3 Mon Sep 17 00:00:00 2001 From: Jurgen Kramer Date: Thu, 12 Jul 2012 19:40:56 +0200 Subject: Add song duration to DSF and DSDIFF DSD decoders. --- src/decoder/dsf_decoder_plugin.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/decoder/dsf_decoder_plugin.c') diff --git a/src/decoder/dsf_decoder_plugin.c b/src/decoder/dsf_decoder_plugin.c index b66ed75e9..c0107eb30 100644 --- a/src/decoder/dsf_decoder_plugin.c +++ b/src/decoder/dsf_decoder_plugin.c @@ -33,6 +33,7 @@ #include "audio_check.h" #include "util/bit_reverse.h" #include "dsdlib.h" +#include "tag_handler.h" #include #include /* for SEEK_SET, SEEK_CUR */ @@ -275,9 +276,13 @@ dsf_stream_decode(struct decoder *decoder, struct input_stream *is) g_error_free(error); return; } + /* Calculate song time from DSD chunk size and sample frequency */ + uint64_t chunk_size = metadata.chunk_size; + float songtime = ((chunk_size / metadata.channels) * 8) / + (float) metadata.sample_rate; /* success: file was recognized */ - decoder_initialized(decoder, &audio_format, false, -1); + decoder_initialized(decoder, &audio_format, false, songtime); if (!dsf_decode_chunk(decoder, is, metadata.channels, metadata.chunk_size, @@ -306,6 +311,11 @@ dsf_scan_stream(struct input_stream *is, /* refuse to parse files which we cannot play anyway */ return false; + /* calculate song time and add as tag */ + unsigned songtime = ((metadata.chunk_size / metadata.channels) * 8) / + metadata.sample_rate; + tag_handler_invoke_duration(handler, handler_ctx, songtime); + return true; } -- cgit v1.2.3