[Slim-Checkins] r8972 - in /trunk/server/Slim: Buttons/Common.pm
Player/Client.pm
adrian at svn.slimdevices.com
adrian at svn.slimdevices.com
Tue Aug 15 12:05:30 PDT 2006
Author: adrian
Date: Tue Aug 15 12:05:27 2006
New Revision: 8972
URL: http://svn.slimdevices.com?rev=8972&view=rev
Log:
Bug: N/A
Description: modeVariables
An alternative to modeParam which provides a scratchpad for state
variables associated with a mode that are guarenteed not to
persist between instances of the mode. Access with $client->modeVariable().
Modified:
trunk/server/Slim/Buttons/Common.pm
trunk/server/Slim/Player/Client.pm
Modified: trunk/server/Slim/Buttons/Common.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Buttons/Common.pm?rev=8972&r1=8971&r2=8972&view=diff
==============================================================================
--- trunk/server/Slim/Buttons/Common.pm (original)
+++ trunk/server/Slim/Buttons/Common.pm Tue Aug 15 12:05:27 2006
@@ -1244,6 +1244,8 @@
push @{$client->modeParameterStack}, $paramHashRef;
+ push @{$client->modeVariableStack}, {};
+
my $newModeFunction = $modes{$setmode};
if (!$newModeFunction || ref($newModeFunction) ne "CODE") {
@@ -1290,6 +1292,7 @@
pop @{$client->modeStack};
pop @{$client->modeParameterStack};
+ pop @{$client->modeVariableStack};
$scrollClientHash->{$client}{scrollParams} = pop @{$scrollClientHash->{$client}{scrollParamsStack}};
my $newmode = mode($client);
Modified: trunk/server/Slim/Player/Client.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Player/Client.pm?rev=8972&r1=8971&r2=8972&view=diff
==============================================================================
--- trunk/server/Slim/Player/Client.pm (original)
+++ trunk/server/Slim/Player/Client.pm Tue Aug 15 12:05:27 2006
@@ -375,6 +375,13 @@
modeParameterStack() - type: array
stack of hashes of mode parameters for previous modes
+
+=item
+
+modeVariableStack() - type: array
+
+ stack of hashes of mode variables for previous modes
+ (mode variables are guarenteed to not persit between mode instances, unlike mode params)
=item
@@ -731,7 +738,7 @@
$client->[101] = undef; # lines2periodic
$client->[102] = 0; # periodicUpdateTime
$client->[103] = undef; # musicInfoTextCache
- $client->[104] = undef; # unused
+ $client->[104] = []; # modeVariableStack
$client->[105] = undef; # unused
$client->[106] = undef; # knobPos
$client->[107] = undef; # knobTime
@@ -1231,10 +1238,22 @@
}
# this is a replacement for param that allows you to pass undef to clear a parameter
+# NB mode parameters may persist between instances of a mode. They should therefore not be used
+# for state which should not persist between instances of a mode - use modeVariable instead
sub modeParam {
my $client = shift;
my $name = shift;
my $mode = $client->modeParameterStack(-1) || return undef;
+
+ @_ ? ($mode->{$name} = shift) : $mode->{$name};
+}
+
+# Mode variables are accessed by this function. Mode variables are used for state which should not
+# persist between instances of a mode
+sub modeVariable {
+ my $client = shift;
+ my $name = shift;
+ my $mode = $client->modeVariableStack(-1) || return undef;
@_ ? ($mode->{$name} = shift) : $mode->{$name};
}
@@ -1965,6 +1984,13 @@
@_ ? ($r->[103] = shift) : $r->[103];
}
+sub modeVariableStack {
+ my $r = shift;
+ my $i;
+ @_ ? ($i = shift) : return $r->[104];
+ @_ ? ($r->[104]->[$i] = shift) : $r->[104]->[$i];
+}
+
sub scrollState {
my $r = shift;
@_ ? ($r->[105] = shift) : $r->[105];
More information about the checkins
mailing list