summaryrefslogtreecommitdiff
path: root/src/codecs/vorbis.cpp
diff options
context:
space:
mode:
authorTom Kirchner <git@halffull.org>2025-01-06 20:53:02 -0800
committerTom Kirchner <git@halffull.org>2025-01-08 20:46:34 -0800
commitfaa62e0c60d51a9df88002a59825b427323259c0 (patch)
treecd0631b047e8b09fbd61ea85ad1a67aa55929a25 /src/codecs/vorbis.cpp
parent829d033a448107f1bc610cf735ce9f7222de564b (diff)
downloadtangara-fw-faa62e0c60d51a9df88002a59825b427323259c0.tar.gz
Add bitrate info
Diffstat (limited to 'src/codecs/vorbis.cpp')
-rw-r--r--src/codecs/vorbis.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/codecs/vorbis.cpp b/src/codecs/vorbis.cpp
index ea33a2af..464aa4a2 100644
--- a/src/codecs/vorbis.cpp
+++ b/src/codecs/vorbis.cpp
@@ -118,6 +118,12 @@ auto TremorVorbisDecoder::OpenStream(std::shared_ptr<IStream> input,
length = l * info->channels;
}
+ auto b = ov_bitrate(vorbis_.get(), -1);
+ std::optional<uint32_t> bitrate_kbps;
+ if (b > 0) {
+ bitrate_kbps = b / 1024;
+ }
+
if (offset && ov_time_seek(vorbis_.get(), offset * 1000) != 0) {
return cpp::fail(Error::kInternalError);
}
@@ -126,6 +132,7 @@ auto TremorVorbisDecoder::OpenStream(std::shared_ptr<IStream> input,
.num_channels = static_cast<uint8_t>(info->channels),
.sample_rate_hz = static_cast<uint32_t>(info->rate),
.total_samples = length,
+ .bitrate_kbps = bitrate_kbps,
};
}