WIP: try to set relative offset correctly based on sources
This commit is contained in:
@@ -119,6 +119,16 @@ class Sources(log.Loggable):
|
||||
|
||||
return self._sources[-1]
|
||||
|
||||
def getCounterStart(self, counter):
|
||||
"""
|
||||
Retrieve the absolute offset of the first source for this counter
|
||||
"""
|
||||
for i, (c, o, s) in enumerate(self._sources):
|
||||
if c == counter:
|
||||
return self._sources[i][1]
|
||||
|
||||
return self._sources[-1][1]
|
||||
|
||||
|
||||
class TocFile(object, log.Loggable):
|
||||
|
||||
@@ -197,7 +207,6 @@ class TocFile(object, log.Loggable):
|
||||
# set index 1 of previous track if there was one, using
|
||||
# pregapLength if applicable
|
||||
if currentTrack:
|
||||
# FIXME: why not set absolute offsets too ?
|
||||
currentTrack.index(1, path=currentFile.path,
|
||||
absolute=absoluteOffset + pregapLength,
|
||||
relative=currentFile.start + pregapLength,
|
||||
@@ -310,6 +319,11 @@ class TocFile(object, log.Loggable):
|
||||
|
||||
length = common.msfToFrames(m.group('length'))
|
||||
c, o, s = sources.get(absoluteOffset)
|
||||
self.debug('at abs offset %d, we are in source %r' % (
|
||||
absoluteOffset, s))
|
||||
counterStart = sources.getCounterStart(c)
|
||||
relativeOffset = absoluteOffset - counterStart
|
||||
|
||||
currentTrack.index(0, path=s and s.path or None,
|
||||
absolute=absoluteOffset,
|
||||
relative=relativeOffset, counter=c)
|
||||
|
||||
@@ -130,9 +130,16 @@ class BlocTestCase(common.TestCase):
|
||||
self.assertEquals(self.toc.getTrackLength(t), -1)
|
||||
|
||||
def testIndexes(self):
|
||||
t = self.toc.table.tracks[0]
|
||||
self.assertEquals(t.getIndex(0).relative, 0)
|
||||
self.assertEquals(t.getIndex(1).relative, 15220)
|
||||
firstTrack = self.toc.table.tracks[0]
|
||||
index0 = firstTrack.getIndex(0)
|
||||
self.assertEquals(index0.absolute, 0)
|
||||
self.assertEquals(index0.relative, 0)
|
||||
self.assertEquals(index0.counter, 0)
|
||||
|
||||
index1 = firstTrack.getIndex(1)
|
||||
self.assertEquals(index1.absolute, 15220)
|
||||
self.assertEquals(index1.relative, 0)
|
||||
self.assertEquals(index1.counter, 1)
|
||||
|
||||
# This disc has a pre-gap, so is a good test for .CUE writing
|
||||
|
||||
|
||||
Reference in New Issue
Block a user