summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJörg Hohensohn <hohensoh@rockbox.org>2004-01-30 22:30:40 +0000
committerJörg Hohensohn <hohensoh@rockbox.org>2004-01-30 22:30:40 +0000
commit95298a955846d59a7758076a56df12f9996fc0bd (patch)
treed9fba4fab3fa32bfefbeba6129b35959c5c6550b
parent41354a85d9e0240121ad709ccbf704cf50c8addc (diff)
downloadrockbox-95298a955846d59a7758076a56df12f9996fc0bd.tar.gz
rockbox-95298a955846d59a7758076a56df12f9996fc0bd.zip
mp3 playback "engine" now in plugin API, rocks can make sound
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4285 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugin.c32
-rw-r--r--apps/plugin.h21
-rw-r--r--firmware/export/mp3_playback.h3
-rw-r--r--firmware/mp3_playback.c6
4 files changed, 59 insertions, 3 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 @@
58static unsigned char pluginbuf[PLUGIN_BUFFER_SIZE]; 61static unsigned char pluginbuf[PLUGIN_BUFFER_SIZE];
59#else 62#else
60extern unsigned char pluginbuf[]; 63extern unsigned char pluginbuf[];
64extern void bitswap(unsigned char *data, int length);
61#endif 65#endif
62 66
63static bool plugin_loaded = false; 67static 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
168int plugin_load(char* plugin, void* parameter) 185int 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. */
316void* 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
297static int plugin_test(int api_version, int model, int memsize) 329static 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) */
194int plugin_load(char* plugin, void* parameter); 210int plugin_load(char* plugin, void* parameter);
195void* plugin_get_buffer(int *buffer_size); 211void* plugin_get_buffer(int *buffer_size);
212void* plugin_get_mp3_buffer(int *buffer_size);
196 213
197/* defined by the plugin */ 214/* defined by the plugin */
198enum plugin_status plugin_start(struct plugin_api* rockbox, void* parameter) 215enum plugin_status plugin_start(struct plugin_api* rockbox, void* parameter)
diff --git a/firmware/export/mp3_playback.h b/firmware/export/mp3_playback.h
index 3c190f2691..15f53472bc 100644
--- a/firmware/export/mp3_playback.h
+++ b/firmware/export/mp3_playback.h
@@ -46,7 +46,7 @@ void mpeg_set_pitch(int percent);
46void demand_irq_enable(bool on); 46void demand_irq_enable(bool on);
47#endif 47#endif
48 48
49/* new functions, to be exported to plugin API */ 49/* new functions, exported to plugin API */
50void mp3_play_init(void); 50void mp3_play_init(void);
51void mp3_play_data(unsigned char* start, int size, 51void mp3_play_data(unsigned char* start, int size,
52 void (*get_more)(unsigned char** start, int* size) /* callback fn */ 52 void (*get_more)(unsigned char** start, int* size) /* callback fn */
@@ -55,6 +55,7 @@ void mp3_play_pause(bool play);
55void mp3_play_stop(void); 55void mp3_play_stop(void);
56long mp3_get_playtime(void); 56long mp3_get_playtime(void);
57void mp3_reset_playtime(void); 57void mp3_reset_playtime(void);
58bool mp3_is_playing(void);
58 59
59 60
60#define SOUND_VOLUME 0 61#define SOUND_VOLUME 0
diff --git a/firmware/mp3_playback.c b/firmware/mp3_playback.c
index fe16676624..422a0e6822 100644
--- a/firmware/mp3_playback.c
+++ b/firmware/mp3_playback.c
@@ -1086,4 +1086,10 @@ void mp3_reset_playtime(void)
1086 playstart_tick = current_tick; 1086 playstart_tick = current_tick;
1087} 1087}
1088 1088
1089
1090bool mp3_is_playing(void)
1091{
1092 return playing;
1093}
1094
1089#endif /* #ifndef SIMULATOR */ 1095#endif /* #ifndef SIMULATOR */