diff options
author | Yuriy Kaminskiy <yumkam@mail.ru> | 2011-01-21 16:25:46 +0300 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2011-01-21 15:37:08 +0100 |
commit | 731ea9b489ec5e4134a07092f9eeb0a81865d841 (patch) | |
tree | e899aceedeb2b157316c70e92243d48f2b96b248 /src/decoder | |
parent | 18b30b50197261a8f062f44b5e8b24b21fb2b280 (diff) | |
download | mpd-731ea9b489ec5e4134a07092f9eeb0a81865d841.tar.gz mpd-731ea9b489ec5e4134a07092f9eeb0a81865d841.tar.xz mpd-731ea9b489ec5e4134a07092f9eeb0a81865d841.zip |
mpg123 decoder: report bitrate
Diffstat (limited to '')
-rw-r--r-- | src/decoder/mpg123_decoder_plugin.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/decoder/mpg123_decoder_plugin.c b/src/decoder/mpg123_decoder_plugin.c index 7b48ebfaf..84f12f29b 100644 --- a/src/decoder/mpg123_decoder_plugin.c +++ b/src/decoder/mpg123_decoder_plugin.c @@ -105,6 +105,7 @@ mpd_mpg123_file_decode(struct decoder *decoder, const char *path_fs) int error; off_t num_samples; enum decoder_command cmd; + struct mpg123_frameinfo info; /* open the file */ @@ -128,6 +129,21 @@ mpd_mpg123_file_decode(struct decoder *decoder, const char *path_fs) (float)num_samples / (float)audio_format.sample_rate); + if (mpg123_info(handle, &info) != MPG123_OK) { + info.vbr = MPG123_CBR; + info.bitrate = 0; + } + + switch (info.vbr) { + case MPG123_ABR: + info.bitrate = info.abr_rate; + break; + case MPG123_CBR: + break; + default: + info.bitrate = 0; + } + /* the decoder main loop */ do { @@ -144,9 +160,17 @@ mpd_mpg123_file_decode(struct decoder *decoder, const char *path_fs) break; } + /* update bitrate for ABR/VBR */ + if (info.vbr != MPG123_CBR) { + /* FIXME: maybe skip, as too expensive? */ + /* FIXME: maybe, (info.vbr == MPG123_VBR) ? */ + if (mpg123_info (handle, &info) != MPG123_OK) + info.bitrate = 0; + } + /* send to MPD */ - cmd = decoder_data(decoder, NULL, buffer, nbytes, 0); + cmd = decoder_data(decoder, NULL, buffer, nbytes, info.bitrate); /* seeking not yet implemented */ } while (cmd == DECODE_COMMAND_NONE); |