[Slim-Checkins] r8920 - in /trunk/server/Slim: Buttons/Playlist.pm Music/Info.pm Player/Client.pm

adrian at svn.slimdevices.com adrian at svn.slimdevices.com
Thu Aug 10 15:35:00 PDT 2006


Author: adrian
Date: Thu Aug 10 15:34:57 2006
New Revision: 8920

URL: http://svn.slimdevices.com?rev=8920&view=rev
Log:
Bug: N/A
Description: add alternative to standardTitle to cache and return text
string for any title format.  Use for extended now playing which
separately fetches ARTIST and ALBUM etc for same song.
Potentially use for standardTitle - assuming similar performance

Modified:
    trunk/server/Slim/Buttons/Playlist.pm
    trunk/server/Slim/Music/Info.pm
    trunk/server/Slim/Player/Client.pm

Modified: trunk/server/Slim/Buttons/Playlist.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Buttons/Playlist.pm?rev=8920&r1=8919&r2=8920&view=diff
==============================================================================
--- trunk/server/Slim/Buttons/Playlist.pm (original)
+++ trunk/server/Slim/Buttons/Playlist.pm Thu Aug 10 15:34:57 2006
@@ -285,14 +285,15 @@
 	}
 
 	if ($client->display->showExtendedText()) {
-		my $url = Slim::Player::Playlist::song($client, browseplaylistindex($client));
+		my $song = Slim::Player::Playlist::song($client, browseplaylistindex($client));
 
 		$parts->{'screen2'} ||= {
 			'line' => [ 
-						Slim::Music::TitleFormatter::infoFormat($url, 'ALBUM'),
-						Slim::Music::TitleFormatter::infoFormat($url, 'ARTIST')
+						Slim::Music::Info::displayText($client, $song, 'ALBUM'),
+						Slim::Music::Info::displayText($client, $song, 'ARTIST')
 						],
 		};
+
 	}
 
 	return $parts;

Modified: trunk/server/Slim/Music/Info.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Music/Info.pm?rev=8920&r1=8919&r2=8920&view=diff
==============================================================================
--- trunk/server/Slim/Music/Info.pm (original)
+++ trunk/server/Slim/Music/Info.pm Thu Aug 10 15:34:57 2006
@@ -174,6 +174,10 @@
 	%displayCache    = ();
 	%currentTitles   = ();
 	%currentBitrates = ();
+
+	foreach my $client ( Slim::Player::Client::clients() ) {
+		$client->musicInfoTextCache(undef);
+	}
 }
 
 sub updateCacheEntry {
@@ -481,6 +485,39 @@
 	return $ref->{'display'};
 }
 
+# get display text for object by format, caches all formats for this url for this client
+sub displayText {
+	my $client = shift;
+	my $obj    = shift;
+	my $format = shift || 'TITLE';
+
+	return '' unless (blessed $obj && $obj->can('url'));
+
+	my $url = $obj->url;
+
+	my $cache = $client->musicInfoTextCache();
+
+	if ($cache->{'url'} && $url && $cache->{'url'} eq $url) {
+
+		if (exists $cache->{"$format"}) {
+			return $cache->{"$format"};
+		} else {
+			return $cache->{"$format"} = Slim::Music::TitleFormatter::infoFormat($obj, $format);
+		}
+
+	}
+
+	my $text = Slim::Music::TitleFormatter::infoFormat($obj, $format);	
+
+	$cache = {};
+	$cache->{'url'} = $url;
+	$cache->{"$format"} = $text;
+
+	$client->musicInfoTextCache($cache);
+
+	return $text;
+}
+
 #
 # Guess the important tags from the filename; use the strings in preference
 # 'guessFileFormats' to generate candidate regexps for matching. First

Modified: trunk/server/Slim/Player/Client.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Player/Client.pm?rev=8920&r1=8919&r2=8920&view=diff
==============================================================================
--- trunk/server/Slim/Player/Client.pm (original)
+++ trunk/server/Slim/Player/Client.pm Thu Aug 10 15:34:57 2006
@@ -730,7 +730,7 @@
 	$client->[100] = undef; # display object
 	$client->[101] = undef; # lines2periodic
 	$client->[102] = 0; # periodicUpdateTime
-	$client->[103] = undef; # unused
+	$client->[103] = undef; # musicInfoTextCache
 	$client->[104] = undef; # unused
 	$client->[105] = undef; # unused
 	$client->[106] = undef; # knobPos
@@ -1960,6 +1960,11 @@
 	@_ ? ($r->[102] = shift) : $r->[102];
 }
 
+sub musicInfoTextCache {
+	my $r = shift;
+	@_ ? ($r->[103] = shift) : $r->[103];
+}
+
 sub scrollState {
 	my $r = shift;
 	@_ ? ($r->[105] = shift) : $r->[105];



More information about the checkins mailing list