From 401921f0530b711afaccacea47a401128efea8df Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Sun, 21 Nov 2021 08:47:38 +0000 Subject: [PATCH] whitespace --- lib/App/MPD/Feeder.pm | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/lib/App/MPD/Feeder.pm b/lib/App/MPD/Feeder.pm index e9029c9..e5c2b70 100644 --- a/lib/App/MPD/Feeder.pm +++ b/lib/App/MPD/Feeder.pm @@ -29,7 +29,7 @@ use constant DEFAULT_CONFIG_FILE => '/etc/mpd-feeder/mpd-feeder.conf'; ADJUST { Getopt::Long::Configure('pass_through'); - Getopt::Long::GetOptions('cfg|config=s' => \$cfg_file); + Getopt::Long::GetOptions( 'cfg|config=s' => \$cfg_file ); Getopt::Long::Configure('no_pass_through'); $cfg_file //= DEFAULT_CONFIG_FILE if -e DEFAULT_CONFIG_FILE; @@ -116,7 +116,8 @@ method connect_mpd { IO::Async::Signal->new( name => 'USR1', on_receipt => sub { - $log->debug("SIGUSR1 received. Dumping configuration to STDERR"); + $log->debug( + "SIGUSR1 received. Dumping configuration to STDERR"); my $old = select \*STDERR; try { $opt->dump; @@ -134,8 +135,8 @@ method connect_db { $self->update_db; } -method update_db($force = undef) { - if (!$db_needs_update and !$force) { +method update_db( $force = undef ) { + if ( !$db_needs_update and !$force ) { $log->debug("Skipping DB update"); return; } @@ -181,9 +182,9 @@ method update_db($force = undef) { } } -method queue_songs($num = undef) { +method queue_songs( $num = undef ) { $self->connect_db; - if (!defined $num) { + if ( !defined $num ) { $self->connect_mpd; $log->trace("Requesting playlist"); my $present = $mpd->send('playlist')->get // []; @@ -192,8 +193,7 @@ method queue_songs($num = undef) { $log->notice( "Playlist contains $present songs. Wanted: " . $opt->target_queue_length ); if ( $present < $opt->target_queue_length ) { - $self->queue_songs( - $opt->target_queue_length - $present ); + $self->queue_songs( $opt->target_queue_length - $present ); } return; @@ -222,6 +222,7 @@ method queue_songs($num = undef) { } $log->debug( "Adding " . join( ', ', map {"«$_»"} @paths ) ); + # MPD needs raw bytes utf8::encode($_) for @paths; my @commands; @@ -258,11 +259,10 @@ method handle_work_queue { $log->notice("disconnecting and re-starting"); $self->stop; - my @exec = - ( $0, '--config', $self->cfg_file, '--skip-db-update' ); + my @exec = ( $0, '--config', $self->cfg_file, '--skip-db-update' ); if ( $log->is_trace ) { - $log->trace( 'exec ' - . join( ' ', map { /\s/ ? "'$_'" : $_ } @exec ) ); + $log->trace( + 'exec ' . join( ' ', map { /\s/ ? "'$_'" : $_ } @exec ) ); } exec(@exec); } @@ -278,10 +278,10 @@ method handle_work_queue { } method break_idle { - if ($idler && !$idler->is_ready) { + if ( $idler && !$idler->is_ready ) { $log->trace("hand-sending 'noidle'"); undef $idler; - $mpd->{mpd_handle}->write("noidle\n");; + $mpd->{mpd_handle}->write("noidle\n"); } else { $log->trace("no idler found"); @@ -299,13 +299,14 @@ method run_loop { if ( time - $last_mpd_comm > 300 ) { $log->trace( - "no active MPD communication for more that 5 minutes" - ); + "no active MPD communication for more that 5 minutes"); $log->trace("forcing alive check"); $self->break_idle; } else { - $log->trace("contacted MPD less than 5 minutes ago. skipping alive check"); + $log->trace( + "contacted MPD less than 5 minutes ago. skipping alive check" + ); } }, )->start @@ -316,13 +317,13 @@ method run_loop { for ( ;; ) { $log->debug("Waiting idle. PID=$$"); $last_mpd_comm = time; - $idler = $mpd->send("idle database playlist"); + $idler = $mpd->send("idle database playlist"); my $result = $idler->get; undef $idler; - if ($result and $result->{changed}){ + if ( $result and $result->{changed} ) { my $changed = $result->{changed}; - $changed = [ $changed ] unless ref $changed; + $changed = [$changed] unless ref $changed; $mpd->emit($_) for @$changed; } -- 2.39.5