diff --git a/apps/beep.c b/apps/beep.c index 3b02e5d8a3..0152900bfc 100644 --- a/apps/beep.c +++ b/apps/beep.c @@ -54,7 +54,7 @@ beep_get_more(const void **start, size_t *size) { count = MIN(count, BEEP_BUF_COUNT); beep_count -= count; - *start = (unsigned char *)beep_buf; + *start = beep_buf; *size = count * 2 * sizeof (int16_t); beep_generate((void *)beep_buf, count, &beep_phase, beep_step, beep_amplitude); diff --git a/apps/misc.c b/apps/misc.c index ca99a1d9ac..3cb314fc51 100644 --- a/apps/misc.c +++ b/apps/misc.c @@ -42,7 +42,6 @@ #include "usb_screen.h" #include "talk.h" #include "audio.h" -#include "mp3_playback.h" #include "settings.h" #include "storage.h" #include "ata_idle_notify.h" @@ -88,6 +87,8 @@ #include "playback.h" #if CONFIG_CODEC == SWCODEC #include "voice_thread.h" +#else +#include "mp3_playback.h" #endif #ifdef BOOTFILE diff --git a/apps/mpeg.c b/apps/mpeg.c index b3e79aadd9..0ecf68fc53 100644 --- a/apps/mpeg.c +++ b/apps/mpeg.c @@ -876,7 +876,7 @@ static void reset_mp3_buffer(void) } /* DMA transfer end interrupt callback */ -static void transfer_end(unsigned char** ppbuf, size_t* psize) +static void transfer_end(const void** ppbuf, size_t* psize) { if(playing && !paused) { diff --git a/apps/plugin.h b/apps/plugin.h index cd2440abdc..8123414ff0 100644 --- a/apps/plugin.h +++ b/apps/plugin.h @@ -637,8 +637,8 @@ struct plugin_api { unsigned int band_setting); #endif /* AUDIOHW_HAVE_EQ */ #if (CONFIG_PLATFORM & PLATFORM_NATIVE) - void (*mp3_play_data)(const unsigned char* start, int size, - void (*get_more)(unsigned char** start, size_t* size)); + void (*mp3_play_data)(const void* start, size_t size, + mp3_play_callback_t get_more); void (*mp3_play_pause)(bool play); void (*mp3_play_stop)(void); bool (*mp3_is_playing)(void); diff --git a/apps/plugins/chip8.c b/apps/plugins/chip8.c index 0e1b9c5213..b2faed5d80 100644 --- a/apps/plugins/chip8.c +++ b/apps/plugins/chip8.c @@ -1268,7 +1268,7 @@ static unsigned char beep[]={255, 111,181,184,144, 17,148, 21,101,166,227,100, 86, 85, 85, 85}; /* callback to request more mp3 data */ -static void callback(unsigned char** start, size_t* size) +static void callback(const void** start, size_t* size) { *start = beep; /* give it the same frame again */ *size = sizeof(beep); diff --git a/apps/plugins/metronome.c b/apps/plugins/metronome.c index 297405571f..54af82fa76 100644 --- a/apps/plugins/metronome.c +++ b/apps/plugins/metronome.c @@ -683,7 +683,7 @@ int bpm_step_counter = 0; #define MET_IS_PLAYING rb->mp3_is_playing() #define MET_PLAY_STOP rb->mp3_play_stop() -static void callback(unsigned char** start, size_t* size) +static void callback(const void** start, size_t* size) { (void)start; /* unused parameter, avoid warning */ *size = 0; /* end of data */ diff --git a/apps/plugins/video.c b/apps/plugins/video.c index 9053ae7fb0..6a66324a79 100644 --- a/apps/plugins/video.c +++ b/apps/plugins/video.c @@ -448,7 +448,7 @@ static void timer4_isr(void) /* ISR function to get more mp3 data */ -static void GetMoreMp3(unsigned char** start, size_t* size) +static void GetMoreMp3(const void** start, size_t* size) { int available; int advance; diff --git a/apps/talk.c b/apps/talk.c index ba2050a9ca..4b0975083d 100644 --- a/apps/talk.c +++ b/apps/talk.c @@ -401,8 +401,8 @@ load_err: } -/* called in ISR context if mp3 data got consumed */ -static void mp3_callback(unsigned char** start, size_t* size) +/* called in ISR context (on HWCODEC) if mp3 data got consumed */ +static void mp3_callback(const void** start, size_t* size) { queue[queue_read].len -= sent; /* we completed this */ queue[queue_read].buf += sent; diff --git a/apps/voice_thread.c b/apps/voice_thread.c index 5d23a74cbc..56d67a2284 100644 --- a/apps/voice_thread.c +++ b/apps/voice_thread.c @@ -117,9 +117,9 @@ enum voice_thread_messages struct voice_info { /* Callback to get more clips */ - void (*get_more)(unsigned char** start, size_t* size); + mp3_play_callback_t get_more; /* Start of clip */ - unsigned char *start; + const void *start; /* Size of clip */ size_t size; }; @@ -200,15 +200,15 @@ static void voice_buf_commit(size_t size) } /* Stop any current clip and start playing a new one */ -void mp3_play_data(const unsigned char* start, int size, - void (*get_more)(unsigned char** start, size_t* size)) +void mp3_play_data(const void *start, size_t size, + mp3_play_callback_t get_more) { - if (get_more != NULL && start != NULL && (ssize_t)size > 0) + if (get_more != NULL && start != NULL && size > 0) { struct voice_info voice_clip = { .get_more = get_more, - .start = (unsigned char *)start, + .start = start, .size = size, }; @@ -312,7 +312,8 @@ static enum voice_state voice_message(struct voice_thread_data *td) td->st = speex_decoder_init(&speex_wb_mode); /* Make bit buffer use our own buffer */ - speex_bits_set_bit_buffer(&td->bits, td->vi.start, td->vi.size); + speex_bits_set_bit_buffer(&td->bits, (void *)td->vi.start, + td->vi.size); speex_decoder_ctl(td->st, SPEEX_GET_LOOKAHEAD, &td->lookahead); return VOICE_STATE_DECODE; @@ -361,10 +362,11 @@ static enum voice_state voice_decode(struct voice_thread_data *td) if (td->vi.get_more != NULL) td->vi.get_more(&td->vi.start, &td->vi.size); - if (td->vi.start != NULL && (ssize_t)td->vi.size > 0) + if (td->vi.start != NULL && td->vi.size > 0) { /* Make bit buffer use our own buffer */ - speex_bits_set_bit_buffer(&td->bits, td->vi.start, td->vi.size); + speex_bits_set_bit_buffer(&td->bits, (void *)td->vi.start, + td->vi.size); /* Don't skip any samples when we're stringing clips together */ td->lookahead = 0; } diff --git a/apps/voice_thread.h b/apps/voice_thread.h index 49b2f3f930..4e4af1fc5c 100644 --- a/apps/voice_thread.h +++ b/apps/voice_thread.h @@ -23,8 +23,10 @@ #include "config.h" -void mp3_play_data(const unsigned char* start, int size, - void (*get_more)(unsigned char** start, size_t* size)); +typedef void (*mp3_play_callback_t)(const void **start, size_t *size); + +void mp3_play_data(const void *start, size_t size, + mp3_play_callback_t get_more); void mp3_play_stop(void); void mp3_play_pause(bool play); bool mp3_is_playing(void); diff --git a/firmware/export/mp3_playback.h b/firmware/export/mp3_playback.h index 6fdaa31cac..de27a2a46d 100644 --- a/firmware/export/mp3_playback.h +++ b/firmware/export/mp3_playback.h @@ -26,6 +26,9 @@ #include +/* callback fn */ +typedef void (*mp3_play_callback_t)(const void **start, size_t* size); + /* functions formerly in mpeg.c */ void mp3_init(int volume, int bass, int treble, int balance, int loudness, int avc, int channel_config, int stereo_width, @@ -42,9 +45,8 @@ void demand_irq_enable(bool on); #if CONFIG_CODEC == MAS3587F void mp3_play_init(void); #endif -void mp3_play_data(const unsigned char* start, int size, - void (*get_more)(unsigned char** start, size_t* size) /* callback fn */ -); +void mp3_play_data(const void* start, size_t size, + mp3_play_callback_t get_more); void mp3_play_pause(bool play); bool mp3_pause_done(void); void mp3_play_stop(void); diff --git a/firmware/target/sh/archos/audio-archos.c b/firmware/target/sh/archos/audio-archos.c index 9dfcb9cb97..2c2579bec5 100644 --- a/firmware/target/sh/archos/audio-archos.c +++ b/firmware/target/sh/archos/audio-archos.c @@ -53,7 +53,7 @@ static bool paused; /* playback is paused */ static bool playing; /* We are playing an MP3 stream */ /* the registered callback function to ask for more mp3 data */ -static void (*callback_for_more)(unsigned char**, size_t*); +static mp3_play_callback_t callback_for_more; /* list of tracks in memory */ #define MAX_ID3_TAGS (1<<4) /* Must be power of 2 */ @@ -156,7 +156,7 @@ static void play_tick(void) void DEI3(void) __attribute__((interrupt_handler)); void DEI3(void) { - unsigned char* start; + const void* start; size_t size = 0; if (callback_for_more != NULL) @@ -469,9 +469,8 @@ void mp3_play_init(void) } #endif -void mp3_play_data(const unsigned char* start, int size, - void (*get_more)(unsigned char** start, size_t* size) /* callback fn */ -) +void mp3_play_data(const void* start, size_t size, + mp3_play_callback_t get_more) { /* init DMA */ DAR3 = 0x5FFFEC3; diff --git a/uisimulator/common/stubs.c b/uisimulator/common/stubs.c index 2a81587d83..1404c1e21b 100644 --- a/uisimulator/common/stubs.c +++ b/uisimulator/common/stubs.c @@ -36,6 +36,8 @@ static bool storage_spinning = false; #if CONFIG_CODEC != SWCODEC +#include "mp3_playback.h" + void audio_set_buffer_margin(int seconds) { (void)seconds; @@ -92,9 +94,8 @@ unsigned char* mp3_get_pos(void) return NULL; } -void mp3_play_data(const unsigned char* start, int size, - void (*get_more)(unsigned char** start, size_t* size) /* callback fn */ -) +void mp3_play_data(const void* start, size_t size, + mp3_play_callback_t get_more) { (void)start; (void)size; (void)get_more; }