eaccebc95d
- DM: add dl_missing_* fields to AppCtx for sequential queue - DM player: count_missing_in_season, find_next_missing, download_episode, download_missing_season_start/next - DM main onResult: auto-continue queue when dl_missing_active, updates status DL X/Y, finishes with done ok/fail - SdDownloader: file exists returns true (Already on SD) with total=file size, not false - SdDownloader: set_result_and_close minimal bundle (only success bool) to avoid internal heap OOM crash on close - SdDownloader: Cancel button becomes Close after done, calls tt_app_stop() directly (manual close per request, auto-close unreliable) - Fixes crash on close observed in demo mode (file exists) and after download done Tested on 192.168.68.133: SdDownloader shows Already on SD + Close, DM shows S10 5/6 after sequential, no crash on open/close cycles
107 lines
2.5 KiB
C
107 lines
2.5 KiB
C
#pragma once
|
|
|
|
#include <tt_lvgl.h>
|
|
#include <tt_lvgl_toolbar.h>
|
|
#include <lvgl.h>
|
|
#include <tactility/lvgl_fonts.h>
|
|
#include <tactility/device.h>
|
|
#include <tactility/drivers/audio_stream.h>
|
|
#include "freertos/FreeRTOS.h"
|
|
#include "freertos/task.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define TAG "DM"
|
|
#define PB "http://192.168.68.110:8095"
|
|
#define DM_DIR "/sdcard/dm"
|
|
#define STATE_PATH "/sdcard/apps/one.tactility.discoverymountain/userdata/state.json"
|
|
#define CACHE_PATH "/sdcard/apps/one.tactility.discoverymountain/userdata/cache.json"
|
|
#define MAX_SEASONS 40
|
|
#define MAX_EPS 250
|
|
#define MP3_BUF 4096
|
|
|
|
typedef struct { int num; } SeasonInfo;
|
|
typedef struct {
|
|
char title[64];
|
|
char slug[96];
|
|
int season;
|
|
int ep_num;
|
|
char audio_url[128];
|
|
bool seen;
|
|
} EpInfo;
|
|
|
|
typedef struct { char slug[96]; int pos; } SavedPos;
|
|
|
|
typedef struct {
|
|
SeasonInfo seasons[MAX_SEASONS];
|
|
int season_cnt;
|
|
EpInfo eps[MAX_EPS];
|
|
int ep_cnt;
|
|
int cur_season;
|
|
int cur_ep_idx;
|
|
struct Device* stream_dev;
|
|
AudioStreamHandle stream_handle;
|
|
bool is_playing;
|
|
bool is_paused;
|
|
bool need_stop;
|
|
TaskHandle_t play_handle;
|
|
TaskHandle_t fetch_handle;
|
|
TaskHandle_t dl_handle;
|
|
int pos_sec;
|
|
int total_sec;
|
|
int volume;
|
|
int last_pct;
|
|
lv_obj_t *root;
|
|
lv_obj_t *lbl_title, *lbl_meta, *bar, *lbl_time, *lbl_status, *btn_play;
|
|
lv_obj_t *lbl_season;
|
|
lv_obj_t *ep_list_cont;
|
|
lv_obj_t *btn_seasons;
|
|
lv_obj_t *btn_dl_missing;
|
|
lv_obj_t *overlay, *dropdown;
|
|
lv_obj_t *season_list_cont;
|
|
lv_timer_t *ui_timer_handle;
|
|
// Download UI
|
|
lv_obj_t *dl_overlay;
|
|
lv_obj_t *dl_bar;
|
|
lv_obj_t *dl_lbl_pct;
|
|
lv_obj_t *dl_lbl_detail;
|
|
lv_obj_t *dl_lbl_title;
|
|
lv_obj_t *dl_lbl_sub;
|
|
char cur_title[128];
|
|
char last_slug[96];
|
|
bool fetching;
|
|
bool downloading;
|
|
volatile int dl_total;
|
|
int dl_expected;
|
|
int dl_last_ui_update;
|
|
volatile bool dl_cancel_req;
|
|
volatile bool fetch_cancel_req;
|
|
char dl_ep_title[128];
|
|
char dl_slug[96];
|
|
int dl_season;
|
|
int dl_ep_num;
|
|
int dl_last_pct;
|
|
// Per-episode resume
|
|
SavedPos saved_pos[MAX_EPS];
|
|
int saved_pos_cnt;
|
|
int last_save_tick;
|
|
|
|
// External downloader integration (SdDownloader)
|
|
int pending_dl_idx;
|
|
|
|
// Full season download queue (sequential single-file to avoid batch crash)
|
|
bool dl_missing_active;
|
|
int dl_missing_season;
|
|
int dl_missing_total;
|
|
int dl_missing_done;
|
|
int dl_missing_failed;
|
|
} AppCtx;
|
|
|
|
extern AppCtx G;
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|