* morituri/image/table.py:

Fix a subtle bug in our CDDB disc id calculation.
	  The length of the audio should be calculated as the delta
	  between leadout and start already converted (and truncated)
	  to seconds.
	* morituri/test/bloc.cue:
	* morituri/test/test_image_toc.py:
	  Fix up tests for this.
This commit is contained in:
Thomas Vander Stichele
2009-05-15 20:33:00 +00:00
parent e0ed33b1da
commit dc9ac1c6e3
4 changed files with 36 additions and 8 deletions

View File

@@ -1,3 +1,14 @@
2009-05-15 Thomas Vander Stichele <thomas at apestaart dot org>
* morituri/image/table.py:
Fix a subtle bug in our CDDB disc id calculation.
The length of the audio should be calculated as the delta
between leadout and start already converted (and truncated)
to seconds.
* morituri/test/bloc.cue:
* morituri/test/test_image_toc.py:
Fix up tests for this.
2009-05-15 Thomas Vander Stichele <thomas at apestaart dot org>
* morituri/program/cdparanoia.py:

View File

@@ -202,18 +202,23 @@ class IndexTable(object, log.Loggable):
# last byte is the number of tracks on the CD
n = 0
# CD's have a standard lead-in time of 2 seconds
# which gets added for CDDB disc id's
delta = 2 * checksum.FRAMES_PER_SECOND
#if self.getTrackStart(1) > 0:
# delta = 0
for track in self.tracks:
# CD's have a standard lead-in time of 2 seconds
# which gets added for CDDB disc id's
offset = self.getTrackStart(track.number) + \
2 * checksum.FRAMES_PER_SECOND
offset = self.getTrackStart(track.number) + delta
seconds = offset / checksum.FRAMES_PER_SECOND
n += self._cddbSum(seconds)
last = self.tracks[-1]
leadout = self.getTrackEnd(last.number)
frameLength = leadout - self.getTrackStart(1)
t = frameLength / checksum.FRAMES_PER_SECOND
# the 'real' leadout, not offset by 150 frames
leadout = self.getTrackEnd(last.number) + 1
startSeconds = self.getTrackStart(1) / checksum.FRAMES_PER_SECOND
leadoutSeconds = leadout / checksum.FRAMES_PER_SECOND
t = leadoutSeconds - startSeconds
value = (n % 0xff) << 24 | t << 8 | len(self.tracks)

View File

@@ -1,4 +1,4 @@
REM DISCID AD0BDF0D
REM DISCID AD0BE00D
REM COMMENT "Morituri"
FILE "data.wav" WAVE
TRACK 01 AUDIO

View File

@@ -125,6 +125,18 @@ class BlocTestCase(unittest.TestCase):
ref = open(os.path.join(os.path.dirname(__file__),
'bloc.cue')).read()
self.assertEquals(cue, ref)
def testCDDBId(self):
self.toc.table.absolutize()
self.assertEquals(self.toc.table.getCDDBDiscId(), 'ad0be00d')
def testAccurateRip(self):
# we verify it because it has failed in readdisc in the past
self.toc.table.absolutize()
self.assertEquals(self.toc.table.getAccurateRipURL(),
'http://www.accuraterip.com/accuraterip/'
'e/d/2/dBAR-013-001af2de-0105994e-ad0be00d.bin')
# The Breeders - Mountain Battles has CDText
class BreedersTestCase(unittest.TestCase):
def setUp(self):