#pragma once
#include "system/includes.h"
#include "circular_buf.h"

struct h_music_stream
{
	int f_len;
	int r_len;
	int w_len;
	int total_len;
	int cbuf_size;
	char url[512];
	char * net_buf;
	void * music_buf;
	void * net_file;
	void * dec_buf;
	cbuffer_t dec_cbuf;
};

struct h_music_status
{
	u8 play;
	u8 pause;
	u8 run;
	int down_status;
	int err_status;
	int sel_item;
};

struct h_music_info
{
	int play_status;
	int first_flag;
	int ex_status;
	u8 play;
	struct h_music_stream hstream;
	struct h_music_status hstatus;
};


void h_net_music_task_quit(void);
static void h_net_music_task_kill(void);


extern void ifly_net_tts_dec_close(void);
extern int ifly_net_tts_dec_open(void *read_priv, int (*read)(void *priv, void *buf, u32 len, u8 tmp_flag, int tmp_offset));
extern void ifly_net_tts_dec_resume(void *priv);
extern int net_download_open(void **priv, struct net_download_parm *parm);
extern u32 net_download_get_tmp_data_size(void *priv);
extern int net_download_read(void *priv, void *buf, u32 len);
extern void net_download_get_status(void *priv, int *download_status, int *http_err_status);
extern int net_download_close(void *priv);
extern void set_continuous_trans(signed char flag);
static void h_net_play_track_clear_flag();
static void h_net_next_music_audio();

extern void h_post_ui_msg(int msg);
extern void free_psram(void *pv);
extern void *malloc_psram(size_t size);