ReplayGainInfo: implement fallback in Get()
Eliminates Complete().
This commit is contained in:
parent
09c3cc58e4
commit
1261327fa6
|
@ -41,10 +41,3 @@ ReplayGainTuple::CalculateScale(float preamp, float missing_preamp,
|
|||
|
||||
return scale;
|
||||
}
|
||||
|
||||
void
|
||||
ReplayGainInfo::Complete()
|
||||
{
|
||||
if (!tuples[REPLAY_GAIN_ALBUM].IsDefined())
|
||||
tuples[REPLAY_GAIN_ALBUM] = tuples[REPLAY_GAIN_TRACK];
|
||||
}
|
||||
|
|
|
@ -57,19 +57,19 @@ struct ReplayGainInfo {
|
|||
}
|
||||
|
||||
const ReplayGainTuple &Get(ReplayGainMode mode) const {
|
||||
return tuples[mode];
|
||||
return mode == REPLAY_GAIN_ALBUM
|
||||
? (tuples[REPLAY_GAIN_ALBUM].IsDefined()
|
||||
? tuples[REPLAY_GAIN_ALBUM]
|
||||
: tuples[REPLAY_GAIN_TRACK])
|
||||
: (tuples[REPLAY_GAIN_TRACK].IsDefined()
|
||||
? tuples[REPLAY_GAIN_TRACK]
|
||||
: tuples[REPLAY_GAIN_ALBUM]);
|
||||
}
|
||||
|
||||
void Clear() {
|
||||
tuples[REPLAY_GAIN_ALBUM].Clear();
|
||||
tuples[REPLAY_GAIN_TRACK].Clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to auto-complete missing data. In particular, if
|
||||
* album information is missing, track gain is used.
|
||||
*/
|
||||
void Complete();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -79,10 +79,9 @@ public:
|
|||
}
|
||||
|
||||
void SetInfo(const ReplayGainInfo *_info) {
|
||||
if (_info != nullptr) {
|
||||
if (_info != nullptr)
|
||||
info = *_info;
|
||||
info.Complete();
|
||||
} else
|
||||
else
|
||||
info.Clear();
|
||||
|
||||
Update();
|
||||
|
|
Loading…
Reference in New Issue