diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/plugin.c | 32 | ||||
-rw-r--r-- | apps/plugin.h | 21 |
2 files changed, 51 insertions, 2 deletions
diff --git a/apps/plugin.c b/apps/plugin.c index e91cba0512..e010ebe841 100644 --- a/apps/plugin.c +++ b/apps/plugin.c | |||
@@ -34,6 +34,9 @@ | |||
34 | #include "lang.h" | 34 | #include "lang.h" |
35 | #include "keyboard.h" | 35 | #include "keyboard.h" |
36 | #include "mpeg.h" | 36 | #include "mpeg.h" |
37 | #include "buffer.h" | ||
38 | #include "mp3_playback.h" | ||
39 | #include "backlight.h" | ||
37 | 40 | ||
38 | #ifdef HAVE_LCD_BITMAP | 41 | #ifdef HAVE_LCD_BITMAP |
39 | #include "widgets.h" | 42 | #include "widgets.h" |
@@ -58,6 +61,7 @@ | |||
58 | static unsigned char pluginbuf[PLUGIN_BUFFER_SIZE]; | 61 | static unsigned char pluginbuf[PLUGIN_BUFFER_SIZE]; |
59 | #else | 62 | #else |
60 | extern unsigned char pluginbuf[]; | 63 | extern unsigned char pluginbuf[]; |
64 | extern void bitswap(unsigned char *data, int length); | ||
61 | #endif | 65 | #endif |
62 | 66 | ||
63 | static bool plugin_loaded = false; | 67 | static bool plugin_loaded = false; |
@@ -163,6 +167,19 @@ static struct plugin_api rockbox_api = { | |||
163 | lcd_blit, | 167 | lcd_blit, |
164 | #endif | 168 | #endif |
165 | yield, | 169 | yield, |
170 | |||
171 | plugin_get_mp3_buffer, | ||
172 | mpeg_sound_set, | ||
173 | #ifndef SIMULATOR | ||
174 | mp3_play_init, | ||
175 | mp3_play_data, | ||
176 | mp3_play_pause, | ||
177 | mp3_play_stop, | ||
178 | mp3_is_playing, | ||
179 | bitswap, | ||
180 | #endif | ||
181 | &global_settings, | ||
182 | backlight_set_timeout, | ||
166 | }; | 183 | }; |
167 | 184 | ||
168 | int plugin_load(char* plugin, void* parameter) | 185 | int plugin_load(char* plugin, void* parameter) |
@@ -294,6 +311,21 @@ void* plugin_get_buffer(int* buffer_size) | |||
294 | return &pluginbuf[buffer_pos]; | 311 | return &pluginbuf[buffer_pos]; |
295 | } | 312 | } |
296 | 313 | ||
314 | /* Returns a pointer to the mp3 buffer. | ||
315 | Playback gets stopped, to avoid conflicts. */ | ||
316 | void* plugin_get_mp3_buffer(int* buffer_size) | ||
317 | { | ||
318 | #ifdef SIMULATOR | ||
319 | static unsigned char buf[1700*1024]; | ||
320 | *buffer_size = sizeof(buf); | ||
321 | return buf; | ||
322 | #else | ||
323 | mpeg_stop(); | ||
324 | *buffer_size = mp3end - mp3buf; | ||
325 | return mp3buf; | ||
326 | #endif | ||
327 | } | ||
328 | |||
297 | static int plugin_test(int api_version, int model, int memsize) | 329 | static int plugin_test(int api_version, int model, int memsize) |
298 | { | 330 | { |
299 | if (api_version < PLUGIN_MIN_API_VERSION || | 331 | if (api_version < PLUGIN_MIN_API_VERSION || |
diff --git a/apps/plugin.h b/apps/plugin.h index b46d9a7a1c..be08091eba 100644 --- a/apps/plugin.h +++ b/apps/plugin.h | |||
@@ -41,9 +41,11 @@ | |||
41 | #include "lcd.h" | 41 | #include "lcd.h" |
42 | #include "id3.h" | 42 | #include "id3.h" |
43 | #include "mpeg.h" | 43 | #include "mpeg.h" |
44 | #include "mp3_playback.h" | ||
45 | #include "settings.h" | ||
44 | 46 | ||
45 | /* increase this every time the api struct changes */ | 47 | /* increase this every time the api struct changes */ |
46 | #define PLUGIN_API_VERSION 9 | 48 | #define PLUGIN_API_VERSION 10 |
47 | 49 | ||
48 | /* update this to latest version if a change to the api struct breaks | 50 | /* update this to latest version if a change to the api struct breaks |
49 | backwards compatibility */ | 51 | backwards compatibility */ |
@@ -181,18 +183,33 @@ struct plugin_api { | |||
181 | int (*atoi)(const char *str); | 183 | int (*atoi)(const char *str); |
182 | struct tm* (*get_time)(void); | 184 | struct tm* (*get_time)(void); |
183 | void* (*plugin_get_buffer)(int* buffer_size); | 185 | void* (*plugin_get_buffer)(int* buffer_size); |
184 | /* new stuff */ | 186 | |
187 | /* new stuff, sort in next time the API gets broken! */ | ||
185 | #ifndef HAVE_LCD_CHARCELLS | 188 | #ifndef HAVE_LCD_CHARCELLS |
186 | unsigned char* lcd_framebuffer; | 189 | unsigned char* lcd_framebuffer; |
187 | /* performance function */ | 190 | /* performance function */ |
188 | void (*lcd_blit) (unsigned char* p_data, int x, int y, int width, int height, int stride); | 191 | void (*lcd_blit) (unsigned char* p_data, int x, int y, int width, int height, int stride); |
189 | #endif | 192 | #endif |
190 | void (*yield)(void); | 193 | void (*yield)(void); |
194 | |||
195 | void* (*plugin_get_mp3_buffer)(int* buffer_size); | ||
196 | void (*mpeg_sound_set)(int setting, int value); | ||
197 | #ifndef SIMULATOR | ||
198 | void (*mp3_play_init)(void); | ||
199 | void (*mp3_play_data)(unsigned char* start, int size, void (*get_more)(unsigned char** start, int* size)); | ||
200 | void (*mp3_play_pause)(bool play); | ||
201 | void (*mp3_play_stop)(void); | ||
202 | bool (*mp3_is_playing)(void); | ||
203 | void (*bitswap)(unsigned char *data, int length); | ||
204 | #endif | ||
205 | struct user_settings* global_settings; | ||
206 | void (*backlight_set_timeout)(unsigned int index); | ||
191 | }; | 207 | }; |
192 | 208 | ||
193 | /* defined by the plugin loader (plugin.c) */ | 209 | /* defined by the plugin loader (plugin.c) */ |
194 | int plugin_load(char* plugin, void* parameter); | 210 | int plugin_load(char* plugin, void* parameter); |
195 | void* plugin_get_buffer(int *buffer_size); | 211 | void* plugin_get_buffer(int *buffer_size); |
212 | void* plugin_get_mp3_buffer(int *buffer_size); | ||
196 | 213 | ||
197 | /* defined by the plugin */ | 214 | /* defined by the plugin */ |
198 | enum plugin_status plugin_start(struct plugin_api* rockbox, void* parameter) | 215 | enum plugin_status plugin_start(struct plugin_api* rockbox, void* parameter) |