Merge remote-tracking branch 'origin/master-cmake' into master-cmake

This commit is contained in:
Sebastien
2020-12-21 11:09:02 -05:00
14 changed files with 117 additions and 52 deletions

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;
}
@@ -1042,7 +1044,7 @@ static void visu_handler( u8_t *data, int len) {
// little trick to clean the taller screens when switching visu
if (visu.row >= displayer.height) GDS_ClearExt(display, false, true, visu.col, visu.row, visu.col + visu.width - 1, visu.row + visu.height - 1);
if (visu.mode) {
// these will be overidden if necessary
visu.col = visu.border = 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

@@ -3,7 +3,7 @@ set( WEBPACK_DIR webapp/webpack/dist )
idf_component_register( SRC_DIRS . webapp
INCLUDE_DIRS . webapp ${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
)