[Slim-Checkins] r33656 - /7.7/trunk/server/Slim/Plugin/MOG/ProtocolHandler.pm

[email protected]
Newsgroups gmane.music.equipment.slimdevices.cvs
Message-ID <[email protected]>
Author: mherger
Date: Fri Nov  4 04:43:11 2011
New Revision: 33656

URL: http://svn.slimdevices.com/slim?rev=33656&view=rev
Log:
Bug: n/a
Description: delay MOG radio playlist handling after adding a track. Deleting/adding a lot of tracks might starve the player.

Modified:
    7.7/trunk/server/Slim/Plugin/MOG/ProtocolHandler.pm

Modified: 7.7/trunk/server/Slim/Plugin/MOG/ProtocolHandler.pm
URL: http://svn.slimdevices.com/slim/7.7/trunk/server/Slim/Plugin/MOG/ProtocolHandler.pm?rev=33656&r1=33655&r2=33656&view=diff
==============================================================================
--- 7.7/trunk/server/Slim/Plugin/MOG/ProtocolHandler.pm (original)
+++ 7.7/trunk/server/Slim/Plugin/MOG/ProtocolHandler.pm Fri Nov  4 04:43:11 2011
@@ -549,19 +549,30 @@
 	my ($trackId, $radioId) = getIds($url);
 	
 	if ( $radioId ) {
-		my $pos = Slim::Player::Source::playingSongIndex($client);
-
-		# remove played/skipped tracks from queue
-		while ($pos-- > 0) {
-			$client->execute([ 'playlist', 'delete', 0 ]);
-		}
-		
-		my $length = Slim::Player::Playlist::count($client);
-		
-		if ($length < MIN_RADIO_QUEUE) {
-			main::DEBUGLOG && $log->debug( "Need to queue up new MOG Radio tracks... $radioId" );
-			_getRadioTracks($client, $radioId);
-		}
+		# disable repeat in radio mode
+		Slim::Player::Playlist::repeat($client, 0);
+		
+		Slim::Utils::Timers::killTimers($client, \&_cleanupRadioTracks);
+		Slim::Utils::Timers::setTimer($client, time() + 5, \&_cleanupRadioTracks, $radioId);
+	}
+}
+
+sub _cleanupRadioTracks {
+	my ($client, $radioId) = @_;
+	
+	my $pos = Slim::Player::Source::playingSongIndex($client);
+
+	# remove played/skipped tracks from queue
+	if ($pos > 0) {
+		my @tracks = Slim::Player::Playlist::songs($client, 0, $pos-1);
+		$client->execute([ 'playlist', 'deletetracks', 'listRef', \@tracks ]) if scalar @tracks;
+	}
+	
+	my $length = Slim::Player::Playlist::count($client);
+	
+	if ($length < MIN_RADIO_QUEUE) {
+		main::DEBUGLOG && $log->debug( "Need to queue up new MOG Radio tracks... $radioId" );
+		_getRadioTracks($client, $radioId);
 	}
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.