replay_gain_info: use INFINITY to mark undefined values
The previous patch not only moved code, it also changed the check. Negative gain values seem to be valid after all, there just was the "magic" value 0.0 which means "not available". This patch changes the "magic" value to "INFINITY", and uses the C99 function isinf() to check. It might have been a better idea to use "NAN", but the "NAN" macro is a GNU extension.
This commit is contained in:
parent
b21e4d9a58
commit
c05e6a1275
@ -21,7 +21,6 @@
|
||||
#include "replay_gain_info.h"
|
||||
|
||||
#include <glib.h>
|
||||
#include <math.h>
|
||||
|
||||
struct replay_gain_info *
|
||||
replay_gain_info_new(void)
|
||||
@ -29,7 +28,7 @@ replay_gain_info_new(void)
|
||||
struct replay_gain_info *ret = g_new(struct replay_gain_info, 1);
|
||||
|
||||
for (unsigned i = 0; i < G_N_ELEMENTS(ret->tuples); ++i) {
|
||||
ret->tuples[i].gain = 0.0;
|
||||
ret->tuples[i].gain = INFINITY;
|
||||
ret->tuples[i].peak = 0.0;
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "check.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <math.h>
|
||||
|
||||
enum replay_gain_mode {
|
||||
REPLAY_GAIN_OFF = -1,
|
||||
@ -54,7 +55,7 @@ replay_gain_info_free(struct replay_gain_info *info);
|
||||
static inline bool
|
||||
replay_gain_tuple_defined(const struct replay_gain_tuple *tuple)
|
||||
{
|
||||
return tuple->gain > 0.0;
|
||||
return !isinf(tuple->gain);
|
||||
}
|
||||
|
||||
float
|
||||
|
Loading…
Reference in New Issue
Block a user