From 16e1e247638aa0da5541aa78fb141e60744d56a0 Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Thu, 4 Aug 2011 15:03:15 +0200 Subject: Handle sample rates and channels. --- decoders/mpg123_decoder.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'decoders/mpg123_decoder.cpp') diff --git a/decoders/mpg123_decoder.cpp b/decoders/mpg123_decoder.cpp index ec6f490..13e9861 100644 --- a/decoders/mpg123_decoder.cpp +++ b/decoders/mpg123_decoder.cpp @@ -17,8 +17,15 @@ DecoderMpg123::DecoderMpg123(const std::string& filename) { throw std::runtime_error(mpg123_plain_strerror(error)); } + long rate; + int channels, enc; + mpg123_getformat(handle, &rate, &channels, &enc); + std::cout << boost::format("mpg123: %li Hz, %i channels, encoding value %i") % rate % channels % enc << std::endl; + this->samplerate = rate; + this->channels = channels; + mpg123_format_none(handle); - mpg123_format(handle, 44100, 2, MPG123_ENC_SIGNED_16); + mpg123_format(handle, rate, channels, MPG123_ENC_SIGNED_16); } DecoderMpg123::~DecoderMpg123() { -- cgit v1.2.3