|
@@ -32,8 +32,8 @@ our $defaultPrefs = {
|
|
'analogOutMode' => 0,
|
|
'analogOutMode' => 0,
|
|
'bass' => 0,
|
|
'bass' => 0,
|
|
'treble' => 0,
|
|
'treble' => 0,
|
|
- 'lineInAlwaysOn' => 0,
|
|
|
|
- 'lineInLevel' => 50,
|
|
|
|
|
|
+ 'lineInAlwaysOn' => 0,
|
|
|
|
+ 'lineInLevel' => 50,
|
|
'menuItem' => [qw(
|
|
'menuItem' => [qw(
|
|
NOW_PLAYING
|
|
NOW_PLAYING
|
|
BROWSE_MUSIC
|
|
BROWSE_MUSIC
|
|
@@ -67,51 +67,66 @@ sub minBass { -13 }
|
|
sub init {
|
|
sub init {
|
|
my $client = shift;
|
|
my $client = shift;
|
|
my ($id, $caps) = @_;
|
|
my ($id, $caps) = @_;
|
|
-
|
|
|
|
|
|
+
|
|
my ($depth) = $caps =~ /Depth=(\d+)/;
|
|
my ($depth) = $caps =~ /Depth=(\d+)/;
|
|
$client->depth($depth || 16);
|
|
$client->depth($depth || 16);
|
|
-
|
|
|
|
|
|
+
|
|
if (!$handlersAdded) {
|
|
if (!$handlersAdded) {
|
|
-
|
|
|
|
|
|
+
|
|
# Add a handler for line-in/out status changes
|
|
# Add a handler for line-in/out status changes
|
|
Slim::Networking::Slimproto::addHandler( LIOS => \&lineInOutStatus );
|
|
Slim::Networking::Slimproto::addHandler( LIOS => \&lineInOutStatus );
|
|
-
|
|
|
|
|
|
+
|
|
# Create a new event for sending LIOS updates
|
|
# Create a new event for sending LIOS updates
|
|
Slim::Control::Request::addDispatch(
|
|
Slim::Control::Request::addDispatch(
|
|
['lios', '_state'],
|
|
['lios', '_state'],
|
|
[1, 0, 0, undef],
|
|
[1, 0, 0, undef],
|
|
);
|
|
);
|
|
-
|
|
|
|
|
|
+
|
|
Slim::Control::Request::addDispatch(
|
|
Slim::Control::Request::addDispatch(
|
|
['lios', 'linein', '_state'],
|
|
['lios', 'linein', '_state'],
|
|
[1, 0, 0, undef],
|
|
[1, 0, 0, undef],
|
|
);
|
|
);
|
|
-
|
|
|
|
|
|
+
|
|
Slim::Control::Request::addDispatch(
|
|
Slim::Control::Request::addDispatch(
|
|
['lios', 'lineout', '_state'],
|
|
['lios', 'lineout', '_state'],
|
|
[1, 0, 0, undef],
|
|
[1, 0, 0, undef],
|
|
);
|
|
);
|
|
-
|
|
|
|
|
|
+
|
|
$handlersAdded = 1;
|
|
$handlersAdded = 1;
|
|
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
$client->SUPER::init(@_);
|
|
$client->SUPER::init(@_);
|
|
Plugins::SqueezeESP32::FirmwareHelper::init($client);
|
|
Plugins::SqueezeESP32::FirmwareHelper::init($client);
|
|
|
|
|
|
main::INFOLOG && $log->is_info && $log->info("SqueezeESP player connected: " . $client->id);
|
|
main::INFOLOG && $log->is_info && $log->info("SqueezeESP player connected: " . $client->id);
|
|
-}
|
|
|
|
|
|
+}
|
|
|
|
|
|
sub initPrefs {
|
|
sub initPrefs {
|
|
my $client = shift;
|
|
my $client = shift;
|
|
-
|
|
|
|
|
|
+
|
|
$sprefs->client($client)->init($defaultPrefs);
|
|
$sprefs->client($client)->init($defaultPrefs);
|
|
-
|
|
|
|
- $prefs->client($client)->init( {
|
|
|
|
|
|
+
|
|
|
|
+ $prefs->client($client)->init( {
|
|
equalizer => [(0) x 10],
|
|
equalizer => [(0) x 10],
|
|
artwork => undef,
|
|
artwork => undef,
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
+ $prefs->setValidate({
|
|
|
|
+ validator => sub {
|
|
|
|
+ my ($pref, $new, $params, $old, $client) = @_;
|
|
|
|
+
|
|
|
|
+ $new ||= [(0) x 10];
|
|
|
|
+
|
|
|
|
+ foreach (0..9) {
|
|
|
|
+ return 0 if $new->[$_] < $client->minBass;
|
|
|
|
+ return 0 if $new->[$_] > $client->maxBass;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return 1;
|
|
|
|
+ }
|
|
|
|
+ }, 'equalizer');
|
|
|
|
+
|
|
$client->SUPER::initPrefs;
|
|
$client->SUPER::initPrefs;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -121,15 +136,15 @@ sub power {
|
|
|
|
|
|
my $res = $client->SUPER::power($on, @_);
|
|
my $res = $client->SUPER::power($on, @_);
|
|
return $res unless defined $on;
|
|
return $res unless defined $on;
|
|
-
|
|
|
|
|
|
+
|
|
if ($on) {
|
|
if ($on) {
|
|
$client->update_artwork(1);
|
|
$client->update_artwork(1);
|
|
} else {
|
|
} else {
|
|
$client->clear_artwork(1);
|
|
$client->clear_artwork(1);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
return $res;
|
|
return $res;
|
|
-}
|
|
|
|
|
|
+}
|
|
|
|
|
|
# Allow the player to define it's display width (and probably more)
|
|
# Allow the player to define it's display width (and probably more)
|
|
sub playerSettingsFrame {
|
|
sub playerSettingsFrame {
|
|
@@ -162,16 +177,16 @@ sub playerSettingsFrame {
|
|
sub bass {
|
|
sub bass {
|
|
my ($client, $new) = @_;
|
|
my ($client, $new) = @_;
|
|
my $value = $client->SUPER::bass($new);
|
|
my $value = $client->SUPER::bass($new);
|
|
-
|
|
|
|
|
|
+
|
|
$client->update_equalizer($value, [2, 1, 3]) if defined $new;
|
|
$client->update_equalizer($value, [2, 1, 3]) if defined $new;
|
|
-
|
|
|
|
|
|
+
|
|
return $value;
|
|
return $value;
|
|
}
|
|
}
|
|
|
|
|
|
sub treble {
|
|
sub treble {
|
|
my ($client, $new) = @_;
|
|
my ($client, $new) = @_;
|
|
my $value = $client->SUPER::treble($new);
|
|
my $value = $client->SUPER::treble($new);
|
|
-
|
|
|
|
|
|
+
|
|
$client->update_equalizer($value, [8, 9, 7]) if defined $new;
|
|
$client->update_equalizer($value, [8, 9, 7]) if defined $new;
|
|
|
|
|
|
return $value;
|
|
return $value;
|
|
@@ -189,8 +204,8 @@ sub send_equalizer {
|
|
sub update_equalizer {
|
|
sub update_equalizer {
|
|
my ($client, $value, $index) = @_;
|
|
my ($client, $value, $index) = @_;
|
|
return if $client->tone_update;
|
|
return if $client->tone_update;
|
|
-
|
|
|
|
- my $equalizer = $prefs->client($client)->get('equalizer');
|
|
|
|
|
|
+
|
|
|
|
+ my $equalizer = $prefs->client($client)->get('equalizer');
|
|
$equalizer->[$index->[0]] = $value;
|
|
$equalizer->[$index->[0]] = $value;
|
|
$equalizer->[$index->[1]] = int($value / 2 + 0.5);
|
|
$equalizer->[$index->[1]] = int($value / 2 + 0.5);
|
|
$equalizer->[$index->[2]] = int($value / 4 + 0.5);
|
|
$equalizer->[$index->[2]] = int($value / 4 + 0.5);
|
|
@@ -203,7 +218,7 @@ sub update_tones {
|
|
$client->tone_update(1);
|
|
$client->tone_update(1);
|
|
$sprefs->client($client)->set('bass', int(($equalizer->[1] * 2 + $equalizer->[2] + $equalizer->[3] * 4) / 7 + 0.5));
|
|
$sprefs->client($client)->set('bass', int(($equalizer->[1] * 2 + $equalizer->[2] + $equalizer->[3] * 4) / 7 + 0.5));
|
|
$sprefs->client($client)->set('treble', int(($equalizer->[7] * 4 + $equalizer->[8] + $equalizer->[9] * 2) / 7 + 0.5));
|
|
$sprefs->client($client)->set('treble', int(($equalizer->[7] * 4 + $equalizer->[8] + $equalizer->[9] * 2) / 7 + 0.5));
|
|
- $client->tone_update(0);
|
|
|
|
|
|
+ $client->tone_update(0);
|
|
}
|
|
}
|
|
|
|
|
|
sub update_artwork {
|
|
sub update_artwork {
|
|
@@ -212,7 +227,7 @@ sub update_artwork {
|
|
|
|
|
|
my $artwork = $cprefs->get('artwork') || return;
|
|
my $artwork = $cprefs->get('artwork') || return;
|
|
return unless $artwork->{'enable'} && $client->display->isa("Plugins::SqueezeESP32::Graphics");
|
|
return unless $artwork->{'enable'} && $client->display->isa("Plugins::SqueezeESP32::Graphics");
|
|
-
|
|
|
|
|
|
+
|
|
my $header = pack('Nnn', $artwork->{'enable'}, $artwork->{'x'}, $artwork->{'y'});
|
|
my $header = pack('Nnn', $artwork->{'enable'}, $artwork->{'x'}, $artwork->{'y'});
|
|
$client->sendFrame( grfa => \$header );
|
|
$client->sendFrame( grfa => \$header );
|
|
$client->display->update;
|
|
$client->display->update;
|
|
@@ -267,7 +282,7 @@ sub clear_artwork {
|
|
if ((!$artwork->{'x'} && !$artwork->{'y'}) || $force) {
|
|
if ((!$artwork->{'x'} && !$artwork->{'y'}) || $force) {
|
|
$client->sendFrame(grfa => \("\x00"x4));
|
|
$client->sendFrame(grfa => \("\x00"x4));
|
|
$client->display->update;
|
|
$client->display->update;
|
|
- }
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -284,7 +299,7 @@ sub config_artwork {
|
|
sub reconnect {
|
|
sub reconnect {
|
|
my $client = shift;
|
|
my $client = shift;
|
|
$client->SUPER::reconnect(@_);
|
|
$client->SUPER::reconnect(@_);
|
|
-
|
|
|
|
|
|
+
|
|
$client->pluginData('artwork_md5', '');
|
|
$client->pluginData('artwork_md5', '');
|
|
$client->config_artwork if $client->display->isa("Plugins::SqueezeESP32::Graphics");
|
|
$client->config_artwork if $client->display->isa("Plugins::SqueezeESP32::Graphics");
|
|
$client->send_equalizer;
|
|
$client->send_equalizer;
|
|
@@ -323,18 +338,18 @@ sub lineOutConnected {
|
|
|
|
|
|
sub lineInOutStatus {
|
|
sub lineInOutStatus {
|
|
my ( $client, $data_ref ) = @_;
|
|
my ( $client, $data_ref ) = @_;
|
|
-
|
|
|
|
|
|
+
|
|
my $state = unpack 'n', $$data_ref;
|
|
my $state = unpack 'n', $$data_ref;
|
|
|
|
|
|
my $oldState = {
|
|
my $oldState = {
|
|
in => $client->lineInConnected(),
|
|
in => $client->lineInConnected(),
|
|
out => $client->lineOutConnected(),
|
|
out => $client->lineOutConnected(),
|
|
};
|
|
};
|
|
-
|
|
|
|
|
|
+
|
|
Slim::Networking::Slimproto::voltage( $client, $state );
|
|
Slim::Networking::Slimproto::voltage( $client, $state );
|
|
|
|
|
|
Slim::Control::Request::notifyFromArray( $client, [ 'lios', $state ] );
|
|
Slim::Control::Request::notifyFromArray( $client, [ 'lios', $state ] );
|
|
-
|
|
|
|
|
|
+
|
|
if ($oldState->{in} != $client->lineInConnected()) {
|
|
if ($oldState->{in} != $client->lineInConnected()) {
|
|
Slim::Control::Request::notifyFromArray( $client, [ 'lios', 'linein', $client->lineInConnected() ] );
|
|
Slim::Control::Request::notifyFromArray( $client, [ 'lios', 'linein', $client->lineInConnected() ] );
|
|
if ( Slim::Utils::PluginManager->isEnabled('Slim::Plugin::LineIn::Plugin')) {
|
|
if ( Slim::Utils::PluginManager->isEnabled('Slim::Plugin::LineIn::Plugin')) {
|