summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
0135556)
it may be hanging if for example the local system was suspended. in
this situation mpd would detect the missing peer (us) when e.g. reporting
idle changes and close the tcp socket. later, the local system resumes
and the local tcp connection is still open and waiting for an idle result
forever
use DBI;
use Getopt::Long;
use IO::Async::Signal;
use DBI;
use Getopt::Long;
use IO::Async::Signal;
+use IO::Async::Timer::Periodic;
use Log::Any qw($log);
use Net::Async::MPD;
use Object::Pad;
use Log::Any qw($log);
use Net::Async::MPD;
use Object::Pad;
has $db :reader;
has $db_needs_update :writer = 1;
has $mpd :reader;
has $db :reader;
has $db_needs_update :writer = 1;
has $mpd :reader;
use constant DEFAULT_CONFIG_FILE => '/etc/mpd-feeder/mpd-feeder.conf';
use constant DEFAULT_CONFIG_FILE => '/etc/mpd-feeder/mpd-feeder.conf';
method prepare_to_wait_idle {
$log->trace('declaring idle mode');
method prepare_to_wait_idle {
$log->trace('declaring idle mode');
- $mpd->send('idle database playlist')->on_done(
+ $idler = $mpd->send('idle database playlist')->on_done(
sub {
my $result = shift;
sub {
my $result = shift;
$self->connect_mpd;
$self->connect_db;
$self->connect_mpd;
$self->connect_db;
+ $mpd->loop->add(
+ IO::Async::Timer::Periodic->new(
+ interval => 300,
+ on_tick => sub {
+ if ($idler) {
+ $log->trace('breaking idle to see if MPD is there');
+ undef $idler;
+ $log->trace("> noidle (direct)");
+ $mpd->{mpd_handle}->write("noidle\n");
+ }
+ },
+ )->start
+ );
+
for ( ;; ) {
$self->queue_songs( undef, sub { $self->prepare_to_wait_idle } );
for ( ;; ) {
$self->queue_songs( undef, sub { $self->prepare_to_wait_idle } );