From c5a84ec87cb903f37c5ddf9841432230c4f1c769 Mon Sep 17 00:00:00 2001 From: jq Date: Wed, 28 Mar 2007 15:59:21 +0000 Subject: [PATCH] [project @ 5762] inlining update_playlist() --- bin/mpd-dynamic | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/bin/mpd-dynamic b/bin/mpd-dynamic index 9b84b36..52b1990 100755 --- a/bin/mpd-dynamic +++ b/bin/mpd-dynamic @@ -24,8 +24,6 @@ use Getopt::Euclid qw[ :minimal_keys ]; use Proc::Daemon; use Time::HiRes qw[ usleep ]; -#use YAML; die Dump(\%ARGV); - Proc::Daemon::Init unless $ARGV{debug}; # @@ -42,23 +40,15 @@ while (1) { # endless loop eval { $status = $mpd->status }; next if $@; # error while peaking status + # do playlist and/or current song have changed? next unless $status->playlist > $playlist || defined $status->song && $status->song != $song; - # playlist and/or current song has changed + + # yup - update playlist & song. $playlist = $status->playlist; $song = $status->song; - update_playlist(); - -} continue { - usleep $ARGV{sleep} * 1000 * 1000; -} - -exit; # should not be there... - - -sub update_playlist { # keep at most $ARGV{old} songs. if ( $song > $ARGV{old} ) { my $old = $song - $ARGV{old}; @@ -71,8 +61,13 @@ sub update_playlist { my $new = $ARGV{new} - ( $#$pl - $song ); eval { $mpd->add( $files[ rand @files ] ) for 1..$new }; } + +} continue { + usleep $ARGV{sleep} * 1000 * 1000; } +exit; # should not be there... + __END__ -- 2.11.4.GIT