Skip to content

Commit e4ebb2c

Browse files
committed
Fix seek http stream change the total byte.
Fix wifi service setting failure IDF>=4.0. Closes #372
1 parent 4aa8e6e commit e4ebb2c

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

components/audio_stream/http_stream.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,8 +416,14 @@ static esp_err_t _http_open(audio_element_handle_t self)
416416
esp_http_client_close(http->client);
417417
return ESP_FAIL;
418418
}
419+
/*
420+
* Due to the total byte of content has been changed after seek, set info.total_bytes at beginning only.
421+
*/
422+
int64_t cur_pos = esp_http_client_fetch_headers(http->client);
423+
if (info.byte_pos <= 0) {
424+
info.total_bytes = cur_pos;
425+
}
419426

420-
info.total_bytes = esp_http_client_fetch_headers(http->client);
421427
ESP_LOGI(TAG, "total_bytes=%d", (int)info.total_bytes);
422428
int status_code = esp_http_client_get_status_code(http->client);
423429
if (status_code == 301 || status_code == 302) {

components/wifi_service/src/wifi_service.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ static void wifi_event_cb(void *arg, esp_event_base_t event_base,
137137
wifi_event_sta_disconnected_t *event = (wifi_event_sta_disconnected_t *) event_data;
138138
if (serv->reason == WIFI_SERV_STA_BY_USER) {
139139
ESP_LOGI(TAG, "SYSTEM_EVENT_STA_DISCONNECTED, reason is WIFI_SERV_STA_BY_USER");
140+
return;
140141
}
141142
wifi_serv_state_send(serv->wifi_serv_que, WIFI_SERV_EVENT_DISCONNECTED, 0, 0, 0);
142143
switch (event->reason) {

0 commit comments

Comments
 (0)