| 1 | package Net::Async::MPD; | ||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||
| 6 | 2 | our $VERSION = '0.005'; | |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use IO::Async::Loop; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use IO::Async::Stream; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use IO::Socket::IP; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use Future::Utils qw( repeat ); | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 12 | 2 | ▶ | use Scalar::Util qw( weaken ); | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||
| 17 | 2 | ▶ | use Moo; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 18 | 2 | ▶ | use MooX::HandlesVia; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 19 | 2 | with 'Role::EventEmitter'; | |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||
| 21 | 2 | ▶ | use Types::Standard qw( | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 22 | InstanceOf Int ArrayRef HashRef Str Maybe Bool CodeRef | ||||||||||||||||||||||||||||||
| 23 | 2 | ); | |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||
| 25 | 2 | ▶ | use Log::Any; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 26 | 2 | my $log = Log::Any->get_logger( category => __PACKAGE__ ); | |||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||
| 28 | 2 | has auto_connect => ( | |||||||||||||||||||||||||||||
| 29 | is => 'ro', | ||||||||||||||||||||||||||||||
| 30 | isa => Bool, | ||||||||||||||||||||||||||||||
| 31 | default => 0, | ||||||||||||||||||||||||||||||
| 32 | ); | ||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||
| 34 | has state => ( | ||||||||||||||||||||||||||||||
| 35 | is => 'rw', | ||||||||||||||||||||||||||||||
| 36 | isa => Str, | ||||||||||||||||||||||||||||||
| 37 | init_arg => undef, | ||||||||||||||||||||||||||||||
| 38 | default => 'created', | ||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | trigger => sub { | ||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||
| 40 | 0 | $_[0]->emit( state => $_[0]->{state} ); | |||||||||||||||||||||||||||||
| 41 | }, | ||||||||||||||||||||||||||||||
| 42 | 2 | ); | |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||
| 44 | has loop => ( | ||||||||||||||||||||||||||||||
| 45 | is => 'ro', | ||||||||||||||||||||||||||||||
| 46 | lazy => 1, | ||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | default => sub { IO::Async::Loop->new }, | ||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||
| 48 | 2 | ); | |||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||
| 50 | has read_queue => ( | ||||||||||||||||||||||||||||||
| 51 | is => 'ro', | ||||||||||||||||||||||||||||||
| 52 | isa => ArrayRef [CodeRef], | ||||||||||||||||||||||||||||||
| 53 | lazy => 1, | ||||||||||||||||||||||||||||||
| 54 | init_arg => undef, | ||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | default => sub { [] }, | ||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||
| 56 | 2 | handles_via => 'Array', | |||||||||||||||||||||||||||||
| 57 | handles => { | ||||||||||||||||||||||||||||||
| 58 | push_read => 'push', | ||||||||||||||||||||||||||||||
| 59 | pop_read => 'pop', | ||||||||||||||||||||||||||||||
| 60 | shift_read => 'shift', | ||||||||||||||||||||||||||||||
| 61 | unshift_read => 'unshift', | ||||||||||||||||||||||||||||||
| 62 | }, | ||||||||||||||||||||||||||||||
| 63 | ); | ||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||
| 65 | 2 | has password => ( | |||||||||||||||||||||||||||||
| 66 | is => 'ro', | ||||||||||||||||||||||||||||||
| 67 | isa => Maybe[Str], | ||||||||||||||||||||||||||||||
| 68 | lazy => 1, | ||||||||||||||||||||||||||||||
| 69 | ); | ||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||
| 71 | has port => ( | ||||||||||||||||||||||||||||||
| 72 | is => 'ro', | ||||||||||||||||||||||||||||||
| 73 | isa => Int, | ||||||||||||||||||||||||||||||
| 74 | lazy => 1, | ||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | default => sub { $ENV{MPD_PORT} // 6600 }, | ||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Condition0%0/2
$ENV{"MPD_PORT"} // 6600
MC/DC0%0/1
$ENV{"MPD_PORT"} // 6600
$ENV{"MPD_PORT"}
Truth table0%0/2
A
A= $ENV{"MPD_PORT"}
| |||||||||||||||||||||||||||||||
| 76 | 2 | ); | |||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||
| 78 | has host => ( | ||||||||||||||||||||||||||||||
| 79 | is => 'ro', | ||||||||||||||||||||||||||||||
| 80 | isa => Str, | ||||||||||||||||||||||||||||||
| 81 | lazy => 1, | ||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | default => sub { $ENV{MPD_HOST} // 'localhost' }, | ||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Condition0%0/2
$ENV{"MPD_HOST"} // "localhost"
MC/DC0%0/1
$ENV{"MPD_HOST"} // "localhost"
$ENV{"MPD_HOST"}
Truth table0%0/2
A
A= $ENV{"MPD_HOST"}
| |||||||||||||||||||||||||||||||
| 83 | 2 | ); | |||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | sub version { $_[0]->{version} }; | ||||||||||||||||||||||||||||
|
Subroutine
version: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | sub _parse_block { | ||||||||||||||||||||||||||||
|
Subroutine
_parse_block: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||
| 88 | 0 | my $self = shift; | |||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | return sub { | ||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=9 SCAR=45.0
| |||||||||||||||||||||||||||||||
| 91 | 0 | my ( $handle, $buffref, $eof ) = @_; | |||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | while ( $$buffref =~ s/^(.*)\n// ) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 94 | 0 | my $line = $1; | |||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | if ($line =~ /\w/) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 97 | 0 | $log->tracef('< %s', $line); | |||||||||||||||||||||||||||||
| 98 | 0 | ▶ | if ($line =~ /^OK/) { | ||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | if ($line =~ /OK MPD (.*)/) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 100 | 0 | $log->trace('Connection established'); | |||||||||||||||||||||||||||||
| 101 | 0 | $self->{version} = $1; | |||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||
| 103 | 0 | ▶ | $self->send( password => $self->password ) | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 104 | if $self->password; | ||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||
| 106 | 0 | $self->state( 'ready' ); | |||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||
| 108 | else { | ||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | pop @{$self->{mpd_buffer}} unless @{$self->{mpd_buffer}[-1]}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 110 | 0 | $self->shift_read->( 1, $self->{mpd_buffer} ); | |||||||||||||||||||||||||||||
| 111 | 0 | $self->{mpd_buffer} = [[]]; | |||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||
| 114 | elsif ($line =~ /^list_OK/) { | ||||||||||||||||||||||||||||||
| 115 | 0 | push @{$self->{mpd_buffer}}, []; | |||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||
| 117 | elsif ($line =~ /^ACK/) { | ||||||||||||||||||||||||||||||
| 118 | 0 | $self->shift_read->( 0, $line ); | |||||||||||||||||||||||||||||
| 119 | 0 | $self->{mpd_buffer} = [[]]; | |||||||||||||||||||||||||||||
| 120 | 0 | last; | |||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||
| 122 | else { | ||||||||||||||||||||||||||||||
| 123 | 0 | push @{$self->{mpd_buffer}[-1]}, $line; | |||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||
| 128 | 0 | return 0; | |||||||||||||||||||||||||||||
| 129 | 0 | }; | |||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||
| 132 | # Set up response parsers for each command | ||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | my $parsers = { none => sub { @_ } }; | ||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||
| 134 | { | ||||||||||||||||||||||||||||||
| 135 | 2 | ▶ | my $item = sub { | ||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=4.1
| |||||||||||||||||||||||||||||||
| 136 | return { | ||||||||||||||||||||||||||||||
| 137 | map { | ||||||||||||||||||||||||||||||
| 138 | 0 | my ($key, $value) = split /: /, $_, 2; | |||||||||||||||||||||||||||||
| 139 | 0 | $key => $value; | |||||||||||||||||||||||||||||
| 140 | 0 | } @{$_[0]} | |||||||||||||||||||||||||||||
| 141 | }; | ||||||||||||||||||||||||||||||
| 142 | 2 | }; | |||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | my $flat_list = sub { [ map { (split /: /, $_, 2)[1] } @{$_[0]} ] }; | ||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=3.5
| |||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | my $base_list = sub { | ||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||
| 147 | 0 | my @main_keys = @{shift()}; | |||||||||||||||||||||||||||||
| 148 | 0 | my @list_keys = @{shift()}; | |||||||||||||||||||||||||||||
| 149 | 0 | my @lines = @{shift()}; | |||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||
| 151 | 0 | my @return; | |||||||||||||||||||||||||||||
| 152 | 0 | my $item = {}; | |||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||
| 154 | 0 | foreach my $line (@lines) { | |||||||||||||||||||||||||||||
| 155 | 0 | my ($key, $value) = split /: /, $line, 2; | |||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | if ( grep { /$key/ } @main_keys ) { | ||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | push @return, $item if defined $item->{$key}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 159 | 0 | $item = { $key => $value }; | |||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||
| 161 | 0 | elsif ( grep { /$key/ } @list_keys ) { | |||||||||||||||||||||||||||||
| 162 | 0 | ▶ | unless (defined $item->{$key}) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 163 | 0 | $item->{$key} = [] | |||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||
| 165 | 0 | push @{$item->{$key}}, $value; | |||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||
| 167 | else { | ||||||||||||||||||||||||||||||
| 168 | 0 | $item->{$key} = $value; | |||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | push @return, $item if keys %{$item}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||
| 173 | 0 | return \@return; | |||||||||||||||||||||||||||||
| 174 | 2 | }; | |||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | my $grouped_list = sub { | ||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||||
| 177 | 0 | my @lines = @{shift()}; | |||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||
| 179 | # Our main category comes at the top of the list of lines | ||||||||||||||||||||||||||||||
| 180 | 0 | my ($main) = split /:\s+/, $lines[0], 2; | |||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||
| 182 | # Make a list of any other categories we might have | ||||||||||||||||||||||||||||||
| 183 | 0 | my @categories; | |||||||||||||||||||||||||||||
| 184 | 0 | foreach (@lines) { | |||||||||||||||||||||||||||||
| 185 | 0 | my ($key) = split /:\s+/, $_, 2; | |||||||||||||||||||||||||||||
| 186 | 0 | ▶ | if ($key eq $main) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | last if @categories; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||
| 189 | else { | ||||||||||||||||||||||||||||||
| 190 | 0 | push @categories, $key; | |||||||||||||||||||||||||||||
| 191 | }; | ||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||
| 194 | 0 | my $return = {}; | |||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | while (@lines) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 197 | # Generate a has with all the data returned for a single item | ||||||||||||||||||||||||||||||
| 198 | # This will be over several lines if we are grouping | ||||||||||||||||||||||||||||||
| 199 | 0 | my $item = do { | |||||||||||||||||||||||||||||
| 200 | 0 | my $set; | |||||||||||||||||||||||||||||
| 201 | 0 | my %missing_keys = map { $_ => 1 } $main, @categories; | |||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | while ( my $line = shift @lines ) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 204 | 0 | my ($key, $value) = split /:\s+/, $line, 2; | |||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||
| 206 | 0 | $set->{$key} = $value; | |||||||||||||||||||||||||||||
| 207 | 0 | delete $missing_keys{$key}; | |||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | last unless %missing_keys; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||
| 212 | 0 | $set; | |||||||||||||||||||||||||||||
| 213 | }; | ||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||
| 215 | # Find or create the array of results we need to push the data into | ||||||||||||||||||||||||||||||
| 216 | 0 | my $pointer = $return; | |||||||||||||||||||||||||||||
| 217 | 0 | for my $category (@categories) { | |||||||||||||||||||||||||||||
| 218 | 0 | ▶ | my $value = $item->{$category} // ''; | ||||||||||||||||||||||||||||
|
Condition0%0/2
$item->{$category} // ""
MC/DC0%0/1
$item->{$category} // ""
$item->{$category}
Truth table0%0/2
A
A= $item->{$category}
| |||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | $pointer = $pointer->{$category}{$value} //= {}; | ||||||||||||||||||||||||||||
|
Condition0%0/2
$pointer->{$category}{$value} //= {}
MC/DC0%0/1
$pointer->{$category}{$value} //= {}
$pointer->{$category}{$value}
Truth table0%0/2
A
A= $pointer->{$category}{$value}
| |||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||
| 222 | 0 | ▶ | push @{ $pointer->{$main} //= [] }, delete $item->{$main}; | ||||||||||||||||||||||||||||
|
Condition0%0/2
$pointer->{$main} //= []
MC/DC0%0/1
$pointer->{$main} //= []
$pointer->{$main}
Truth table0%0/2
A
A= $pointer->{$main}
| |||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||
| 225 | 0 | return $return; | |||||||||||||||||||||||||||||
| 226 | 2 | }; | |||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||
| 228 | # Untested commands: what do they return? | ||||||||||||||||||||||||||||||
| 229 | # consume | ||||||||||||||||||||||||||||||
| 230 | # crossfade | ||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||
| 232 | 0 | ▶ | my $file_list = sub { $base_list->( [qw( directory file )], [], @_ ) }; | ||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||
| 234 | 2 | $parsers->{$_} = $flat_list foreach qw( | |||||||||||||||||||||||||||||
| 235 | commands notcommands channels tagtypes urlhandlers listplaylist | ||||||||||||||||||||||||||||||
| 236 | ); | ||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||
| 238 | 2 | $parsers->{$_} = $item foreach qw( | |||||||||||||||||||||||||||||
| 239 | currentsong stats idle status addid update | ||||||||||||||||||||||||||||||
| 240 | readcomments replay_gain_status rescan | ||||||||||||||||||||||||||||||
| 241 | ); | ||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||
| 243 | 2 | $parsers->{$_} = $file_list foreach qw( | |||||||||||||||||||||||||||||
| 244 | find playlistinfo listallinfo search find playlistid playlistfind | ||||||||||||||||||||||||||||||
| 245 | listfiles plchanges listplaylistinfo playlistsearch listfind | ||||||||||||||||||||||||||||||
| 246 | ); | ||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||
| 248 | 2 | $parsers->{list} = $grouped_list; | |||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||
| 250 | 2 | foreach ( | |||||||||||||||||||||||||||||
| 251 | [ outputs => [qw( outputid )], [] ], | ||||||||||||||||||||||||||||||
| 252 | [ plchangesposid => [qw( cpos )], [] ], | ||||||||||||||||||||||||||||||
| 253 | [ listplaylists => [qw( playlist )], [] ], | ||||||||||||||||||||||||||||||
| 254 | [ listmounts => [qw( mount )], [] ], | ||||||||||||||||||||||||||||||
| 255 | [ listneighbors => [qw( neighbor )], [] ], | ||||||||||||||||||||||||||||||
| 256 | [ listall => [qw( directory )], [qw( file )] ], | ||||||||||||||||||||||||||||||
| 257 | [ readmessages => [qw( channel )], [qw( message )] ], | ||||||||||||||||||||||||||||||
| 258 | [ lsinfo => [qw( directory file playlist )], [] ], | ||||||||||||||||||||||||||||||
| 259 | [ decoders => [qw( plugin )], [qw( suffix mime_type )] ], | ||||||||||||||||||||||||||||||
| 260 | ) { | ||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||
| 262 | 18 | my ($cmd, $header, $list) = @{$_}; | |||||||||||||||||||||||||||||
| 263 | 0 | ▶ | $parsers->{$cmd} = sub { $base_list->( $header, $list, @_ ) }; | ||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | $parsers->{playlist} = sub { | ||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||
| 267 | 0 | my $lines = [ map { s/^\w*?://; $_ } @{shift()} ]; | |||||||||||||||||||||||||||||
| 268 | 0 | $flat_list->( $lines, @_ ) | |||||||||||||||||||||||||||||
| 269 | 2 | }; | |||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | $parsers->{count} = sub { | ||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||
| 272 | 0 | my $lines = shift; | |||||||||||||||||||||||||||||
| 273 | 0 | my ($main) = split /:\s+/, $lines->[0], 2; | |||||||||||||||||||||||||||||
| 274 | 0 | $base_list->( [ $main ], [qw( )], $lines, @_ ) | |||||||||||||||||||||||||||||
| 275 | 2 | }; | |||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | $parsers->{sticker} = sub { | ||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||
| 278 | 0 | my $lines = shift; | |||||||||||||||||||||||||||||
| 279 | 0 | ▶ | return {} unless scalar @{$lines}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||
| 281 | 0 | my $single = ($lines->[0] !~ /^file/); | |||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||
| 283 | 0 | my $base = $base_list->( [qw( file )], [qw( sticker )], $lines, @_ ); | |||||||||||||||||||||||||||||
| 284 | my $return = [ map { | ||||||||||||||||||||||||||||||
| 285 | 0 | $_->{sticker} = { map { split(/=/, $_, 2) } @{$_->{sticker}} }; $_; | |||||||||||||||||||||||||||||
| 286 | 0 | } @{$base} ]; | |||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||
| 288 | 0 | ▶ | return $single ? $return->[0] : $return; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 289 | 2 | }; | |||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||
| 292 | 0 | ▶ | sub idle { | ||||||||||||||||||||||||||||
|
Subroutine
idle: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||
| 293 | 0 | my ($self, @subsystems) = @_; | |||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||
| 295 | 0 | $self->{idle_future} = $self->loop->new_future; | |||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||
| 297 | 0 | weaken $self; | |||||||||||||||||||||||||||||
| 298 | 0 | ▶ | repeat { | ||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | $self->send( idle => @subsystems, sub { | ||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||
| 300 | 0 | $self->emit( shift->{changed} ); | |||||||||||||||||||||||||||||
| 301 | 0 | }); | |||||||||||||||||||||||||||||
| 302 | 0 | ▶ | } until => sub { $self->{idle_future}->is_ready }; | ||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||
| 304 | 0 | return $self->{idle_future}; | |||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | sub noidle { | ||||||||||||||||||||||||||||
|
Subroutine
noidle: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||
| 308 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||
| 310 | 0 | my $idle = $self->{idle_future}; | |||||||||||||||||||||||||||||
| 311 | 0 | ▶ | return unless defined $idle; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 312 | 0 | ▶ | return if $idle->is_ready; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||
| 314 | 0 | $self->send( 'noidle' ); | |||||||||||||||||||||||||||||
| 315 | 0 | $idle->done; | |||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||
| 317 | 0 | return; | |||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||
| 320 | 0 | ▶ | sub send { | ||||||||||||||||||||||||||||
|
Subroutine
send: not called CC=20 SCAR=60.4
Pod
documented
| |||||||||||||||||||||||||||||||
| 321 | 0 | my $self = shift; | |||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||
| 323 | 0 | ▶ | my $opt = ( ref $_[0] eq 'HASH' ) ? shift : {}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 324 | 0 | ▶ | my $cb = pop if ref $_[-1] eq 'CODE'; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 325 | 0 | my (@commands) = @_; | |||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||
| 327 | 0 | ▶ | croak 'Need commands to send' | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 328 | unless @commands; | ||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||
| 330 | # Normalise input | ||||||||||||||||||||||||||||||
| 331 | 0 | ▶ | if (ref $commands[0] eq 'ARRAY') { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 332 | @commands = map { | ||||||||||||||||||||||||||||||
| 333 | 0 | ▶ | ( ref $_ eq 'ARRAY' ) ? join( q{ }, @{$_} ) : $_; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 334 | 0 | } @{$commands[0]}; | |||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||
| 336 | else { | ||||||||||||||||||||||||||||||
| 337 | 0 | @commands = join q{ }, @commands; | |||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||
| 340 | 0 | my $command = ''; | |||||||||||||||||||||||||||||
| 341 | # Remove underscores from (most) command names | ||||||||||||||||||||||||||||||
| 342 | @commands = map { | ||||||||||||||||||||||||||||||
| 343 | 0 | my $args; | |||||||||||||||||||||||||||||
| 344 | 0 | ($command, $args) = split /\s/, $_, 2; | |||||||||||||||||||||||||||||
| 345 | 0 | ▶ | $command =~ s/_//g unless $command =~ /^(replay_gain_|command_list)/; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 346 | 0 | ▶ | $args //= q{}; | ||||||||||||||||||||||||||||
|
Condition0%0/2
$args //= ""
MC/DC0%0/1
$args //= ""
$args
Truth table0%0/2
A
A= $args
| |||||||||||||||||||||||||||||||
| 347 | 0 | ▶ | $command . ($args ne q{} ? " $args" : q{}); | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 348 | } @commands; | ||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||
| 350 | # Ensure a command list if sending multiple commands | ||||||||||||||||||||||||||||||
| 351 | 0 | ▶ | if (scalar @commands > 1) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 352 | 0 | ▶ | my $list = $opt->{list} // 1; | ||||||||||||||||||||||||||||
|
Condition0%0/2
$opt->{"list"} // 1
MC/DC0%0/1
$opt->{"list"} // 1
$opt->{"list"}
Truth table0%0/2
A
A= $opt->{"list"}
| |||||||||||||||||||||||||||||||
| 353 | 0 | ▶ | my $list_start = | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 354 | 'command_list' . ( $list ? '_ok' : q{} ) . '_begin'; | ||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||
| 356 | 0 | ▶ | unshift @commands, $list_start | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 357 | unless $commands[0] =~ /^command_list/; | ||||||||||||||||||||||||||||||
| 358 | 0 | ▶ | push @commands, 'command_list_end' | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 359 | unless $commands[-1] =~ /^command_list/; | ||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||
| 362 | 0 | my $parser; | |||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||
| 364 | 0 | ▶ | if (defined $opt->{parser}) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 365 | 0 | my $input = delete $opt->{parser}; | |||||||||||||||||||||||||||||
| 366 | 0 | ▶ | $parser = (ref $input eq 'CODE') ? $input : $parsers->{$input}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 367 | 0 | ▶ | croak 'Not a code reference or recognised parser name' | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 368 | unless defined $parser; | ||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||
| 370 | else { | ||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | $parser = sub { | ||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||
| 372 | 0 | my ($input, $commands) = @_; | |||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||
| 374 | my @result = map { | ||||||||||||||||||||||||||||||
| 375 | 0 | my $command; | |||||||||||||||||||||||||||||
| 376 | 0 | ▶ | do { $command = shift @{$commands} } | ||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $command && $command =~ /^command_list/
MC/DC0%0/2
defined $command && $command =~ /^command_list/
defined $command
$command =~ /^command_list/
Truth table0%0/3
A && B
A= defined $commandB= $command =~ /^command_list/
| |||||||||||||||||||||||||||||||
| 377 | until !defined $command or $command !~ /^command_list/; | ||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||
| 379 | 0 | ▶ | my $sub = $parsers->{$command // ''} // $parsers->{none}; | ||||||||||||||||||||||||||||
|
Condition0%0/5
$$parsers{$command // ""} // $parsers->{"none"}
$command // ""
MC/DC0%0/2
$$parsers{$command // ""} // $parsers->{"none"}
$$parsers{$command // ""}
$parsers->{"none"}
MC/DC0%0/1
$command // ""
$command
Truth table0%0/3
A // B
A= $$parsers{$command // ""}B= $parsers->{"none"}
Truth table0%0/2
A
A= $command
| |||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||
| 381 | 0 | $sub->( $input->[$_] ); | |||||||||||||||||||||||||||||
| 382 | 0 | } 0 .. $#{$input}; | |||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||
| 384 | return @result | ||||||||||||||||||||||||||||||
| 385 | 0 | }; | |||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||
| 388 | 0 | my $future = $self->loop->new_future; | |||||||||||||||||||||||||||||
| 389 | 0 | ▶ | $future->on_done( $cb ) if $cb; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||
| 391 | return $future->fail('No connection to MPD server' ) | ||||||||||||||||||||||||||||||
| 392 | 0 | ▶ | unless $self->{mpd_handle}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||
| 394 | 0 | ▶ | $self->push_read( sub { | ||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||
| 395 | 0 | my ($success, $result) = @_; | |||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||
| 397 | 0 | ▶ | if ($success) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 398 | $future->done( $parser->( | ||||||||||||||||||||||||||||||
| 399 | 0 | $result, [ map { my ($name) = split /\s/, $_, 2 } @commands ] | |||||||||||||||||||||||||||||
| 400 | )); | ||||||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||||
| 402 | else { | ||||||||||||||||||||||||||||||
| 403 | 0 | $self->emit( error => $result ); | |||||||||||||||||||||||||||||
| 404 | 0 | $future->fail( $result ); | |||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||
| 406 | 0 | }); | |||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||
| 408 | 0 | $log->tracef( '> %s', $_ ) foreach @commands; | |||||||||||||||||||||||||||||
| 409 | 0 | $self->{mpd_handle}->write( join("\n", @commands) . "\n" ); | |||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||
| 411 | 0 | return $future; | |||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||
| 414 | 0 | ▶ | sub get { shift->send( @_ )->get } | ||||||||||||||||||||||||||||
|
Subroutine
get: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||
| 416 | 0 | ▶ | sub until { | ||||||||||||||||||||||||||||
|
Subroutine
until: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||
| 417 | 0 | my ($self, $name, $check, $cb) = @_; | |||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||
| 419 | 0 | weaken $self; | |||||||||||||||||||||||||||||
| 420 | 0 | my $wrapper; | |||||||||||||||||||||||||||||
| 421 | 0 | ▶ | $wrapper = sub { | ||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||
| 422 | 0 | ▶ | if ($check->(@_)) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 423 | 0 | $self->unsubscribe($name => $wrapper); | |||||||||||||||||||||||||||||
| 424 | 0 | $cb->(@_); | |||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||
| 426 | 0 | }; | |||||||||||||||||||||||||||||
| 427 | 0 | $self->on($name => $wrapper); | |||||||||||||||||||||||||||||
| 428 | 0 | weaken $wrapper; | |||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||
| 430 | 0 | return $wrapper; | |||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||
| 433 | 1 | ▶ | sub BUILD { | ||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 434 | 1 | my ($self, $args) = @_; | |||||||||||||||||||||||||||||
| 435 | 1 | ▶ | $self->connect->get if $self->auto_connect; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 436 | 1 | ▶ | $self->catch( sub {} ); | ||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 437 | 1 | $self->{mpd_buffer} = [[]]; | |||||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||
| 440 | 0 | ▶ | sub connect { | ||||||||||||||||||||||||||||
|
Subroutine
connect: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 441 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||
| 442 | 0 | my $loop = $self->loop; | |||||||||||||||||||||||||||||
| 443 | 0 | my $connected = $loop->new_future; | |||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||
| 445 | 0 | ▶ | return $connected->done if $self->state eq 'ready'; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||
| 447 | 0 | ▶ | my $socket = IO::Socket::IP->new($self->host . ':' . $self->port) | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 448 | or return $connected->fail("MPD connect failed: $!"); | ||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||
| 450 | 0 | $log->debugf('Connecting to %s:%s', $self->host, $self->port); | |||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||
| 452 | 0 | ▶ | my $on_error = sub { $self->emit( error => shift ) }; | ||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||
| 454 | my $handle = IO::Async::Stream->new( | ||||||||||||||||||||||||||||||
| 455 | handle => $socket, | ||||||||||||||||||||||||||||||
| 456 | 0 | ▶ | on_read_error => sub { $on_error->('Read error: ' . shift) }, | ||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||
| 457 | 0 | ▶ | on_write_error => sub { $on_error->('Write error: ' . shift) }, | ||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||
| 458 | 0 | ▶ | on_read_eof => sub { shift->close }, | ||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||
| 459 | 0 | ▶ | on_closed => sub { | ||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||
| 460 | 0 | $self->{mpd_handle} = undef; | |||||||||||||||||||||||||||||
| 461 | 0 | $self->emit( 'close' ); | |||||||||||||||||||||||||||||
| 462 | }, | ||||||||||||||||||||||||||||||
| 463 | 0 | on_read => $self->_parse_block, | |||||||||||||||||||||||||||||
| 464 | ); | ||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||
| 466 | 0 | ▶ | unless ($self->{mpd_handle}) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 467 | 0 | $self->{mpd_handle} = $handle; | |||||||||||||||||||||||||||||
| 468 | 0 | $loop->add( $handle ); | |||||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||
| 471 | $self->until( state => | ||||||||||||||||||||||||||||||
| 472 | 0 | ▶ | sub { $_[1] eq 'ready' }, | ||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||
| 473 | 0 | ▶ | sub { $connected->done; } | ||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||
| 474 | 0 | ); | |||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||
| 476 | 0 | return $connected; | |||||||||||||||||||||||||||||
| 477 | } | ||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||
| 479 | 2 | 1; | |||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||
| 481 | __END__ | ||||||||||||||||||||||||||||||