# Platterpus UI script — ONE bounded -O read, run by hand (round 35).
#
# Run it with:  ./platterpus-x86_64.AppImage --run-script overreadprobe
#          or:  Tools → Advanced → Run test script…  → Load → Run
#
# WHAT IT IS FOR. The cyanrip fork's `.24` (93afa15) reads a frame outside the
# disc once, writes a frame the drive refuses as silence, and says so per track:
# `Beyond disc: N of M frames refused (written as silence)`. Before `.24`, `-O`
# hung a read on the rig's BDR-209D for about 23 minutes, which is why every
# other script here keeps `force_overread` off. The fork's round 35 lap 1 S17
# item 3 asks for one read: the LAST track only, at +667, so it reaches two
# frames past the lead-out, under a time limit of a few minutes. Step 4 adds their
# lap 3 S10, the lead-in side, under the same limit.
#
# THE TIME LIMIT CANNOT BE LEFT OFF. The `cyanrip` step below has no timeout
# argument: the runner kills the ripper at its own fixed limit
# (`CYANRIP_VERB_TIMEOUT_S`, 300 seconds) and records the kill. Nothing a script
# can write raises or removes it.
#
# WHAT IT RECORDS. The transcript keeps the step's exit code, its exact argv and
# its complete output; cyanrip prints the `Beyond disc:` line to its output as
# well as its log (`cyanrip@93afa15:src/cyanrip_log.c:481`), so the line is in
# the transcript, and the log lands in `r35overread` in the rips folder. The
# bundle the run ends with carries both.
#
# ONE THING TO DO BY HAND FIRST: put the reference disc in and let the drive
# settle. Run it after the Full run, not during it.

log ===== Round 35: one bounded -O read of the last track =====

log --- 1. the build that bounds -O, or stop ---
cyanrip --version
expect-exit 0
# `.23` and earlier have no bound on -O; on them this read could hang the
# drive until the step's limit kills it. Stop rather than find out.
expect-cyanrip platterpus-fork-g93afa15
abort-if-failed the installed ripper is not .24, whose -O is bounded

log --- 2. the disc and the drive's offset, or stop ---
rescan
pick-release 1 90
expect-tracks 1+
set-drive-offset
# +667 is the BDR-209D's offset, which is what reaches past the lead-out here.
expect read_offset 667
abort-if-failed not the BDR-209D at +667, so the read would not be the one asked for

log --- 3. the read: last track only, -O, killed at the step's fixed limit ---
cyanrip -N -s (offset) -l (lasttrack) -O -D r35overread (consumer) (diagnostics)
expect-exit 0
expect-cyanrip Beyond disc:
snapshot afteroverread

log --- 4. the lead-in side: track 1 at a deliberately wrong -667, the same limit ---
# The fork's round 35 lap 3 S10, optional on their side and the one to drop for
# time: the reference disc's track 1 starts at LSN 0, so -667 reads two frames
# BEFORE the disc through the same bounded branch. Typed, not (offset), because a
# wrong offset is the point; it reaches only this argv, never the drive's setting.
# Its audio is not kept. If step 3 hit the limit, this one will tell nothing new.
cyanrip -N -s -667 -l 1 -O -D r35overreadleadin (consumer) (diagnostics)
expect-exit 0
expect-cyanrip Beyond disc:

log --- 5. nothing here turned overread on for your rips ---
expect force_overread off
