#include "config.h" #include "include\board.h" #include "include\clock.h" #include "include\aud_drv.h" #include "include\mp3_drv.h" #include "include\audio.h" #include "include\aud_drv.h" #include "include\stream_task.h" #include "include\mp3_buffer.h" #include "include/wifi.h" #include "include\audio.h" #include "include/circular_buffer.h" void stream_task_init (void) { /* init mp3_buffer */ mp3_buffer_init(); /* init sound control */ snd_init(); /* init audio control */ audio_init(); /* fill wifi buffer */ cbuf_fill_buffer_force(); /* lock pll - there's really no need to do this because nothing else should be using the pll. that's why we don't check the result for lock failure*/ Pll_get_lock(); /* start playing stream */ snd_start(); } void stream_task (void) { Byte (*eof_func)(void); Byte (*getc_func)(void); switch (g_current_source) { case AUDIO_CUE_ZERO_ID: eof_func=mp3_buffer_0_eof; getc_func=mp3_buffer_0_getc; break; case AUDIO_CUE_ONE_ID: eof_func=mp3_buffer_1_eof; getc_func=mp3_buffer_1_getc; break; case AUDIO_CUE_TWO_ID: eof_func=mp3_buffer_2_eof; getc_func=mp3_buffer_2_getc; break; case AUDIO_CUE_THREE_ID: eof_func=mp3_buffer_3_eof; getc_func=mp3_buffer_3_getc; break; case AUDIO_CUE_FOUR_ID: eof_func=mp3_buffer_4_eof; getc_func=mp3_buffer_4_getc; break; case AUDIO_CUE_FIVE_ID: eof_func=mp3_buffer_5_eof; getc_func=mp3_buffer_5_getc; break; case AUDIO_CUE_SIX_ID: eof_func=mp3_buffer_6_eof; getc_func=mp3_buffer_6_getc; break; case AUDIO_CUE_SEVEN_ID: eof_func=mp3_buffer_7_eof; getc_func=mp3_buffer_7_getc; break; case AUDIO_CUE_EIGHT_ID: eof_func=mp3_buffer_8_eof; getc_func=mp3_buffer_8_getc; break; case AUDIO_CUE_NINE_ID: eof_func=mp3_buffer_9_eof; getc_func=mp3_buffer_9_getc; break; case AUDIO_CUE_VOLUME_ID: eof_func=mp3_buffer_10_eof; getc_func=mp3_buffer_10_getc; break; case AUDIO_CUE_SILENCE_ID: eof_func=mp3_buffer_100_eof; getc_func=mp3_buffer_100_getc; break; case MP3_BUFFER_WIFI: while (Mp3_frame_request()) { if (cbuf_empty()) { while (Mp3_frame_request()) { Mp3_load(wifi_recv_byte()); } break; } Mp3_load(cbuf_pop_element()); } cbuf_fill_buffer(); return; case TEST_AUDIO_ID: eof_func=mp3_buffer_120_eof; getc_func=mp3_buffer_120_getc; break; } while (Mp3_frame_request()) { if (eof_func()) { mp3_buffer_fix_eof(); audio_init(); snd_start(); break; } /* send data while requested */ Mp3_load(getc_func()); } }