summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars-Dominik Braun <PromyLOPh@lavabit.com>2009-07-11 19:18:03 +0200
committerLars-Dominik Braun <PromyLOPh@lavabit.com>2009-07-11 19:18:03 +0200
commit235dcb00e742388caf76c130b68f0de999de2bd5 (patch)
treea9d3e1b0abb76d5a85ba98d7eb53240a057aa1a7
parenta34feb431bb9a8bef76fc1e069c73ded48b1f4cc (diff)
downloadpianobar-235dcb00e742388caf76c130b68f0de999de2bd5.tar.gz
pianobar-235dcb00e742388caf76c130b68f0de999de2bd5.tar.bz2
pianobar-235dcb00e742388caf76c130b68f0de999de2bd5.zip
Fix hardcoded mp3 bitrate
Get bitrate from header of first decoded frame now.
-rw-r--r--src/player.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/player.c b/src/player.c
index beccc37..fd56b0a 100644
--- a/src/player.c
+++ b/src/player.c
@@ -310,13 +310,6 @@ char BarPlayerMp3Cb (void *ptr, size_t size, void *stream) {
return 0;
}
- /* initialize song length */
- if (player->mode < PLAYER_SAMPLESIZE_INITIALIZED) {
- player->songDuration = (float) player->waith.contentLength /
- ((float) MP3_BITRATE * 1024.0 /
- (float) BAR_PLAYER_MS_TO_S_FACTOR / 8.0);
- }
-
/* some "prebuffering" */
if (player->mode < PLAYER_RECV_DATA &&
player->bufferFilled < sizeof (player->buffer) / 2) {
@@ -363,6 +356,12 @@ char BarPlayerMp3Cb (void *ptr, size_t size, void *stream) {
format.byte_format = AO_FMT_LITTLE;
player->audioOutDevice = ao_open_live (audioOutDriver,
&format, NULL);
+
+ /* calc song length using the framerate of the first decoded frame */
+ player->songDuration = (float) player->waith.contentLength /
+ ((float) player->mp3Frame.header.bitrate /
+ (float) BAR_PLAYER_MS_TO_S_FACTOR / 8.0);
+
/* must be > PLAYER_SAMPLESIZE_INITIALIZED, otherwise time won't
* be visible to user (ugly, but mp3 decoding != aac decoding) */
player->mode = PLAYER_RECV_DATA;