From 635791d1cdb1db47096572cfbb13351ab6e3f57f Mon Sep 17 00:00:00 2001 From: Orivej Desh Date: Sun, 28 Mar 2010 19:34:16 +0200 Subject: cue: prepend pregap to the beginning of the track .. rather then append to the end of the previous one Cuebreakpoints from the cuetools package has three modes of operation, and the default is to append pregap (INDEX 00) to the end of the previous track. This is the behavior most compliant to the existing cue files. Here is the patch which fixes the issue. I borrowed bits of implementation from cuebreakpoints. I assumed that the whole audio file must be covered by head-to-head going tracks, which is how hardware CD players probably work. In cue_tag I changed rounding from rounding up to rounding down because the thing in mpd which calculates actual track duration (and current position) rounds it down, and I didn't want to see in my playlist values different from whose in a now-playing progress bar. I've compared the resultant mpd behaviour with "mplayer -ss MM:SS.MS" where the time was supplied by cuebreakpoints and noticed that mplayer started each track a bit earlier then mpd, though this was the same before the patch. --- src/cue/cue_tag.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/cue') diff --git a/src/cue/cue_tag.c b/src/cue/cue_tag.c index 67919ce3..d5bfe26d 100644 --- a/src/cue/cue_tag.c +++ b/src/cue/cue_tag.c @@ -178,9 +178,16 @@ cue_tag(struct Cd *cd, unsigned tnum) if (tag == NULL) return NULL; + tag->time = track_get_length(track) + - track_get_index(track, 1) + + track_get_zero_pre(track); + track = cd_get_track(cd, tnum+1); + if (track != NULL) + tag->time += track_get_index(track, 1) + - track_get_zero_pre(track); /* libcue returns the track duration in frames, and there are - 75 frames per second; this formula rounds up */ - tag->time = (track_get_length(track) + 74) / 75; + 75 frames per second; this formula rounds down */ + tag->time = tag->time / 75; return tag; } -- cgit v1.2.3