summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer/libmad/timer.c
Unidiff
Diffstat (limited to 'core/multimedia/opieplayer/libmad/timer.c') (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/libmad/timer.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/core/multimedia/opieplayer/libmad/timer.c b/core/multimedia/opieplayer/libmad/timer.c
index 299fe0b..fa377d0 100644
--- a/core/multimedia/opieplayer/libmad/timer.c
+++ b/core/multimedia/opieplayer/libmad/timer.c
@@ -1,15 +1,15 @@
1/* 1/*
2 * libmad - MPEG audio decoder library 2 * libmad - MPEG audio decoder library
3 * Copyright (C) 2000-2001 Robert Leslie 3 * Copyright (C) 2000-2004 Underbit Technologies, Inc.
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or 7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version. 8 * (at your option) any later version.
9 * 9 *
10 * This program is distributed in the hope that it will be useful, 10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License 15 * You should have received a copy of the GNU General Public License
@@ -69,25 +69,25 @@ void mad_timer_negate(mad_timer_t *timer)
69 if (timer->fraction) { 69 if (timer->fraction) {
70 timer->seconds -= 1; 70 timer->seconds -= 1;
71 timer->fraction = MAD_TIMER_RESOLUTION - timer->fraction; 71 timer->fraction = MAD_TIMER_RESOLUTION - timer->fraction;
72 } 72 }
73} 73}
74 74
75/* 75/*
76 * NAME:timer->abs() 76 * NAME:timer->abs()
77 * DESCRIPTION:return the absolute value of a timer 77 * DESCRIPTION:return the absolute value of a timer
78 */ 78 */
79mad_timer_t mad_timer_abs(mad_timer_t timer) 79mad_timer_t mad_timer_abs(mad_timer_t timer)
80{ 80{
81 if (mad_timer_sign(timer) < 0) 81 if (timer.seconds < 0)
82 mad_timer_negate(&timer); 82 mad_timer_negate(&timer);
83 83
84 return timer; 84 return timer;
85} 85}
86 86
87/* 87/*
88 * NAME:reduce_timer() 88 * NAME:reduce_timer()
89 * DESCRIPTION:carry timer fraction into seconds 89 * DESCRIPTION:carry timer fraction into seconds
90 */ 90 */
91static 91static
92void reduce_timer(mad_timer_t *timer) 92void reduce_timer(mad_timer_t *timer)
93{ 93{
@@ -318,25 +318,26 @@ signed long mad_timer_count(mad_timer_t timer, enum mad_units units)
318} 318}
319 319
320/* 320/*
321 * NAME:timer->fraction() 321 * NAME:timer->fraction()
322 * DESCRIPTION:return fractional part of timer in arbitrary terms 322 * DESCRIPTION:return fractional part of timer in arbitrary terms
323 */ 323 */
324unsigned long mad_timer_fraction(mad_timer_t timer, unsigned long denom) 324unsigned long mad_timer_fraction(mad_timer_t timer, unsigned long denom)
325{ 325{
326 timer = mad_timer_abs(timer); 326 timer = mad_timer_abs(timer);
327 327
328 switch (denom) { 328 switch (denom) {
329 case 0: 329 case 0:
330 return MAD_TIMER_RESOLUTION / timer.fraction; 330 return timer.fraction ?
331 MAD_TIMER_RESOLUTION / timer.fraction : MAD_TIMER_RESOLUTION + 1;
331 332
332 case MAD_TIMER_RESOLUTION: 333 case MAD_TIMER_RESOLUTION:
333 return timer.fraction; 334 return timer.fraction;
334 335
335 default: 336 default:
336 return scale_rational(timer.fraction, MAD_TIMER_RESOLUTION, denom); 337 return scale_rational(timer.fraction, MAD_TIMER_RESOLUTION, denom);
337 } 338 }
338} 339}
339 340
340/* 341/*
341 * NAME:timer->string() 342 * NAME:timer->string()
342 * DESCRIPTION:write a string representation of a timer using a template 343 * DESCRIPTION:write a string representation of a timer using a template