Compare commits

...

10 Commits

Author SHA1 Message Date
Philippe G
1a3c888f44 correct fixed volume spectrum scale - release 2020-12-06 22:52:37 -08:00
Philippe G
90ee59754d discover buffer potential overflow 2020-12-05 16:10:53 -08:00
Philippe G
c33c6187ca remove unused code + plugin update 2020-12-03 20:56:56 -08:00
Philippe G
99019cd22f mirror make branch changes on plugin (need to point there ...) 2020-12-02 14:06:49 -08:00
Philippe G
3dc2ed9629 fix hires display - release 2020-12-02 13:58:49 -08:00
Sébastien
99722a6f94 Update Dockerfile 2020-11-22 10:13:25 -05:00
Philippe G
75580feaa0 close socket when connect() fails
might be linked to "too many CLI connection" but I'm not sure
2020-11-21 18:09:41 -08:00
Sebastien
2d573da503 Fixing #59 and unnecessary jack insertion messages-release 2020-11-21 09:26:56 -05:00
Sébastien
2687023b6f change build - all branches except master 2020-11-20 11:50:43 -05:00
Sébastien
0993186e01 Create codeql-analysis.yml 2020-11-19 07:48:20 -05:00
21 changed files with 191 additions and 67 deletions

View File

@@ -4,9 +4,9 @@ name: Cross-Build
on:
push:
branches: [ master-cmake ]
branches-ignore: [ master ]
pull_request:
branches: [ master-cmake ]
branches-ignore: [ master ]
jobs:
job1:

67
.github/workflows/codeql-analysis.yml vendored Normal file
View File

@@ -0,0 +1,67 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
on:
push:
branches: [ master-cmake ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master-cmake ]
schedule:
- cron: '19 12 * * 4'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
language: [ 'cpp', 'javascript', 'python']
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
steps:
- name: Checkout repository
uses: actions/checkout@v2
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
#- run: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1

View File

@@ -18,8 +18,6 @@ RUN wget https://dl.espressif.com/dl/xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a
RUN tar -xzf xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz
RUN rm xtensa-esp32-elf-linux64-1.22.0-80-g6c4433a-5.2.0.tar.gz
# Patch I2S in esp-idf
RUN cp /workspace/squeezelite-esp32/idf-patch/i2s.c /workspace/esp-idf/components/driver/i2s.c
RUN rm -r /workspace/squeezelite-esp32
RUN mkdir /workspace/squeezelite-esp32

View File

@@ -457,9 +457,9 @@ CONFIG_LWIP_SO_REUSE=y
CONFIG_LWIP_SO_REUSE_RXTOALL=y
# CONFIG_LWIP_SO_RCVBUF is not set
# CONFIG_LWIP_IP_FRAG is not set
#CONFIG_LWIP_IP_REASSEMBLY is not set
# CONFIG_LWIP_STATS is not set
# CONFIG_LWIP_ETHARP_TRUST_IP_MAC is not set
CONFIG_LWIP_IP_REASSEMBLY=y
CONFIG_LWIP_ESP_GRATUITOUS_ARP=y
CONFIG_LWIP_GARP_TMR_INTERVAL=60
CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=32

View File

@@ -457,7 +457,7 @@ CONFIG_LWIP_MAX_SOCKETS=16
# CONFIG_LWIP_USE_ONLY_LWIP_SELECT is not set
CONFIG_LWIP_SO_REUSE=y
CONFIG_LWIP_SO_REUSE_RXTOALL=y
#CONFIG_LWIP_IP_REASSEMBLY is not set
CONFIG_LWIP_IP_REASSEMBLY=y
CONFIG_LWIP_ESP_GRATUITOUS_ARP=y
CONFIG_LWIP_GARP_TMR_INTERVAL=60
CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=32

View File

@@ -28,10 +28,6 @@ extern void output_bt_tick(void);
extern char* output_state_str(void);
extern bool output_stopped(void);
extern void wifi_manager_update_status();
//int64_t connecting_timeout = 0;
static void bt_app_av_state_connecting(uint16_t event, void *param);
static void filter_inquiry_scan_result(esp_bt_gap_cb_param_t *param);
@@ -206,13 +202,11 @@ void set_app_source_state(int new_state){
if(bt_app_source_a2d_state!=new_state){
ESP_LOGD(TAG, "Updating state from %s to %s", APP_AV_STATE_DESC[bt_app_source_a2d_state], APP_AV_STATE_DESC[new_state]);
bt_app_source_a2d_state=new_state;
wifi_manager_update_status();
}
}
void set_a2dp_media_state(int new_state){
if(bt_app_source_media_state!=new_state){
bt_app_source_media_state=new_state;
wifi_manager_update_status();
}
}
void hal_bluetooth_init(const char * options)

