#ifndef SRC_TONE_H_
#define SRC_TONE_H_

//#define DEBUG_TONE
#ifdef DEBUG_TONE
    #define sound_debug(fmt,...)  brom_func->printf(fmt,##__VA_ARGS__)
#else
    #define sound_debug(fmt,...)
#endif


typedef struct _tagMsWavPcmHeader44
{
	unsigned char ChunkID[4]; // "RIFF"; The "RIFF" the mainchunk;
	unsigned long ChunkSize; // FileSize - 8; The size following this data
	unsigned char Format[4]; // "WAVE"; The "WAVE" format consists of two subchunks: "fmt " and "data"
	unsigned char SubChunk1ID[4]; // "fmt "
	unsigned long SubChunk1Size; // 16 for PCM. This is the size of the rest of the subchunk which follows this data.
	unsigned short AudioFormat; // 1 for PCM. Linear quantization
	unsigned short NumChannels; // 1->Mono, 2->stereo, etc..
	unsigned long SampleRate; // 8000, 11025, 16000, 44100, 48000, etc..
	unsigned long ByteRate; // = SampleRate * NumChannels * BitsPerSample/8
	unsigned short BlockAlign; // = NumChannels * BitsPerSample / 8
	unsigned short BitsPerSample; // 8->8bits, 16->16bits, etc..
	unsigned char SubChunk2ID[4]; // "data"
	unsigned long SubChun2Size; // = NumSamples * NumChannels * BitsPerSample / 8. The size of data
} wav_pcm_header44;

typedef struct _wav_info
{

	unsigned short NumChannels;
	unsigned long  in_SampleRate;
	unsigned short BitsPerSample;
	unsigned long  out_SampleRate;
	unsigned int   out_frame_indeed;
	unsigned int   buffer_input_size;
	unsigned int   buffer_output_size;
}wav_info;

typedef struct _resample_info
{
	wav_info	   wav_in_info;
	unsigned int   out_frame_count;
	unsigned int   mPhaseIncrement;
	unsigned short mInputIndex;
	unsigned int   mPhaseFraction;
	short mX0L;
	short mX0R;
}resample_info;


typedef struct sound_infor_def
{
    volatile unsigned int id;
    volatile unsigned int type;
    volatile unsigned int addr;
    volatile unsigned int length;
} sound_infor_def_type;


typedef struct soundplay_def_
{
    volatile unsigned int SampleRate;
    volatile unsigned int BitsPerSample;
    volatile unsigned int Channels;
    volatile unsigned int frame_byte_length;
} soundplay_def_type;


typedef enum
{
    MP3 = 0,
    WAV = 1,
    ADPCM = 2,
} sound_type;

void sound_init(void);
int8_t sound_action(uint16_t id,uint32_t SampleRate,uint32_t BitsPerSample,uint32_t Channels,uint32_t frame_byte_length,uint8_t option);
void sound_callback(short* addr,uint32_t bytes_length);
#ifdef  SOUND_ENABLE
void sound_stop_callbak(void);
#endif
int8_t sound_play_handle(void);
#endif /* SRC_TONE_H_ */
