| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# |
|
2
|
|
|
|
|
|
|
# CD ripping POE component |
|
3
|
|
|
|
|
|
|
# Copyright (c) Erick Calder, 2002. |
|
4
|
|
|
|
|
|
|
# All rights reserved. |
|
5
|
|
|
|
|
|
|
# |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package POE::Component::CD::Rip; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# --- external modules -------------------------------------------------------- |
|
10
|
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
6419
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
39
|
|
|
12
|
1
|
|
|
1
|
|
9
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
32
|
|
|
13
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
|
1
|
|
|
|
|
13
|
|
|
|
1
|
|
|
|
|
74
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
1962
|
use POE qw(Wheel::Run Filter::Line Driver::SysRW); |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# --- module variables -------------------------------------------------------- |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use vars qw($VERSION); |
|
20
|
|
|
|
|
|
|
$VERSION = substr q$Revision: 1.2 $, 10; |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my %stat = ( |
|
23
|
|
|
|
|
|
|
':-)' => 'Normal operation, low/no jitter', |
|
24
|
|
|
|
|
|
|
':-|' => 'Normal operation, considerable jitter', |
|
25
|
|
|
|
|
|
|
':-/' => 'Read drift', |
|
26
|
|
|
|
|
|
|
':-P' => 'Unreported loss of streaming in atomic read operation', |
|
27
|
|
|
|
|
|
|
'8-|' => 'Finding read problems at same point during reread; hard to correct', |
|
28
|
|
|
|
|
|
|
':-0' => 'SCSI/ATAPI transport error', |
|
29
|
|
|
|
|
|
|
':-(' => 'Scratch detected', |
|
30
|
|
|
|
|
|
|
';-(' => 'Gave up trying to perform a correction', |
|
31
|
|
|
|
|
|
|
'8-X' => 'Aborted (as per -X) due to a scratch/skip', |
|
32
|
|
|
|
|
|
|
':^D' => 'Finished extracting', |
|
33
|
|
|
|
|
|
|
); |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# --- module interface -------------------------------------------------------- |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub new { |
|
38
|
|
|
|
|
|
|
my $class = shift; |
|
39
|
|
|
|
|
|
|
my $opts = shift; |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my $self = bless({}, $class); |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my %opts = !defined($opts) ? () : ref($opts) ? %$opts : ($opts, @_); |
|
44
|
|
|
|
|
|
|
%$self = (%$self, %opts); |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
$self->{dev} ||= "/dev/cdrom"; |
|
47
|
|
|
|
|
|
|
$self->{alias} ||= "main"; |
|
48
|
|
|
|
|
|
|
$self->{status} ||= "status"; |
|
49
|
|
|
|
|
|
|
$self->{done} ||= "done"; |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
return $self; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub rip { |
|
55
|
|
|
|
|
|
|
my $self = shift; |
|
56
|
|
|
|
|
|
|
my ($n, $fn) = @_; |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
POE::Session->create( |
|
59
|
|
|
|
|
|
|
inline_states => { |
|
60
|
|
|
|
|
|
|
_start => \&_start, |
|
61
|
|
|
|
|
|
|
_stop => \&_stop, |
|
62
|
|
|
|
|
|
|
got_output => \&got_output, |
|
63
|
|
|
|
|
|
|
got_error => \&got_error, |
|
64
|
|
|
|
|
|
|
got_done => \&got_done |
|
65
|
|
|
|
|
|
|
}, |
|
66
|
|
|
|
|
|
|
args => [$self, $n, $fn] |
|
67
|
|
|
|
|
|
|
); |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# --- session handlers -------------------------------------------------------- |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub _start { |
|
73
|
|
|
|
|
|
|
my ($heap, $self, $n, $fn) = @_[HEAP, ARG0 .. ARG2]; |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
$heap->{self} = $self; |
|
76
|
|
|
|
|
|
|
$heap->{n} = $n; |
|
77
|
|
|
|
|
|
|
$heap->{fn} = $fn; |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
my @cmd = ("cdparanoia", "-d", $self->{dev}, $n, $fn); |
|
80
|
|
|
|
|
|
|
$heap->{child} = POE::Wheel::Run->new( |
|
81
|
|
|
|
|
|
|
Program => \@cmd, |
|
82
|
|
|
|
|
|
|
StdioFilter => POE::Filter::Line->new(), # Child speaks in lines |
|
83
|
|
|
|
|
|
|
Conduit => "pty", |
|
84
|
|
|
|
|
|
|
StdoutEvent => "got_output", # Child wrote to STDOUT |
|
85
|
|
|
|
|
|
|
CloseEvent => "got_done", |
|
86
|
|
|
|
|
|
|
); |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub _stop { |
|
90
|
|
|
|
|
|
|
kill 9, $_[HEAP]->{child}->PID; |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub got_output { |
|
94
|
|
|
|
|
|
|
my ($kernel, $heap) = @_[KERNEL, HEAP]; |
|
95
|
|
|
|
|
|
|
local $_ = $_[ARG0]; |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
$heap->{from} = $1 if /from sector\s+(\d+)/; |
|
98
|
|
|
|
|
|
|
$heap->{to} = $1 if /to sector\s+(\d+)/; |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
if (/PROGRESS/) { |
|
101
|
|
|
|
|
|
|
my $blk = substr($_, 50, 6); $blk =~ s/\.+/$heap->{from}/; |
|
102
|
|
|
|
|
|
|
my $st = substr($_, 65, 3); # smiley |
|
103
|
|
|
|
|
|
|
my $stmsg = $stat{$st}; |
|
104
|
|
|
|
|
|
|
my $p = ($blk - $heap->{from}) / ($heap->{to} - $heap->{from}); |
|
105
|
|
|
|
|
|
|
$p = int(100 * $p); |
|
106
|
|
|
|
|
|
|
my $self = $heap->{self}; |
|
107
|
|
|
|
|
|
|
$kernel->post($self->{alias} |
|
108
|
|
|
|
|
|
|
, $self->{status} => [$blk, $p, $st, $stmsg] |
|
109
|
|
|
|
|
|
|
); |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub got_done { |
|
114
|
|
|
|
|
|
|
my ($kernel, $heap) = @_[KERNEL, HEAP]; |
|
115
|
|
|
|
|
|
|
my $self = $heap->{self}; |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
$kernel->post($self->{alias}, $self->{done}, $self->{fn}, $self->{n}); |
|
118
|
|
|
|
|
|
|
delete $heap->{child}; |
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub got_error { |
|
122
|
|
|
|
|
|
|
my ($kernel, $heap) = @_[KERNEL, HEAP]; |
|
123
|
|
|
|
|
|
|
my $self = $heap->{self}; |
|
124
|
|
|
|
|
|
|
$kernel->post($self->{alias}, $self->{error}); |
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
1; # :) |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
__END__ |