Skip to content

Commit

Permalink
Add experimental overread support (lead-out)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeLametta committed Nov 29, 2015
1 parent 693d67c commit c29da6c
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 10 deletions.
4 changes: 2 additions & 2 deletions morituri/common/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ def verifyTrack(self, runner, trackResult):
return ret

def ripTrack(self, runner, trackResult, offset, device, profile, taglist,
what=None):
overread, what=None):
"""
Ripping the track may change the track's filename as stored in
trackResult.
Expand All @@ -590,7 +590,7 @@ def ripTrack(self, runner, trackResult, offset, device, profile, taglist,
what='track %d' % (trackResult.number, )

t = cdparanoia.ReadVerifyTrackTask(trackResult.filename,
self.result.table, start, stop,
self.result.table, start, stop, overread,
offset=offset,
device=device,
profile=profile,
Expand Down
21 changes: 13 additions & 8 deletions morituri/program/cdparanoia.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ class ReadTrackTask(log.Loggable, task.Task):

_MAXERROR = 100 # number of errors detected by parser

def __init__(self, path, table, start, stop, offset=0, device=None,
action="Reading", what="track"):
def __init__(self, path, table, start, stop, overread, offset=0,
device=None, action="Reading", what="track"):
"""
Read the given track.
Expand Down Expand Up @@ -248,6 +248,7 @@ def __init__(self, path, table, start, stop, offset=0, device=None,
self._parser = ProgressParser(start, stop)
self._device = device
self._start_time = None
self._overread = overread

self._buffer = "" # accumulate characters
self._errors = []
Expand Down Expand Up @@ -278,8 +279,12 @@ def start(self, runner):
stopTrack, stopOffset)

bufsize = 1024
argv = ["cdparanoia", "--stderr-progress",
"--sample-offset=%d" % self._offset, ]
if self._overread:
argv = ["cdparanoia", "--stderr-progress",
"--sample-offset=%d" % self._offset, "--force-overread", ]
else:
argv = ["cdparanoia", "--stderr-progress",
"--sample-offset=%d" % self._offset, ]
if self._device:
argv.extend(["--force-cdrom-device", self._device, ])
argv.extend(["%d[%s]-%d[%s]" % (
Expand Down Expand Up @@ -422,8 +427,8 @@ class ReadVerifyTrackTask(log.Loggable, task.MultiSeparateTask):
_tmpwavpath = None
_tmppath = None

def __init__(self, path, table, start, stop, offset=0, device=None,
profile=None, taglist=None, what="track"):
def __init__(self, path, table, start, stop, overread, offset=0,
device=None, profile=None, taglist=None, what="track"):
"""
@param path: where to store the ripped track
@type path: str
Expand Down Expand Up @@ -459,10 +464,10 @@ def __init__(self, path, table, start, stop, offset=0, device=None,

self.tasks = []
self.tasks.append(
ReadTrackTask(tmppath, table, start, stop,
ReadTrackTask(tmppath, table, start, stop, overread,
offset=offset, device=device, what=what))
self.tasks.append(checksum.CRC32Task(tmppath))
t = ReadTrackTask(tmppath, table, start, stop,
t = ReadTrackTask(tmppath, table, start, stop, overread,
offset=offset, device=device, action="Verifying", what=what)
self.tasks.append(t)
self.tasks.append(checksum.CRC32Task(tmppath))
Expand Down
6 changes: 6 additions & 0 deletions morituri/result/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ def logRip(self, ripResult, epoch):

lines.append("Read offset correction: %d" %
ripResult.offset)
overread = "Unknown"
if ripResult.overread is True:
overread = "Yes (Lead-Out)"
if ripResult.overread is False:
overread = "No"
lines.append("Overread: %s" % overread)
lines.append("")

# toc
Expand Down
1 change: 1 addition & 0 deletions morituri/result/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class RipResult:
"""

offset = 0
overread = None
table = None
artist = None
title = None
Expand Down
9 changes: 9 additions & 0 deletions morituri/rip/cd.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,13 @@ def addOptions(self):
self.parser.add_option('-o', '--offset',
action="store", dest="offset",
help="sample read offset (defaults to configured value, or 0)")
self.parser.add_option('-x', '--force-overread',
action="store_true", dest="overread",
help="Force overreading into the lead-out portion of the disc. "
"Works only if the patched cdparanoia package is installed "
"and the drive supports this feature. "
"The default value is: %default",
default=False)
self.parser.add_option('-O', '--output-directory',
action="store", dest="output_directory",
help="output directory; will be included in file paths in result "
Expand Down Expand Up @@ -282,6 +289,7 @@ def doCommand(self):
self.program.setWorkingDirectory(self.options.working_directory)
self.program.outdir = self.options.output_directory.decode('utf-8')
self.program.result.offset = int(self.options.offset)
self.program.result.overread = self.options.overread

### write disc files
disambiguate = False
Expand Down Expand Up @@ -378,6 +386,7 @@ def ripIfNotRipped(number):
device=self.parentCommand.options.device,
profile=profile,
taglist=self.program.getTagList(number),
overread=self.options.overread,
what='track %d of %d%s' % (
number, len(self.itable.tracks), extra))
break
Expand Down

0 comments on commit c29da6c

Please sign in to comment.