5 ###--------------------------------------------------------------------------
6 ### Table of contents representation.
8 ### We need a simple table of contents representation. A toc file consists
9 ### of a number of records, one per line; each record is a number of
10 ### blank-delimited fields. Fields don't contain whitespace, so no quoting
11 ### is needed. The first field of each record is a type which explains how
12 ### to decode the rest.
14 ### `T' START Audio track starts at START frames.
16 ### `D' START Data track, starts at START frames.
18 ### `E' END Leadout at END frames.
20 ###--------------------------------------------------------------------------
21 ### Command line options.
25 while getopts "d:h:" opt
; do
36 *) echo >&2 "Usage: $0 [-d DATA] [-h HIDDEN] DIR|CD-DEVICE"; exit 1 ;;
40 ###--------------------------------------------------------------------------
41 ### Work out what to do.
43 if [ -d
"$source" ]; then
45 ## Intuit what's going on from a directory full of FLAC files.
47 for i
in [0-9][0-9][-.\
]*.flac
; do
48 metaflac
--show-total-samples
"$i"
51 while read samples
; do
52 frames
=$
((samples
/588))
68 elif [ -b
"$source" ]; then
70 ## Read a table of contents from a CD.
71 wodim dev
="$source" -toc |
sed '
73 s/^track:\(.*\) lba: *\([0-9][0-9]*\) (.*mode: *\([-0-9][0-9]*\) *$/\1 \3 \2/
74 ' |
while read track mode offset
; do
75 case "$track,$mode" in
76 lout
,-1) echo "E $offset" ;;
77 *,0 |
*,-1) echo "T $offset" ;;
78 *,1 |
*,2) echo "D $offset" ;;
83 echo >&2 "$0: don't know how to read a toc from $source"