diff options
author | Lars-Dominik Braun <PromyLOPh@lavabit.com> | 2009-02-06 16:44:20 +0100 |
---|---|---|
committer | Lars-Dominik Braun <PromyLOPh@lavabit.com> | 2009-02-06 16:45:59 +0100 |
commit | fcb1d460d459242dc30d033305db2cb9bf313f5e (patch) | |
tree | 8a1e3dce4971a53419ed70a1b963010710257e7e | |
parent | a2aee035072a5d346c187a890539f72c6d5167a0 (diff) | |
download | pianobar-fcb1d460d459242dc30d033305db2cb9bf313f5e.tar.gz pianobar-fcb1d460d459242dc30d033305db2cb9bf313f5e.tar.bz2 pianobar-fcb1d460d459242dc30d033305db2cb9bf313f5e.zip |
Fix FPE
Introduced in (last) commit a2aee035072a5d346c187a890539f72c6d5167a0.
Don't divide by zero :)
-rw-r--r-- | src/player.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/player.c b/src/player.c index e6edf2e..fc7fa46 100644 --- a/src/player.c +++ b/src/player.c @@ -342,11 +342,14 @@ size_t BarPlayerMp3CurlCb (void *ptr, size_t size, size_t nmemb, void *stream) { ao_play (player->audioOutDevice, (char *) madDecoded, player->mp3Synth.pcm.length * 2 * 2); - /* same calculation as in aac player; don't need to divide by channels, - * length is number of samples for _one_ channel */ - player->songPlayed += (float) player->mp3Synth.pcm.length * - (float) BAR_PLAYER_MS_TO_S_FACTOR / - (float) player->samplerate; + /* avoid division by 0 */ + if (player->mode == PLAYER_RECV_DATA) { + /* same calculation as in aac player; don't need to divide by + * channels, length is number of samples for _one_ channel */ + player->songPlayed += (float) player->mp3Synth.pcm.length * + (float) BAR_PLAYER_MS_TO_S_FACTOR / + (float) player->samplerate; + } QUIT_PAUSE_CHECK; } while (player->mp3Stream.error != MAD_ERROR_BUFLEN); |