diff options
author | Lars-Dominik Braun <PromyLOPh@gmail.com> | 2008-06-22 11:32:22 +0200 |
---|---|---|
committer | Lars-Dominik Braun <PromyLOPh@gmail.com> | 2008-06-22 11:32:22 +0200 |
commit | ab38ac31d09f85ceb4e47f4a18e3d71f59c2c9d4 (patch) | |
tree | 887e5098e2422e03f0f66f75fee5d9fc4f74bba4 /src | |
parent | 98c2f0b1a22f89dc971472702b3ac4e080183e48 (diff) | |
download | pianobar-ab38ac31d09f85ceb4e47f4a18e3d71f59c2c9d4.tar.gz pianobar-ab38ac31d09f85ceb4e47f4a18e3d71f59c2c9d4.tar.bz2 pianobar-ab38ac31d09f85ceb4e47f4a18e3d71f59c2c9d4.zip |
client: Time calc algo => function
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 19 |
1 files changed, 11 insertions, 8 deletions
@@ -142,6 +142,12 @@ char *selectMusicId (PianoHandle_t *ph) { return musicId; } +/* FIXME: this is now correct */ +inline float BarSamplesToSeconds (float samplerate, float channels, + float samples) { + return channels * 1000.0 * samples / samplerate; +} + int main (int argc, char **argv) { PianoHandle_t ph; struct aacPlayer player; @@ -370,14 +376,11 @@ int main (int argc, char **argv) { /* show time */ if (player.finishedPlayback == 0 && player.mode >= SAMPLESIZE_INITIALIZED) { - /* FIXME: is this calculation correct? */ - /* one frame length: T = 1/f */ - float songLength = 1.0 / (float) player.samplerate * - (float) player.channels * 1000.0 * - (float) player.sampleSizeN; - float songRemaining = songLength - 1.0 / (float) player.samplerate * - (float) player.channels * 1000.0 * - (float) player.sampleSizeCurr; + float songLength = BarSamplesToSeconds (player.samplerate, + player.channels, player.sampleSizeN); + float songRemaining = songLength - + BarSamplesToSeconds (player.samplerate, player.channels, + player.sampleSizeCurr); printf ("-%02i:%02i/%02i:%02i\r", (int) songRemaining/60, (int) songRemaining%60, (int) songLength/60, (int) songLength%60); |