Skip to content

Commit a3be5b2

Browse files
committedApr 1, 2020
Merge branch 'bugfix/fix_http_stream_and_wifi_service_bug' into 'master'
Bugfix/fix http stream and wifi service bug See merge request adf/esp-adf-internal!465
2 parents fe5db0b + e4ebb2c commit a3be5b2

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed
 

‎components/audio_stream/http_stream.c

+16-1
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) {
@@ -666,6 +672,15 @@ audio_element_handle_t http_stream_init(http_stream_cfg_t *config)
666672
esp_err_t http_stream_next_track(audio_element_handle_t el)
667673
{
668674
http_stream_t *http = (http_stream_t *)audio_element_getdata(el);
675+
if (!(http->enable_playlist_parser && http->is_playlist_resolved)) {
676+
/**
677+
* This is not a playlist!
678+
* Do not reset states for restart element.
679+
* Just return.
680+
*/
681+
ESP_LOGD(TAG, "Direct URI. Stream will be stopped");
682+
return ESP_OK;
683+
}
669684
audio_element_reset_state(el);
670685
audio_element_info_t info;
671686
audio_element_getinfo(el, &info);

‎components/wifi_service/src/wifi_service.c

+1
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)