CrossFade: pass total_time as SignedSongTime instance

This commit is contained in:
Max Kellermann 2014-08-29 23:41:34 +02:00
parent 58352ea69d
commit 7c567e3cbd
3 changed files with 7 additions and 4 deletions

View File

@ -19,6 +19,7 @@
#include "config.h" #include "config.h"
#include "CrossFade.hxx" #include "CrossFade.hxx"
#include "Chrono.hxx"
#include "MusicChunk.hxx" #include "MusicChunk.hxx"
#include "AudioFormat.hxx" #include "AudioFormat.hxx"
#include "util/NumberParser.hxx" #include "util/NumberParser.hxx"
@ -85,7 +86,7 @@ mixramp_interpolate(const char *ramp_list, float required_db)
} }
unsigned unsigned
CrossFadeSettings::Calculate(float total_time, CrossFadeSettings::Calculate(SignedSongTime total_time,
float replay_gain_db, float replay_gain_prev_db, float replay_gain_db, float replay_gain_prev_db,
const char *mixramp_start, const char *mixramp_prev_end, const char *mixramp_start, const char *mixramp_prev_end,
const AudioFormat af, const AudioFormat af,
@ -95,7 +96,8 @@ CrossFadeSettings::Calculate(float total_time,
unsigned int chunks = 0; unsigned int chunks = 0;
float chunks_f; float chunks_f;
if (duration < 0 || duration >= total_time || if (total_time.IsNegative() ||
duration < 0 || duration >= total_time.ToDoubleS() ||
/* we can't crossfade when the audio formats are different */ /* we can't crossfade when the audio formats are different */
af != old_format) af != old_format)
return 0; return 0;

View File

@ -23,6 +23,7 @@
#include "Compiler.h" #include "Compiler.h"
struct AudioFormat; struct AudioFormat;
class SignedSongTime;
struct CrossFadeSettings { struct CrossFadeSettings {
/** /**
@ -60,7 +61,7 @@ struct CrossFadeSettings {
* should be disabled for this song change * should be disabled for this song change
*/ */
gcc_pure gcc_pure
unsigned Calculate(float total_time, unsigned Calculate(SignedSongTime total_time,
float replay_gain_db, float replay_gain_prev_db, float replay_gain_db, float replay_gain_prev_db,
const char *mixramp_start, const char *mixramp_start,
const char *mixramp_prev_end, const char *mixramp_prev_end,

View File

@ -1001,7 +1001,7 @@ Player::Run()
calculate how many chunks will be required calculate how many chunks will be required
for it */ for it */
cross_fade_chunks = cross_fade_chunks =
pc.cross_fade.Calculate(dc.total_time.ToDoubleS(), pc.cross_fade.Calculate(dc.total_time,
dc.replay_gain_db, dc.replay_gain_db,
dc.replay_gain_prev_db, dc.replay_gain_prev_db,
dc.GetMixRampStart(), dc.GetMixRampStart(),