• Audio::CD quirk!

    From Angus McLeod@VERT/ANJO to All on Tuesday, June 20, 2006 14:33:00
    Anyone using Audio::CD to read disk info from their CD drive and do a CDDB/FreeDB lookup? I just found a quirk! Maybe it's something I'm not
    doing that I should, so please observe this proggy:

    #!/usr/bin/perl -w

    use Audio::CD;

    sub run_test {
    my $device = shift;
    my ($cd, $cddb, $data, $info, $cddb_t, $info_t, $i);

    print "==== testing $device ", "="x40, "\n";
    $cd = Audio::CD->init( $device );
    $cddb = $cd->cddb();

    printf "Disk ID = %08x\n", $cddb->discid();

    $data = $cddb->lookup();

    printf "Artist = %s\n", $data->artist();
    printf "Album = %s\n", $data->title();
    printf "Genre = %s\n", $data->genre();

    $info = $cd->stat();
    printf "Tracks = %d\n", $info->total_tracks();
    printf "Time = %2d:%02d\n", $info->time();
    printf "Length = %2d:%02d\n", $info->length();

    $cddb_t = $data->tracks( $info );
    $info_t = $info->tracks();

    for ($i=0; $i<=$#{$cddb_t}; $i++) {
    printf "%2d:%02d . %2d:%02d %s\n",
    ${$info_t}[$i]->pos(),
    ${$info_t}[$i]->length(),
    ${$cddb_t}[$i]->name();
    }


    }

    run_test( '/dev/dvd' );
    sleep 30;
    run_test( '/dev/dvd' );

    If you run this, it will print some info about the CD, and give you 30
    seconds to swap out the CD for aother one. Then it prints the info for
    the second CD.

    Here's the quirk: If you DON'T change the CD, it FAILS to do the lookup() properly the second time, and you get undefined/blank data. The thing is, even if you change the second call to use a different drive, like

    run_test( '/dev/burner' );

    and during the 30 seconds you move the SAME disk to the second drive, it
    STILL fails the second lookup().

    If you lookup() the CD, terminate the program and restart it, and lookup()
    the same CD again, all works well. But not if you do the lookup twice in
    a row, on the same CD in the same invocation of the program. If you do a lookup() on one CD, then on a different CD then attempt a lookup() on the first CD again, all works well.

    I gotta figure out how to work around this quirk. Anybody got any ideas?
    ---
    Playing: "Where do we go now but nowherer?"
    by "Nick Cave & The Bad Seeds" from "The boatman's call" album
    þ Synchronet þ Programatically generated on The ANJO BBS