[go: up one dir, main page]

File: altcdloop.txt

package info (click to toggle)
cdtool 2.1.5-4.1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 284 kB
  • ctags: 176
  • sloc: ansic: 2,264; makefile: 167; sh: 121
file content (329 lines) | stat: -rw-r--r-- 12,724 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
Message received at 29000@bugs.debian.org:

Received: (at 29000) by bugs.debian.org; 6 Nov 1998 13:34:56 +0000
Received: (qmail 11790 invoked from network); 6 Nov 1998 13:34:52 -0000
Received: from murphy.debian.org (HELO murphy.novare.net) (209.176.56.6)
  by master.debian.org with SMTP; 6 Nov 1998 13:34:52 -0000
Received: (qmail 7795 invoked from network); 6 Nov 1998 13:08:09 -0000
Received: from acay019125135.acay.com.au (HELO alkan) (mail@203.19.125.135)
  by murphy.debian.org with SMTP; 6 Nov 1998 13:08:09 -0000
Received: from mem by alkan with local (Exim 2.04 #1)
        id 0zblbV-0000L6-00 (Debian); Sat, 7 Nov 1998 00:07:05 +1100
To: The Fuzzy One <s335810@student.uq.edu.au>, 29000@bugs.debian.org
Cc: control@bugs.debian.org
Subject: Re: Bug#29000: cdtool: CD looping program is not cool enough (bug-fix included)
References: <E0zbZwy-0000dv-00@fuzzy.localnet>
From: Martin Mitchell <martin@debian.org>
Date: 07 Nov 1998 00:07:05 +1100
In-Reply-To: The Fuzzy One's message of "Fri, 6 Nov 1998 10:40:28 +1000"
Message-ID: <87emrh3r7q.fsf@mail.usyd.edu.au>
Lines: 16
X-Mailer: Gnus v5.6.44/Emacs 19.34

severity 29000 wishlist
quit

Hi Benjamin,

Could you please coordinate with the upstream developer(s) of cdtool as
mentioned in /usr/doc/cdtool/changelog.gz. This will ensure your changes
get incorporated into the main cdtool source, and keep the Debian cdtool
consistent with other versions. In the meantime I will leave this bug
open with severity wishlist. Also I think you should rewrite it in C,
like the rest of cdtool - it is faster particularly on architectures
like m68k, which Debian supports.

Regards,

        Martin.

  ------------------------------------------------------------------------
Acknowledgement sent to Martin Mitchell <martin@debian.org>:
Extra info received and forwarded to list. Full text available.
  ------------------------------------------------------------------------
Information forwarded to debian-bugs-dist@lists.debian.org:
Bug#29000; Package cdtool. Full text available.
  ------------------------------------------------------------------------

Message received at submit@bugs.debian.org:

Received: (at submit) by bugs.debian.org; 6 Nov 1998 00:42:02 +0000
Received: (qmail 2321 invoked from network); 6 Nov 1998 00:42:01 -0000
Received: from student.uq.edu.au (root@130.102.2.20)
  by master.debian.org with SMTP; 6 Nov 1998 00:42:00 -0000
Received: from fuzzy.localnet (s335810.student.uq.edu.au [172.20.5.42])
        by student.uq.edu.au (8.9.1a/8.9.1) with ESMTP id KAA28398
        for <submit@bugs.debian.org>; Fri, 6 Nov 1998 10:41:44 +1000 (GMT+1000)
Received: from fuzzy by fuzzy.localnet with local (Exim 1.92 #1 (Debian))
        id 0zbZwy-0000dv-00; Fri, 6 Nov 1998 10:40:28 +1000
From: The Fuzzy One <s335810@student.uq.edu.au>
Subject: cdtool: CD looping program is not cool enough (bug-fix included)
To: submit@bugs.debian.org
X-Mailer: bug 3.1.5
Message-Id: <E0zbZwy-0000dv-00@fuzzy.localnet>
Date: Fri, 6 Nov 1998 10:40:28 +1000

Package: cdtool
Version: 2.1.4-2

Attached[1] is a cute little awk program I wrote to do cooler cd looping.
cdloop simply isn't up to scratch ;)
cdjuke is a more advanced text-mode interactive cd player that I thought
you might be interested in.  Several features make it reasonably cute.

1.  Low CPU loading
cdjuke attempts to minimise cpu loading by not checking the cd status
at fixed intervals, instead waiting until a song is due to be finished
before waking up.  This may cause confusion with scratched cds, but is
still behaviour that I prefer.

2.  Play-lists embedded within .cdtooldb, or indicated on the command-line
By default, all non-data tracks are considered by cdjuke.
A line such as:
playlist 1 2 3 4 5 6 7 8 10 11 12 13
placed into the entry for a cd in .cdtooldb sets
up a defualt play-list that may be over-ridden
by on the command-line.

3.  Clever track randomisation
If track randomisation is requested, tracks are chosen according
to the system random number generator.  A memory of recent tracks
is stored to prevent tracks being repeated several times.  The
memory lenght is expressed as a percentage of cd tracks, and is
set at 60% in the default configuration.  That is to say, choices
for next track are made from the 40% of the cd that is not considered
recent.

4.  Hot-swapping of CDs is supported
While a song is playing, the cd may be changed.  When cdjuke
next wakes up, it adjusts to the new cd including updating
play-lists.  Since I only have a single cd drive, more advanced
features are not used.

Release early, and release often they say.
The latest version of cdjuke can usually be found on
http://student.uq.edu.au/~s335810/code/cdjuke,
however this web-site is likely to close soon in
favour of a commercial account post-graduation.

Known bugs:
* If run with mawk, then for a currently unknown reason it cannot be
  started as a "cron" or "at" job, resulting in the error
  "awk: bozo: wait_for".  gawk does not seem to have this problem.
* Hot-swapping support needs work to really be considered a feature.
* A list of tracks should be accepted on the command-line, as per
  a real juke-box
* Simultaneous multiple cd support should be included
* Likely to out-grow awk capabilities, should be re-written in either
  C or *gasp* perl

[1]  ---- Begin  ----
#!/usr/bin/awk -f
# This program is released under the GNU Public License version 2.0,
# or at your option, a later version.
# Author: Benjamin Carlyle <fuzzy@humbug.org.au>

BEGIN {
        ECHO=" "
        #ECHO=" echo "           #  Debugging
        CDIR=" cdir "            #  Command to run for cd listing
        CDIR_T=" cdir -t "       #  Command to run to match tracks line
        CDJUMP= ECHO " cdplay "  #  Command to run to jump to a particular track
        SLEEP= ECHO " sleep "    #  Command to sleep for a number of seconds
        C=" ; "                  #  Command separator
        if ("CDTOOLPATHDB" in ENVIRON) {
          CDDB=ENVIRON["CDTOOLPATHDB"]
         } else {
          CDDB=ENVIRON["HOME"] "/.cdtooldb"
         }
        RECENTPERCENT=60 / 100   #  Percentage of album considered "recent"
        LAGTIME=1                #  of seconds to finish early for each track
        ERRSLEEPTIME=30          #  of seconds to finish early for each track
 }

# Print the usage message
function usage() {
        print "Usage:"
        print " " ARGV[0] " [-- -r]|[{track}+]"
 }

function printtracks(tracks) {
        printf "Track-list: "
        for (i=1; i<tracks[0]; i++) {
                printf tracks[i] ", "
         }
        printf tracks[tracks[0]] ".\n"
 }

# Find the play-list of the current cd
# playlist(...)[0] is the size of the play-list,
# while tracks are numbered playlist(...)[1]..playlist[playlist(...)[0]]
function playlist(tracks,      trackline) {

        if (noupdate) {
                printtracks(tracks)
                return
         }

        while (! CDIR_T | getline) {
                print "No cd!!!!   (sleeping " ERRSLEEPTIME " seconds)"
                system(SLEEP ERRSLEEPTIME)
                close(CDIR_T)
         }
        trackline=$0
        close(CDIR_T)

        foundlist=0
        delete tracks
        # Find the tracks line in our user's .cdtooldb
        while (getline < CDDB > 0 && !foundlist) {
                if ($0 == trackline) {
                        # Find the playlist-line
                        while (getline < CDDB > 0 && !foundlist) {
                                if ($1 == "playlist") {
                                        foundlist=1
                                        for (i=1; i<NF; i++) {
                                                tracks[i]=$(i+1)
                                         }
                                        tracks[0] = NF-1
                                 }
                                if ($1 == "tracks") {
                                        # Gone past the end of record
                                        break
                                 }
                         }
                 }
         }
        close(CDDB)

        if (!foundlist) {
                # Find all non-data tracks
                CDIR | getline    # ... discard first line
                i = 1
                while (CDIR | getline > 0) {
                        if ($2 ~ /[0-9]+/ && $3 != "[DATA]") {
                                tracks[i++] = $2
                         }
                 }
                tracks[0] = i-1
                close (CDIR)
         }

        printtracks(tracks)
 }

# Parse the command-line
BEGIN {
        numtracks=1
        for (i=1;i<ARGC;i++) {
                if (ARGV[i] ~ /-.*/) {
                        if (ARGV[i]=="-r" || "--random") {
                                random=1
                         }
                 } else if (ARGV[i] ~ /[0-9]+/) {
                        tracklist[numtracks++]=ARGV[i]
                        noupdate=1
                 } else {
                        usage()
                        exit
                 }
         }
        tracklist[0]=numtracks-1
        playlist(tracklist)
 }

# Return the number of seconds for a time listed in xx:yy.zz format
function breaktime(timestring,       splitarray) {
        split(timestring,temparray,/\.|\:/)
        return temparray[1] * 60 + temparray[2]
 }

# Update entire time table
function readtimes(timearray) {
        CDIR | getline   # Ignore the first (status) line
  while (CDIR | getline > 0) {
                if ($3 == "[DATA]") {
                        timearray[$2]=LAGTIME
                 } else {
                        timearray[$2]=breaktime($1)
                 }
         }
        close(CDIR)
 }

function waittrack(playid) {
        if (playid) {
                while (playid | getline > 0) ;
                close(playid)
         }
 }

# Play a partular track as soon as the previous one is finished.
# Prints status messages
# playid is global, since awk has no concept of a "static" variable...
function playtrack(track) {
        readtimes(times)
        waittrack(playid)
        print "Playing " track "... (" times[track] "s)"
        playid = CDJUMP track C SLEEP (times[track]-LAGTIME)
        playid | getline
        return playid
 }

BEGIN {
        if (!random) {
                print "Playing in order."
                # Repeatedly play every track in the playlist
                while (1) {
                        for (track=1; track<=tracklist[0]; track++) {
                                playtrack(tracklist[track])
                                playlist(tracklist)
                         }
                 }
         } else {
                print "Playing in random order."
                # Repeatedly play a random, non-recent track
                while (1) {
                        # Check chosen track hasn't been played recently
                        do {
                                randomtrack=int(rand()*tracklist[0])+1
                         } while (randomtrack in recenttrack)

                        # Update definition of "recent"
                        recenttrack[randomtrack]=randomtrack
                                trackentry[tail++]=randomtrack
                        numrecent++
                        # Someone might have changed cds...
                        while (numrecent>tracklist[0]*RECENTPERCENT) {
                                delete recenttrack[trackentry[head]]
                                delete trackentry[head]
                                head++
                                numrecent--
                         }

                        playid = playtrack(tracklist[randomtrack])
                        playlist(tracklist)
                 }
         }
 }

---- end ----

-- System Information
Debian Release: 2.0
Kernel Version: Linux fuzzy 2.0.30 #1 Sun Jun 1 09:14:11 EST 1997 i486 unknown

Versions of the packages cdtool depends on:
ii  libc6           2.0.7t-1       The GNU C library version 2 (run-time files)

  ------------------------------------------------------------------------
Acknowledgement sent to The Fuzzy One <s335810@student.uq.edu.au>:
New bug report received and forwarded. Copy sent to Martin Mitchell
<martin@debian.org>. Full text available.
  ------------------------------------------------------------------------
Report forwarded to debian-bugs-dist@lists.debian.org, Martin Mitchell
<martin@debian.org>:
Bug#29000; Package cdtool. Full text available.
  ------------------------------------------------------------------------
Ian Jackson / owner@bugs.debian.org, through the Debian bug database
Last modified: 12:39:01 GMT Wed 08 Sep (timestamp page available).