View File

@@ -531,7 +531,9 @@ cJSON * add_gpio_for_name(cJSON * list,const char * nvs_entry,const char * name,
int gpioNum=0;
if ((p = strcasestr(nvs_entry, name)) != NULL) {
gpioNum = atoi(strchr(p, '=') + 1);
cJSON_AddItemToArray(llist,get_gpio_entry(name,prefix,gpioNum,fixed));
if(gpioNum>=0){
cJSON_AddItemToArray(llist,get_gpio_entry(name,prefix,gpioNum,fixed));
}
}
return llist;
}

View File

@@ -40,8 +40,6 @@ static struct {
.cells = 2,
};
extern void wifi_manager_update_status();
/****************************************************************************************
*
*/
@@ -66,7 +64,6 @@ static void battery_callback(TimerHandle_t xTimer) {
battery.avg = battery.sum / battery.count;
battery.sum = battery.count = 0;
ESP_LOGI(TAG, "Voltage %.2fV", battery.avg);
wifi_manager_update_status();
}
}

View File

@@ -41,7 +41,6 @@ bool jack_inserted_svc(void);
void (*spkfault_handler_svc)(bool inserted);
bool spkfault_svc(void);
extern void wifi_manager_update_status();
/****************************************************************************************
*
@@ -147,8 +146,6 @@ static void monitor_callback(TimerHandle_t xTimer) {
*/
static void jack_handler_default(void *id, button_event_e event, button_press_e mode, bool long_press) {
ESP_LOGD(TAG, "Jack %s", event == BUTTON_PRESSED ? "inserted" : "removed");
messaging_post_message(MESSAGING_INFO, MESSAGING_CLASS_SYSTEM,"jack is %s",BUTTON_PRESSED ? "inserted" : "removed");
wifi_manager_update_status();
if (jack_handler_svc) (*jack_handler_svc)(event == BUTTON_PRESSED);
}

View File

