diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2012-03-04 14:44:43 -0500 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2012-03-04 14:50:47 -0500 |
commit | d18a5cad7f002b2f67385e57118048ea3db185a6 (patch) | |
tree | 61b8eafcf9d0197a8bc1f6c795c775f9170a4f64 | |
parent | 534117d1e0d01b78d0ab9040e64fbd88213cd805 (diff) | |
download | rockbox-d18a5cad7f002b2f67385e57118048ea3db185a6.tar.gz rockbox-d18a5cad7f002b2f67385e57118048ea3db185a6.zip |
Tweak paramters of mp3_play_data and callback.
Use generic void * and size_t and make mp3_play_data and its callback
agree on types. Use mp3_play_callback_t instead of prototyping
right in the function call (so it's not so messy to look at). Change
doesn't appear to require plugin API version increment.
Change-Id: Idcab2740ee316a2beb6e0a87b8f4934d9d6b3dd8
-rw-r--r-- | apps/beep.c | 2 | ||||
-rw-r--r-- | apps/misc.c | 3 | ||||
-rw-r--r-- | apps/mpeg.c | 2 | ||||
-rw-r--r-- | apps/plugin.h | 4 | ||||
-rw-r--r-- | apps/plugins/chip8.c | 2 | ||||
-rw-r--r-- | apps/plugins/metronome.c | 2 | ||||
-rw-r--r-- | apps/plugins/video.c | 2 | ||||
-rw-r--r-- | apps/talk.c | 4 | ||||
-rw-r--r-- | apps/voice_thread.c | 20 | ||||
-rw-r--r-- | apps/voice_thread.h | 6 | ||||
-rw-r--r-- | firmware/export/mp3_playback.h | 8 | ||||
-rw-r--r-- | firmware/target/sh/archos/audio-archos.c | 9 | ||||
-rw-r--r-- | uisimulator/common/stubs.c | 7 |
13 files changed, 39 insertions, 32 deletions
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) | |||
54 | { | 54 | { |
55 | count = MIN(count, BEEP_BUF_COUNT); | 55 | count = MIN(count, BEEP_BUF_COUNT); |
56 | beep_count -= count; | 56 | beep_count -= count; |
57 | *start = (unsigned char *)beep_buf; | 57 | *start = beep_buf; |
58 | *size = count * 2 * sizeof (int16_t); | 58 | *size = count * 2 * sizeof (int16_t); |
59 | beep_generate((void *)beep_buf, count, &beep_phase, | 59 | beep_generate((void *)beep_buf, count, &beep_phase, |
60 | beep_step, beep_amplitude); | 60 | 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 @@ | |||
42 | #include "usb_screen.h" | 42 | #include "usb_screen.h" |
43 | #include "talk.h" | 43 | #include "talk.h" |
44 | #include "audio.h" | 44 | #include "audio.h" |
45 | #include "mp3_playback.h" | ||
46 | #include "settings.h" | 45 | #include "settings.h" |
47 | #include "storage.h" | 46 | #include "storage.h" |
48 | #include "ata_idle_notify.h" | 47 | #include "ata_idle_notify.h" |
@@ -88,6 +87,8 @@ | |||
88 | #include "playback.h" | 87 | #include "playback.h" |
89 | #if CONFIG_CODEC == SWCODEC | 88 | #if CONFIG_CODEC == SWCODEC |
90 | #include "voice_thread.h" | 89 | #include "voice_thread.h" |
90 | #else | ||
91 | #include "mp3_playback.h" | ||
91 | #endif | 92 | #endif |
92 | 93 | ||
93 | #ifdef BOOTFILE | 94 | #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) | |||
876 | } | 876 | } |
877 | 877 | ||
878 | /* DMA transfer end interrupt callback */ | 878 | /* DMA transfer end interrupt callback */ |
879 | static void transfer_end(unsigned char** ppbuf, size_t* psize) | 879 | static void transfer_end(const void** ppbuf, size_t* psize) |
880 | { | 880 | { |
881 | if(playing && !paused) | 881 | if(playing && !paused) |
882 | { | 882 | { |
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 { | |||
637 | unsigned int band_setting); | 637 | unsigned int band_setting); |
638 | #endif /* AUDIOHW_HAVE_EQ */ | 638 | #endif /* AUDIOHW_HAVE_EQ */ |
639 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) | 639 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) |
640 | void (*mp3_play_data)(const unsigned char* start, int size, | 640 | void (*mp3_play_data)(const void* start, size_t size, |
641 | void (*get_more)(unsigned char** start, size_t* size)); | 641 | mp3_play_callback_t get_more); |
642 | void (*mp3_play_pause)(bool play); | 642 | void (*mp3_play_pause)(bool play); |
643 | void (*mp3_play_stop)(void); | 643 | void (*mp3_play_stop)(void); |
644 | bool (*mp3_is_playing)(void); | 644 | 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, | |||
1268 | 111,181,184,144, 17,148, 21,101,166,227,100, 86, 85, 85, 85}; | 1268 | 111,181,184,144, 17,148, 21,101,166,227,100, 86, 85, 85, 85}; |
1269 | 1269 | ||
1270 | /* callback to request more mp3 data */ | 1270 | /* callback to request more mp3 data */ |
1271 | static void callback(unsigned char** start, size_t* size) | 1271 | static void callback(const void** start, size_t* size) |
1272 | { | 1272 | { |
1273 | *start = beep; /* give it the same frame again */ | 1273 | *start = beep; /* give it the same frame again */ |
1274 | *size = sizeof(beep); | 1274 | *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; | |||
683 | #define MET_IS_PLAYING rb->mp3_is_playing() | 683 | #define MET_IS_PLAYING rb->mp3_is_playing() |
684 | #define MET_PLAY_STOP rb->mp3_play_stop() | 684 | #define MET_PLAY_STOP rb->mp3_play_stop() |
685 | 685 | ||
686 | static void callback(unsigned char** start, size_t* size) | 686 | static void callback(const void** start, size_t* size) |
687 | { | 687 | { |
688 | (void)start; /* unused parameter, avoid warning */ | 688 | (void)start; /* unused parameter, avoid warning */ |
689 | *size = 0; /* end of data */ | 689 | *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) | |||
448 | 448 | ||
449 | 449 | ||
450 | /* ISR function to get more mp3 data */ | 450 | /* ISR function to get more mp3 data */ |
451 | static void GetMoreMp3(unsigned char** start, size_t* size) | 451 | static void GetMoreMp3(const void** start, size_t* size) |
452 | { | 452 | { |
453 | int available; | 453 | int available; |
454 | int advance; | 454 | 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: | |||
401 | } | 401 | } |
402 | 402 | ||
403 | 403 | ||
404 | /* called in ISR context if mp3 data got consumed */ | 404 | /* called in ISR context (on HWCODEC) if mp3 data got consumed */ |
405 | static void mp3_callback(unsigned char** start, size_t* size) | 405 | static void mp3_callback(const void** start, size_t* size) |
406 | { | 406 | { |
407 | queue[queue_read].len -= sent; /* we completed this */ | 407 | queue[queue_read].len -= sent; /* we completed this */ |
408 | queue[queue_read].buf += sent; | 408 | 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 | |||
117 | struct voice_info | 117 | struct voice_info |
118 | { | 118 | { |
119 | /* Callback to get more clips */ | 119 | /* Callback to get more clips */ |
120 | void (*get_more)(unsigned char** start, size_t* size); | 120 | mp3_play_callback_t get_more; |
121 | /* Start of clip */ | 121 | /* Start of clip */ |
122 | unsigned char *start; | 122 | const void *start; |
123 | /* Size of clip */ | 123 | /* Size of clip */ |
124 | size_t size; | 124 | size_t size; |
125 | }; | 125 | }; |
@@ -200,15 +200,15 @@ static void voice_buf_commit(size_t size) | |||
200 | } | 200 | } |
201 | 201 | ||
202 | /* Stop any current clip and start playing a new one */ | 202 | /* Stop any current clip and start playing a new one */ |
203 | void mp3_play_data(const unsigned char* start, int size, | 203 | void mp3_play_data(const void *start, size_t size, |
204 | void (*get_more)(unsigned char** start, size_t* size)) | 204 | mp3_play_callback_t get_more) |
205 | { | 205 | { |
206 | if (get_more != NULL && start != NULL && (ssize_t)size > 0) | 206 | if (get_more != NULL && start != NULL && size > 0) |
207 | { | 207 | { |
208 | struct voice_info voice_clip = | 208 | struct voice_info voice_clip = |
209 | { | 209 | { |
210 | .get_more = get_more, | 210 | .get_more = get_more, |
211 | .start = (unsigned char *)start, | 211 | .start = start, |
212 | .size = size, | 212 | .size = size, |
213 | }; | 213 | }; |
214 | 214 | ||
@@ -312,7 +312,8 @@ static enum voice_state voice_message(struct voice_thread_data *td) | |||
312 | td->st = speex_decoder_init(&speex_wb_mode); | 312 | td->st = speex_decoder_init(&speex_wb_mode); |
313 | 313 | ||
314 | /* Make bit buffer use our own buffer */ | 314 | /* Make bit buffer use our own buffer */ |
315 | speex_bits_set_bit_buffer(&td->bits, td->vi.start, td->vi.size); | 315 | speex_bits_set_bit_buffer(&td->bits, (void *)td->vi.start, |
316 | td->vi.size); | ||
316 | speex_decoder_ctl(td->st, SPEEX_GET_LOOKAHEAD, &td->lookahead); | 317 | speex_decoder_ctl(td->st, SPEEX_GET_LOOKAHEAD, &td->lookahead); |
317 | 318 | ||
318 | return VOICE_STATE_DECODE; | 319 | return VOICE_STATE_DECODE; |
@@ -361,10 +362,11 @@ static enum voice_state voice_decode(struct voice_thread_data *td) | |||
361 | if (td->vi.get_more != NULL) | 362 | if (td->vi.get_more != NULL) |
362 | td->vi.get_more(&td->vi.start, &td->vi.size); | 363 | td->vi.get_more(&td->vi.start, &td->vi.size); |
363 | 364 | ||
364 | if (td->vi.start != NULL && (ssize_t)td->vi.size > 0) | 365 | if (td->vi.start != NULL && td->vi.size > 0) |
365 | { | 366 | { |
366 | /* Make bit buffer use our own buffer */ | 367 | /* Make bit buffer use our own buffer */ |
367 | speex_bits_set_bit_buffer(&td->bits, td->vi.start, td->vi.size); | 368 | speex_bits_set_bit_buffer(&td->bits, (void *)td->vi.start, |
369 | td->vi.size); | ||
368 | /* Don't skip any samples when we're stringing clips together */ | 370 | /* Don't skip any samples when we're stringing clips together */ |
369 | td->lookahead = 0; | 371 | td->lookahead = 0; |
370 | } | 372 | } |
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 @@ | |||
23 | 23 | ||
24 | #include "config.h" | 24 | #include "config.h" |
25 | 25 | ||
26 | void mp3_play_data(const unsigned char* start, int size, | 26 | typedef void (*mp3_play_callback_t)(const void **start, size_t *size); |
27 | void (*get_more)(unsigned char** start, size_t* size)); | 27 | |
28 | void mp3_play_data(const void *start, size_t size, | ||
29 | mp3_play_callback_t get_more); | ||
28 | void mp3_play_stop(void); | 30 | void mp3_play_stop(void); |
29 | void mp3_play_pause(bool play); | 31 | void mp3_play_pause(bool play); |
30 | bool mp3_is_playing(void); | 32 | 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 @@ | |||
26 | 26 | ||
27 | #include <stdbool.h> | 27 | #include <stdbool.h> |
28 | 28 | ||
29 | /* callback fn */ | ||
30 | typedef void (*mp3_play_callback_t)(const void **start, size_t* size); | ||
31 | |||
29 | /* functions formerly in mpeg.c */ | 32 | /* functions formerly in mpeg.c */ |
30 | void mp3_init(int volume, int bass, int treble, int balance, int loudness, | 33 | void mp3_init(int volume, int bass, int treble, int balance, int loudness, |
31 | int avc, int channel_config, int stereo_width, | 34 | int avc, int channel_config, int stereo_width, |
@@ -42,9 +45,8 @@ void demand_irq_enable(bool on); | |||
42 | #if CONFIG_CODEC == MAS3587F | 45 | #if CONFIG_CODEC == MAS3587F |
43 | void mp3_play_init(void); | 46 | void mp3_play_init(void); |
44 | #endif | 47 | #endif |
45 | void mp3_play_data(const unsigned char* start, int size, | 48 | void mp3_play_data(const void* start, size_t size, |
46 | void (*get_more)(unsigned char** start, size_t* size) /* callback fn */ | 49 | mp3_play_callback_t get_more); |
47 | ); | ||
48 | void mp3_play_pause(bool play); | 50 | void mp3_play_pause(bool play); |
49 | bool mp3_pause_done(void); | 51 | bool mp3_pause_done(void); |
50 | void mp3_play_stop(void); | 52 | 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 */ | |||
53 | static bool playing; /* We are playing an MP3 stream */ | 53 | static bool playing; /* We are playing an MP3 stream */ |
54 | 54 | ||
55 | /* the registered callback function to ask for more mp3 data */ | 55 | /* the registered callback function to ask for more mp3 data */ |
56 | static void (*callback_for_more)(unsigned char**, size_t*); | 56 | static mp3_play_callback_t callback_for_more; |
57 | 57 | ||
58 | /* list of tracks in memory */ | 58 | /* list of tracks in memory */ |
59 | #define MAX_ID3_TAGS (1<<4) /* Must be power of 2 */ | 59 | #define MAX_ID3_TAGS (1<<4) /* Must be power of 2 */ |
@@ -156,7 +156,7 @@ static void play_tick(void) | |||
156 | void DEI3(void) __attribute__((interrupt_handler)); | 156 | void DEI3(void) __attribute__((interrupt_handler)); |
157 | void DEI3(void) | 157 | void DEI3(void) |
158 | { | 158 | { |
159 | unsigned char* start; | 159 | const void* start; |
160 | size_t size = 0; | 160 | size_t size = 0; |
161 | 161 | ||
162 | if (callback_for_more != NULL) | 162 | if (callback_for_more != NULL) |
@@ -469,9 +469,8 @@ void mp3_play_init(void) | |||
469 | } | 469 | } |
470 | #endif | 470 | #endif |
471 | 471 | ||
472 | void mp3_play_data(const unsigned char* start, int size, | 472 | void mp3_play_data(const void* start, size_t size, |
473 | void (*get_more)(unsigned char** start, size_t* size) /* callback fn */ | 473 | mp3_play_callback_t get_more) |
474 | ) | ||
475 | { | 474 | { |
476 | /* init DMA */ | 475 | /* init DMA */ |
477 | DAR3 = 0x5FFFEC3; | 476 | 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 @@ | |||
36 | static bool storage_spinning = false; | 36 | static bool storage_spinning = false; |
37 | 37 | ||
38 | #if CONFIG_CODEC != SWCODEC | 38 | #if CONFIG_CODEC != SWCODEC |
39 | #include "mp3_playback.h" | ||
40 | |||
39 | void audio_set_buffer_margin(int seconds) | 41 | void audio_set_buffer_margin(int seconds) |
40 | { | 42 | { |
41 | (void)seconds; | 43 | (void)seconds; |
@@ -92,9 +94,8 @@ unsigned char* mp3_get_pos(void) | |||
92 | return NULL; | 94 | return NULL; |
93 | } | 95 | } |
94 | 96 | ||
95 | void mp3_play_data(const unsigned char* start, int size, | 97 | void mp3_play_data(const void* start, size_t size, |
96 | void (*get_more)(unsigned char** start, size_t* size) /* callback fn */ | 98 | mp3_play_callback_t get_more) |
97 | ) | ||
98 | { | 99 | { |
99 | (void)start; (void)size; (void)get_more; | 100 | (void)start; (void)size; (void)get_more; |
100 | } | 101 | } |