From 39f7545cd5ef7a30bbd482f3579df7744c6b688d Mon Sep 17 00:00:00 2001 From: jacqueline Date: Fri, 7 Jul 2023 15:29:47 +1000 Subject: wire up the playing screen with some real data Includes implementing song duration calculation for CBR MP3 files --- src/codecs/mad.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src/codecs/mad.cpp') diff --git a/src/codecs/mad.cpp b/src/codecs/mad.cpp index 23b4ccf6..81daeb9f 100644 --- a/src/codecs/mad.cpp +++ b/src/codecs/mad.cpp @@ -6,6 +6,7 @@ #include "mad.hpp" #include +#include #include #include @@ -79,12 +80,19 @@ auto MadMp3Decoder::BeginStream(const cpp::span input) } uint8_t channels = MAD_NCHANNELS(&header); - return {GetBytesUsed(input.size_bytes()), - OutputFormat{ - .num_channels = channels, - .bits_per_sample = 24, // We always scale to 24 bits - .sample_rate_hz = header.samplerate, - }}; + OutputFormat output{ + .num_channels = channels, + .bits_per_sample = 24, // We always scale to 24 bits + .sample_rate_hz = header.samplerate, + .duration_seconds = {}, + .bits_per_second = {}, + }; + + // TODO(jacqueline): Support VBR. Although maybe libtags is the better place + // to handle this? + output.bits_per_second = header.bitrate; + + return {GetBytesUsed(input.size_bytes()), output}; } auto MadMp3Decoder::ContinueStream(cpp::span input, -- cgit v1.2.3