@@ -279,6 +279,7 @@ static void notify(in_addr_t ip, u16_t hport, u16_t cport) {
if (connect(cli_sock, (struct sockaddr *) &addr, addrlen) < 0) {
LOG_ERROR("unable to connect to server %s:%hu with cli", inet_ntoa(server_ip), server_cport);
closesocket(cli_sock);
cli_sock = -1;
}

View File

@@ -808,6 +808,8 @@ static void grfa_handler(u8_t *data, int len) {
artwork.y = htons(pkt->y);
} else if (artwork.size) GDS_ClearWindow(display, artwork.x, artwork.y, -1, -1, GDS_COLOR_BLACK);
LOG_INFO("gfra en:%u x:%hu, y:%hu", artwork.enable, artwork.x, artwork.y);
// done in any case
return;
}
@@ -875,7 +877,7 @@ static void visu_update(void) {
// convert to dB (1 bit remaining for getting X²/N, 60dB dynamic starting from 0dBFS = 3 bits back-off)
for (int i = visu.n; --i >= 0;) {
visu.bars[i].current = visu.max * (0.01667f*10*log10f(0.0000001f + (visu.bars[i].current >> (visu_export.gain == FIXED_ONE ? 7 : 1))) - 0.2543f);
visu.bars[i].current = visu.max * (0.01667f*10*log10f(0.0000001f + (visu.bars[i].current >> (visu_export.gain == FIXED_ONE ? 8 : 1))) - 0.2543f);
if (visu.bars[i].current > visu.max) visu.bars[i].current = visu.max;
else if (visu.bars[i].current < 0) visu.bars[i].current = 0;
}
@@ -917,7 +919,7 @@ static void visu_update(void) {
}
// convert to dB and bars, same back-off
if (power) visu.bars[i].current = visu.max * (0.01667f*10*(log10f(power) - log10f(FFT_LEN/(visu_export.gain == FIXED_ONE ? 128 : 2)*2)) - 0.2543f);
if (power) visu.bars[i].current = visu.max * (0.01667f*10*(log10f(power) - log10f(FFT_LEN*(visu_export.gain == FIXED_ONE ? 256 : 2))) - 0.2543f);
if (visu.bars[i].current > visu.max) visu.bars[i].current = visu.max;
else if (visu.bars[i].current < 0) visu.bars[i].current = 0;
}
@@ -1065,13 +1067,27 @@ static void visu_handler( u8_t *data, int len) {
bars = htonl(pkt->bars);
visu.spectrum_scale = htonl(pkt->spectrum_scale) / 100.;
} else {
// full screen visu, try to use bottom screen if available
// full screen visu, try to optimize orientation/shape
visu.width = htonl(pkt->full.width);
visu.height = GDS_GetHeight(display) > displayer.height ? GDS_GetHeight(display) - displayer.height : GDS_GetHeight(display);
visu.row = GDS_GetHeight(display) - visu.height;
visu.height = GDS_GetHeight(display);
// try to estimate if we should rotate visu
if (visu.height > displayer.height && visu.height > 2*visu.width) visu.rotate = true;
// do we have enough height to play with layout
if (GDS_GetHeight(display) > displayer.height) {
// by default, use up to the bottom of the display
visu.height -= displayer.height;
visu.row = displayer.height;
if (artwork.enable && artwork.y) {
// server sets width to artwork X offset to tell us to rotate
if (visu.width != artwork.x) {
visu.height = artwork.y - displayer.height;
if (visu.height <= 0) {
visu.height = displayer.height;
LOG_WARN("No room left for visualizer, disable it or increase artwork offset %d", artwork.y);
}
} else visu.rotate = true;
}
} else visu.row = 0;
// is this spectrum or analogue/digital
if ((visu.mode & ~VISU_ESP32) == VISU_SPECTRUM) {
@@ -1094,9 +1110,10 @@ static void visu_handler( u8_t *data, int len) {
visu.style = htonl(pkt->classical_vu.style);
if (visu.style) visu.row = visu.height - VU_HEIGHT;
}
if (bars > MAX_BARS) bars = MAX_BARS;
}
if (bars > MAX_BARS) bars = MAX_BARS;
// for rotate, swap width & height
if (visu.rotate) visu_fit(bars, visu.height, visu.width);
else visu_fit(bars, visu.width, visu.height);

View File

@@ -124,7 +124,7 @@ static int _write_frames(frames_t out_frames, bool silence, s32_t gainL, s32_t g
int32_t output_bt_data(uint8_t *data, int32_t len) {
int32_t iframes = len / BYTES_PER_FRAME, start_timer = 0;
if (len < 0 || data == NULL || !running) {
if (iframes <= 0 || data == NULL || !running) {
return 0;
}
@@ -135,9 +135,9 @@ int32_t output_bt_data(uint8_t *data, int32_t len) {
// for us to send. (BTC_SBC_DEC_PCM_DATA_LEN * sizeof(OI_INT16) - availPcmBytes
SET_MIN_MAX(len,req);
TIME_MEASUREMENT_START(start_timer);
SET_MIN_MAX_SIZED(_buf_used(outputbuf),bt,outputbuf->size);
LOCK;
SET_MIN_MAX_SIZED(_buf_used(outputbuf),bt,outputbuf->size);
output.device_frames = 0;
output.updated = gettime_ms();
output.frames_played_dmp = output.frames_played;

View File

@@ -822,14 +822,14 @@ in_addr_t discover_server(char *default_server, int max) {
memset(&s, 0, sizeof(s));
if (sendto(disc_sock, buf, len, 0, (struct sockaddr *)&d, sizeof(d)) < 0) {
LOG_INFO("error sending disovery");
LOG_INFO("error sending discovery");
}
if (poll(&pollinfo, 1, 5000) == 1) {
char readbuf[32], *p;
char readbuf[64], *p;
socklen_t slen = sizeof(s);
memset(readbuf, 0, 32);
recvfrom(disc_sock, readbuf, 32 - 1, 0, (struct sockaddr *)&s, &slen);
memset(readbuf, 0, sizeof(readbuf));
recvfrom(disc_sock, readbuf, sizeof(readbuf) - 1, 0, (struct sockaddr *)&s, &slen);
LOG_INFO("got response from: %s:%d", inet_ntoa(s.sin_addr), ntohs(s.sin_port));
if ((p = strstr(readbuf, port_d)) != NULL) {

View File

@@ -1,7 +1,7 @@
idf_component_register( SRC_DIRS .
INCLUDE_DIRS . ${IDF_PATH}/components/esp_http_server/src ${IDF_PATH}/components/esp_http_server/src/port/esp32 ${IDF_PATH}/components/esp_http_server/src/util ${IDF_PATH}/components/esp_http_server/src/
REQUIRES squeezelite-ota json mdns
PRIV_REQUIRES tools services platform_config esp_common json newlib freertos spi_flash nvs_flash mdns pthread wpa_supplicant platform_console esp_http_server console driver_bt
PRIV_REQUIRES tools services platform_config esp_common json newlib freertos spi_flash nvs_flash mdns pthread wpa_supplicant platform_console esp_http_server console driver_bt
EMBED_FILES res/style.css.gz res/code.js.gz index.html res/bootstrap.css.gz res/yeti/bootstrap.css.gz res/jquery.js.gz res/bootstrap.js.gz res/favicon.ico
)

View File

@@ -1182,6 +1182,8 @@ esp_err_t status_get_handler(httpd_req_t *req){
else {
httpd_resp_send_err(req, HTTPD_500_INTERNAL_SERVER_ERROR , "Error retrieving status object");
}
// update status for next status call
wifi_manager_update_status();
return ESP_OK;
}

View File

@@ -17,6 +17,17 @@ my $VISUALIZER_WAVEFORM = 3;
my $VISUALIZER_VUMETER_ESP32 = 0x11;
my $VISUALIZER_SPECTRUM_ANALYZER_ESP32 = 0x12;
my %SPECTRUM_DEFAULTS = (
scale => 25,
small => {
size => 25,
band => 5.33
},
full => {
band => 8
},
);
{
#__PACKAGE__->mk_accessor('array', 'modes');
__PACKAGE__->mk_accessor('rw', 'modes');
@@ -33,12 +44,14 @@ sub new {
$cprefs->init( {
width => 128,
small_VU => 15,
spectrum => { scale => 25,
small => { size => 25, band => 5.33 },
full => { band => 8 },
},
}
);
spectrum => \%SPECTRUM_DEFAULTS,
} );
$prefs->migrateClient(2, sub {
my ($cprefs, $client) = @_;
sanitizeSpectrum($cprefs->get('spectrum'));
1;
});
$display->init_accessor(
modes => $display->build_modes,
@@ -106,6 +119,16 @@ sub displayHeight {
return 32;
}
sub sanitizeSpectrum {
my ($spectrum) = shift;
$spectrum->{small}->{size} ||= $SPECTRUM_DEFAULTS{small}->{size};
$spectrum->{small}->{band} ||= $SPECTRUM_DEFAULTS{small}->{band};
$spectrum->{full}->{band} ||= $SPECTRUM_DEFAULTS{full}->{band};
return $spectrum;
}
sub build_modes {
my $client = shift->client;
my $cprefs = $prefs->client($client);
@@ -118,7 +141,7 @@ sub build_modes {
my $width_low = ($artwork->{'enable'} && $artwork->{'x'} && ($artwork->{'y'} >= 32 || $disp_width - $artwork->{'x'} > 32)) ? $artwork->{'x'} : $disp_width;
my $small_VU = $cprefs->get('small_VU');
my $spectrum = $cprefs->get('spectrum');
my $spectrum = sanitizeSpectrum($cprefs->get('spectrum'));
my $small_spectrum_pos = { x => $width - int ($spectrum->{small}->{size} * $width / 100),
width => int ($spectrum->{small}->{size} * $width / 100),

View File

@@ -91,16 +91,19 @@ sub init {
}
$client->SUPER::init(@_);
$client->config_artwork;
$client->send_equalizer;
main::INFOLOG && $log->is_info && $log->info("SqueezeESP player connected: " . $client->id);
}
sub initPrefs {
my $client = shift;
$sprefs->client($client)->init($defaultPrefs);
$prefs->client($client)->init( { equalizer => [(0) x 10] } );
$prefs->client($client)->init( {
equalizer => [(0) x 10],
artwork => undef,
} );
$client->SUPER::initPrefs;
}
@@ -184,11 +187,13 @@ sub update_artwork {
my $cprefs = $prefs->client($client);
my $artwork = $cprefs->get('artwork') || return;
return unless $artwork->{'enable'};
my $s = min($cprefs->get('height') - $artwork->{'y'}, $cprefs->get('width') - $artwork->{'x'});
my $header = pack('Nnn', $artwork->{'enable'}, $artwork->{'x'}, $artwork->{'y'});
$client->sendFrame( grfa => \$header );
$client->display->update;
my $s = min($cprefs->get('height') - $artwork->{'y'}, $cprefs->get('width') - $artwork->{'x'});
my $params = { force => shift || 0 };
my $path = 'music/current/cover_' . $s . 'x' . $s . '_o.jpg';
my $body = Slim::Web::Graphics::artworkRequest($client, $path, $params, \&send_artwork, undef, HTTP::Response->new);
@@ -248,13 +253,17 @@ sub config_artwork {
if ( my $artwork = $prefs->client($client)->get('artwork') ) {
my $header = pack('Nnn', $artwork->{'enable'}, $artwork->{'x'}, $artwork->{'y'});
$client->sendFrame( grfa => \$header );
$client->display->update;
}
}
sub reconnect {
my $client = shift;
$client->pluginData('artwork_md5', '');
$client->SUPER::reconnect(@_);
$client->pluginData('artwork_md5', '');
$client->config_artwork;
$client->send_equalizer;
}
# Change the analog output mode between headphone and sub-woofer

View File

@@ -43,22 +43,29 @@ sub handler {
if ($paramRef->{'saveSettings'}) {
if ($client->displayWidth) {
$cprefs->set('small_VU', $paramRef->{'pref_small_VU'} || 15);
my $spectrum = {
scale => $paramRef->{'pref_spectrum_scale'} || 25,
small => { size => $paramRef->{'pref_spectrum_small_size'} || 25,
band => $paramRef->{'pref_spectrum_small_band'} || 5.33 },
full => { band => $paramRef->{'pref_spectrum_full_band'} } || 8,
};
require Plugins::SqueezeESP32::Graphics;
my $spectrum = Plugins::SqueezeESP32::Graphics::sanitizeSpectrum({
scale => $paramRef->{'pref_spectrum_scale'},
small => {
size => $paramRef->{'pref_spectrum_small_size'},
band => $paramRef->{'pref_spectrum_small_band'}
},
full => {
band => $paramRef->{'pref_spectrum_full_band'}
},
});
$cprefs->set('spectrum', $spectrum);
my $artwork = {
enable => $paramRef->{'pref_artwork_enable'},
enable => $paramRef->{'pref_artwork_enable'} eq 'on',
x => $paramRef->{'pref_artwork_x'} || 0,
y => $paramRef->{'pref_artwork_y'} || 0,
};
$cprefs->set('artwork', $artwork);
$client->display->modes($client->display->build_modes);
$client->display->update;
# the display update will be done below, after all is completed
# force update or disable artwork
if ($artwork->{'enable'}) {
@@ -66,6 +73,7 @@ sub handler {
} else {
$client->config_artwork();
}
}
my $equalizer = $cprefs->get('equalizer');

View File

@@ -24,6 +24,12 @@ $prefs->migrateClient(1, sub {
1;
});
$prefs->migrateClient(2, sub {
my ($cprefs, $client) = @_;
$cprefs->set('artwork', undef) if $cprefs->get('artwork') && ref $cprefs->get('artwork') ne 'HASH';
1;
});
$prefs->setChange(sub {
$_[2]->send_equalizer;
}, 'equalizer');
@@ -67,8 +73,9 @@ sub onNotification {
my $request = shift;
my $client = $request->client || return;
if ($client->isa('Plugins::SqueezeESP32::Player')) {
$client->update_artwork();
foreach my $player ($client->syncGroupActiveMembers) {
next unless $player->isa('Plugins::SqueezeESP32::Player');
$player->update_artwork;
}
}

View File

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

View File

@@ -80,8 +80,10 @@ PLUGIN_SQUEEZEESP32_ARTWORK
PLUGIN_SQUEEZEESP32_ARTWORK_DESC
DE Wenn die Y Position kleiner als 32 ist, dann werden Plattenhüllen auf der rechten Seite angezeigt, und x definiert die Startposition.
DE Plattenhüllen werden auf Displays mit weniger als 16 Graustufen in sehr geringer Qualität angezeigt.
EN When Y position is less than 32, then artwork is displayed at the right of the main screen and x defines the starting position
EN Using artwork on less than 16-levels grayscale display if really poor quality
EN When Y position is less than 32, then artwork is displayed at the right of the main screen and X defines the starting position
EN <br>On large screen, it's possible to rotate the VU/Spectrum by setting a small X offset (typically 32). That will push the
EN artwork to the right and make space for a vertical VU to its left.
EN <br>Note that using artwork on less than 16-levels grayscale display if really poor quality
PLUGIN_SQUEEZEESP32_ARTWORK_ENABLE
DE Aktivieren