Skip to content

Commit

Permalink
Merge branch 'bugfix/fix_http_stream_and_wifi_service_bug' into 'master'
Browse files Browse the repository at this point in the history
Bugfix/fix http stream and wifi service bug

See merge request adf/esp-adf-internal!465
  • Loading branch information
jason-mao committed Apr 1, 2020
2 parents fe5db0b + e4ebb2c commit a3be5b2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
17 changes: 16 additions & 1 deletion components/audio_stream/http_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,14 @@ static esp_err_t _http_open(audio_element_handle_t self)
esp_http_client_close(http->client);
return ESP_FAIL;
}
/*
* Due to the total byte of content has been changed after seek, set info.total_bytes at beginning only.
*/
int64_t cur_pos = esp_http_client_fetch_headers(http->client);
if (info.byte_pos <= 0) {
info.total_bytes = cur_pos;
}

info.total_bytes = esp_http_client_fetch_headers(http->client);
ESP_LOGI(TAG, "total_bytes=%d", (int)info.total_bytes);
int status_code = esp_http_client_get_status_code(http->client);
if (status_code == 301 || status_code == 302) {
Expand Down Expand Up @@ -666,6 +672,15 @@ audio_element_handle_t http_stream_init(http_stream_cfg_t *config)
esp_err_t http_stream_next_track(audio_element_handle_t el)
{
http_stream_t *http = (http_stream_t *)audio_element_getdata(el);
if (!(http->enable_playlist_parser && http->is_playlist_resolved)) {
/**
* This is not a playlist!
* Do not reset states for restart element.
* Just return.
*/
ESP_LOGD(TAG, "Direct URI. Stream will be stopped");
return ESP_OK;
}
audio_element_reset_state(el);
audio_element_info_t info;
audio_element_getinfo(el, &info);
Expand Down
1 change: 1 addition & 0 deletions components/wifi_service/src/wifi_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ static void wifi_event_cb(void *arg, esp_event_base_t event_base,
wifi_event_sta_disconnected_t *event = (wifi_event_sta_disconnected_t *) event_data;
if (serv->reason == WIFI_SERV_STA_BY_USER) {
ESP_LOGI(TAG, "SYSTEM_EVENT_STA_DISCONNECTED, reason is WIFI_SERV_STA_BY_USER");
return;
}
wifi_serv_state_send(serv->wifi_serv_que, WIFI_SERV_EVENT_DISCONNECTED, 0, 0, 0);
switch (event->reason) {
Expand Down

0 comments on commit a3be5b2

Please sign in to comment.