summaryrefslogtreecommitdiff
path: root/decoders
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2011-08-04 15:03:15 +0200
committerJon Bergli Heier <snakebite@jvnv.net>2011-08-04 15:03:15 +0200
commit16e1e247638aa0da5541aa78fb141e60744d56a0 (patch)
treeb6f99c16767c95c0b9fb0a79abea613150b11a4e /decoders
parent2c01957dfe1135955627cbbbffddc70d090d2656 (diff)
Handle sample rates and channels.
Diffstat (limited to 'decoders')
-rw-r--r--decoders/ffmpeg_decoder.cpp2
-rw-r--r--decoders/mpg123_decoder.cpp9
2 files changed, 10 insertions, 1 deletions
diff --git a/decoders/ffmpeg_decoder.cpp b/decoders/ffmpeg_decoder.cpp
index 630e38e..7b7397f 100644
--- a/decoders/ffmpeg_decoder.cpp
+++ b/decoders/ffmpeg_decoder.cpp
@@ -14,6 +14,8 @@ DecoderFFmpeg::DecoderFFmpeg(const std::string& filename) {
av_dump_format(lavf_ctx, 0, filename.c_str(), 0);
lavc_ctx = lavf_ctx->streams[0]->codec;
+ samplerate = lavc_ctx->sample_rate;
+ channels = lavc_ctx->channels;
codec = avcodec_find_decoder(lavc_ctx->codec_id);
std::cerr << "Opening decoder: " << avcodec_open(lavc_ctx, codec) << std::endl;
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() {