artwork support - release

This commit is contained in:
philippe44
2020-03-19 16:13:59 -07:00
parent 5e5dc9ba29
commit 606f1983c5
9 changed files with 40 additions and 25 deletions

View File

@@ -595,9 +595,6 @@ static void grfs_handler(u8_t *data, int len) {
scroller.first = true; scroller.first = true;
scroller.overflow = false; scroller.overflow = false;
// background excludes space taken by visu (if any)
scroller.back.width = displayer.width - ((visu.mode && visu.row < SB_HEIGHT) ? visu.width : 0);
// set scroller steps & beginning // set scroller steps & beginning
if (pkt->direction == 1) { if (pkt->direction == 1) {
scroller.scrolled = 0; scroller.scrolled = 0;
@@ -634,6 +631,7 @@ static void grfg_handler(u8_t *data, int len) {
// size of scrollable area (less than background) // size of scrollable area (less than background)
scroller.width = htons(pkt->width); scroller.width = htons(pkt->width);
scroller.back.width = ((len - sizeof(struct grfg_packet)) * 8) / displayer.height;
memcpy(scroller.back.frame, data + sizeof(struct grfg_packet), len - sizeof(struct grfg_packet)); memcpy(scroller.back.frame, data + sizeof(struct grfg_packet), len - sizeof(struct grfg_packet));
// update display asynchronously (frames are organized by columns) // update display asynchronously (frames are organized by columns)
@@ -670,6 +668,13 @@ static void grfa_handler(u8_t *data, int len) {
// new grfa artwork, allocate memory // new grfa artwork, allocate memory
if (!offset) { if (!offset) {
// same trick to clean current/previous window
if (artwork.size) {
GDS_ClearWindow(display, artwork.x, artwork.y, -1, -1, GDS_COLOR_BLACK);
artwork.size = 0;
}
// now use new parameters
artwork.x = htons(pkt->x); artwork.x = htons(pkt->x);
artwork.y = htons(pkt->y); artwork.y = htons(pkt->y);
if (artwork.data) free(artwork.data); if (artwork.data) free(artwork.data);
@@ -685,7 +690,6 @@ static void grfa_handler(u8_t *data, int len) {
GDS_DrawJPEG(display, artwork.data, artwork.x, artwork.y, artwork.y < 32 ? (GDS_IMAGE_RIGHT | GDS_IMAGE_TOP) : GDS_IMAGE_CENTER); GDS_DrawJPEG(display, artwork.data, artwork.x, artwork.y, artwork.y < 32 ? (GDS_IMAGE_RIGHT | GDS_IMAGE_TOP) : GDS_IMAGE_CENTER);
free(artwork.data); free(artwork.data);
artwork.data = NULL; artwork.data = NULL;
artwork.size = 0;
} }
LOG_INFO("gfra l:%u x:%hu, y:%hu, o:%u s:%u", length, artwork.x, artwork.y, offset, size); LOG_INFO("gfra l:%u x:%hu, y:%hu, o:%u s:%u", length, artwork.x, artwork.y, offset, size);
@@ -849,9 +853,6 @@ static void visu_handler( u8_t *data, int len) {
visu.border = htonl(pkt->border); visu.border = htonl(pkt->border);
bars = htonl(pkt->bars); bars = htonl(pkt->bars);
visu.spectrum_scale = htonl(pkt->spectrum_scale) / 100.; visu.spectrum_scale = htonl(pkt->spectrum_scale) / 100.;
// might have a race condition with scroller message, so update width in case
if (scroller.active) scroller.back.width = displayer.width - visu.width;
} else { } else {
// full screen visu, try to use bottom screen if available // full screen visu, try to use bottom screen if available
visu.width = displayer.width; visu.width = displayer.width;

Binary file not shown.

View File

@@ -109,7 +109,7 @@ sub build_modes {
my $artwork = $cprefs->get('artwork'); my $artwork = $cprefs->get('artwork');
# if artwork is in main display, reduce width # if artwork is in main display, reduce width
$width = $artwork->{'x'} - 1 if $artwork->{'enable'} && $artwork->{y} < 32; $width = $artwork->{'x'} if $artwork->{'enable'} && $artwork->{y} < 32;
my $small_VU = $cprefs->get('small_VU'); my $small_VU = $cprefs->get('small_VU');
my $spectrum = $cprefs->get('spectrum'); my $spectrum = $cprefs->get('spectrum');

View File

@@ -42,6 +42,11 @@ sub hasScrolling {
return 1; return 1;
} }
sub reconnect {
my $client = shift;
$client->pluginData('artwork_md5', '');
$client->SUPER::reconnect(@_);
}
sub directMetadata { sub directMetadata {
my $client = shift; my $client = shift;

View File

@@ -54,6 +54,9 @@ sub handler {
$cprefs->set('artwork', $artwork); $cprefs->set('artwork', $artwork);
$client->display->modes($client->display->build_modes); $client->display->modes($client->display->build_modes);
$client->display->update; $client->display->update;
# force update
Plugins::SqueezeESP32::Plugin::update_artwork($client, 1) if $artwork->{'enable'};
} }
# as there is nothing captured, we need to re-set these variables # as there is nothing captured, we need to re-set these variables

View File

@@ -33,38 +33,44 @@ sub initPlugin {
Slim::Networking::Slimproto::addPlayerClass($class, 100, 'squeezeesp32', { client => 'Plugins::SqueezeESP32::Player', display => 'Plugins::SqueezeESP32::Graphics' }); Slim::Networking::Slimproto::addPlayerClass($class, 100, 'squeezeesp32', { client => 'Plugins::SqueezeESP32::Player', display => 'Plugins::SqueezeESP32::Graphics' });
$log->info("Added class 100 for SqueezeESP32"); $log->info("Added class 100 for SqueezeESP32");
Slim::Control::Request::subscribe(\&update_artwork, [ ['newmetadata'] ] ); Slim::Control::Request::subscribe(\&onNotification, [ ['newmetadata'] ] );
Slim::Control::Request::subscribe(\&update_artwork, [ ['playlist'], ['open', 'newsong'] ]); Slim::Control::Request::subscribe(\&onNotification, [ ['playlist'], ['open', 'newsong'] ]);
}
sub onNotification {
my $request = shift;
my $client = $request->client;
my $reqstr = $request->getRequestString();
$log->info("artwork update notification $reqstr");
#my $path = $request->getParam('_path');
update_artwork($client);
} }
sub update_artwork { sub update_artwork {
my $request = shift; my $client = shift;
my $client = $request->client; my $force = shift || 0;
my $cprefs = $prefs->client($client); my $cprefs = $prefs->client($client);
my $artwork = $cprefs->get('artwork'); my $artwork = $cprefs->get('artwork');
return unless $client->model eq 'squeezeesp32' && $artwork->{'enable'}; return unless $client->model eq 'squeezeesp32' && $artwork->{'enable'};
my $reqstr = $request->getRequestString();
#my $path = $request->getParam('_path');
my $s = $artwork->{'y'} >= 32 ? $cprefs->get('height') - $artwork->{'y'} : 32; my $s = $artwork->{'y'} >= 32 ? $cprefs->get('height') - $artwork->{'y'} : 32;
$s = min($s, $cprefs->get('width') - $artwork->{'x'}); $s = min($s, $cprefs->get('width') - $artwork->{'x'});
my $path = 'music/current/cover_' . $s . 'x' . $s . '_o.jpg'; my $path = 'music/current/cover_' . $s . 'x' . $s . '_o.jpg';
my $body = Slim::Web::Graphics::artworkRequest($client, $path, undef, \&send_artwork, undef, HTTP::Response->new); my $body = Slim::Web::Graphics::artworkRequest($client, $path, $force, \&send_artwork, undef, HTTP::Response->new);
send_artwork($client, undef, \$body) if $body; send_artwork($client, undef, \$body) if $body;
$log->info("artwork update notification $reqstr with $path");
} }
sub send_artwork { sub send_artwork {
my ($client, $params, $dataref) = @_; my ($client, $force, $dataref) = @_;
# I'm not sure why we are called so often, so only send when needed # I'm not sure why we are called so often, so only send when needed
my $md5 = md5($$dataref); my $md5 = md5($$dataref);
return if $client->pluginData('artwork_md5') eq $md5; return if $client->pluginData('artwork_md5') eq $md5 && !$force;
$client->pluginData('artwork', $dataref); $client->pluginData('artwork', $dataref);
$client->pluginData('artwork_md5', $md5); $client->pluginData('artwork_md5', $md5);

Binary file not shown.

View File

@@ -10,6 +10,6 @@
<name>PLUGIN_SQUEEZEESP32</name> <name>PLUGIN_SQUEEZEESP32</name>
<description>PLUGIN_SQUEEZEESP32_DESC</description> <description>PLUGIN_SQUEEZEESP32_DESC</description>
<module>Plugins::SqueezeESP32::Plugin</module> <module>Plugins::SqueezeESP32::Plugin</module>
<version>0.40</version> <version>0.41</version>
<creator>Philippe</creator> <creator>Philippe</creator>
</extensions> </extensions>

View File

@@ -1,10 +1,10 @@
<?xml version='1.0' standalone='yes'?> <?xml version='1.0' standalone='yes'?>
<extensions> <extensions>
<plugins> <plugins>
<plugin version="0.40" name="SqueezeESP32" minTarget="7.5" maxTarget="*"> <plugin version="0.41" name="SqueezeESP32" minTarget="7.5" maxTarget="*">
<link>https://github.com/sle118/squeezelite-esp32</link> <link>https://github.com/sle118/squeezelite-esp32</link>
<creator>Philippe</creator> <creator>Philippe</creator>
<sha>aa122a85db949c903ffa978d3e3b4ee3205e4ec2</sha> <sha>88ecf433757f057351bcb88461c1db040caef884</sha>
<email>philippe_44@outlook.com</email> <email>philippe_44@outlook.com</email>
<desc lang="EN">SqueezeESP32 additional player id (100)</desc> <desc lang="EN">SqueezeESP32 additional player id (100)</desc>
<url>http://github.com/sle118/squeezelite-esp32/raw/master/plugin/SqueezeESP32.zip</url> <url>http://github.com/sle118/squeezelite-esp32/raw/master/plugin/SqueezeESP32.zip</url>