POE-Component-CD-Rip
view release on metacpan or search on metacpan
#
# CD ripping POE component
# Copyright (c) Erick Calder, 2002.
# All rights reserved.
#
package POE::Component::CD::Rip;
# --- external modules --------------------------------------------------------
use warnings;
use strict;
use Carp;
use POE qw(Wheel::Run Filter::Line Driver::SysRW);
# --- module variables --------------------------------------------------------
use vars qw($VERSION);
$VERSION = substr q$Revision: 1.2 $, 10;
my %stat = (
':-)' => 'Normal operation, low/no jitter',
':-|' => 'Normal operation, considerable jitter',
':-/' => 'Read drift',
':-P' => 'Unreported loss of streaming in atomic read operation',
'8-|' => 'Finding read problems at same point during reread; hard to correct',
':-0' => 'SCSI/ATAPI transport error',
':-(' => 'Scratch detected',
';-(' => 'Gave up trying to perform a correction',
'8-X' => 'Aborted (as per -X) due to a scratch/skip',
':^D' => 'Finished extracting',
);
# --- module interface --------------------------------------------------------
sub new {
my $class = shift;
my $opts = shift;
my $self = bless({}, $class);
my %opts = !defined($opts) ? () : ref($opts) ? %$opts : ($opts, @_);
%$self = (%$self, %opts);
$self->{dev} ||= "/dev/cdrom";
$self->{alias} ||= "main";
$self->{status} ||= "status";
$self->{done} ||= "done";
return $self;
}
sub rip {
my $self = shift;
my ($n, $fn) = @_;
POE::Session->create(
inline_states => {
_start => \&_start,
_stop => \&_stop,
got_output => \&got_output,
got_error => \&got_error,
got_done => \&got_done
},
args => [$self, $n, $fn]
);
}
# --- session handlers --------------------------------------------------------
sub _start {
my ($heap, $self, $n, $fn) = @_[HEAP, ARG0 .. ARG2];
$heap->{self} = $self;
$heap->{n} = $n;
$heap->{fn} = $fn;
my @cmd = ("cdparanoia", "-d", $self->{dev}, $n, $fn);
$heap->{child} = POE::Wheel::Run->new(
Program => \@cmd,
StdioFilter => POE::Filter::Line->new(), # Child speaks in lines
Conduit => "pty",
StdoutEvent => "got_output", # Child wrote to STDOUT
CloseEvent => "got_done",
);
( run in 0.772 second using v1.01-cache-2.11-cpan-140bd7fdf52 )