From 6f030a01c97063b4ec0e1c30a62016cbfd8eea05 Mon Sep 17 00:00:00 2001 From: Andrew Mahone Date: Fri, 6 Mar 2009 01:08:02 +0000 Subject: add the needed plugin API exports for pictureflow to hwcodec, use the audio buffer if plugin buffer is too small, build on any target with bitmap + tagcache git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20213 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugin.c | 2 +- apps/plugin.h | 6 +++--- apps/plugins/SOURCES | 2 +- apps/plugins/pictureflow.c | 54 +++++++++++++++++++++++++--------------------- 4 files changed, 34 insertions(+), 30 deletions(-) diff --git a/apps/plugin.c b/apps/plugin.c index 115db060bf..d72e439bec 100644 --- a/apps/plugin.c +++ b/apps/plugin.c @@ -557,8 +557,8 @@ static const struct plugin_api rockbox_api = { codec_thread_do_callback, codec_load_file, get_codec_filename, - get_metadata, #endif + get_metadata, mp3info, count_mp3_frames, create_xing_header, diff --git a/apps/plugin.h b/apps/plugin.h index 1c8682f43b..fd3e276dcd 100644 --- a/apps/plugin.h +++ b/apps/plugin.h @@ -127,12 +127,12 @@ void* plugin_get_buffer(size_t *buffer_size); #define PLUGIN_MAGIC 0x526F634B /* RocK */ /* increase this every time the api struct changes */ -#define PLUGIN_API_VERSION 143 +#define PLUGIN_API_VERSION 144 /* update this to latest version if a change to the api struct breaks backwards compatibility (and please take the opportunity to sort in any new function which are "waiting" at the end of the function table) */ -#define PLUGIN_MIN_API_VERSION 143 +#define PLUGIN_MIN_API_VERSION 144 /* plugin return codes */ enum plugin_status { @@ -698,8 +698,8 @@ struct plugin_api { unsigned int *audio_thread_id); int (*codec_load_file)(const char* codec, struct codec_api *api); const char *(*get_codec_filename)(int cod_spec); - bool (*get_metadata)(struct mp3entry* id3, int fd, const char* trackname); #endif + bool (*get_metadata)(struct mp3entry* id3, int fd, const char* trackname); bool (*mp3info)(struct mp3entry *entry, const char *filename); int (*count_mp3_frames)(int fd, int startpos, int filesize, void (*progressfunc)(int)); diff --git a/apps/plugins/SOURCES b/apps/plugins/SOURCES index 7854ef3e1d..d9ed9ac24f 100644 --- a/apps/plugins/SOURCES +++ b/apps/plugins/SOURCES @@ -56,7 +56,7 @@ text_editor.c wavview.c robotfindskitten.c -#if defined(HAVE_TAGCACHE) && (CONFIG_CODEC == SWCODEC) +#if defined(HAVE_TAGCACHE) pictureflow.c #endif diff --git a/apps/plugins/pictureflow.c b/apps/plugins/pictureflow.c index 58d2869ecc..59b7c84f55 100644 --- a/apps/plugins/pictureflow.c +++ b/apps/plugins/pictureflow.c @@ -286,8 +286,8 @@ static int selected_track; static int selected_track_pulse; void reset_track_list(void); -void * plugin_buf; -size_t plugin_buf_size; +void * buf; +size_t buf_size; static int old_drawmode; @@ -566,43 +566,43 @@ void init_reflect_table(void) */ int create_album_index(void) { - plugin_buf_size -= UNIQBUF_SIZE * sizeof(long); - long *uniqbuf = (long *)(plugin_buf_size + (char *)plugin_buf); + buf_size -= UNIQBUF_SIZE * sizeof(long); + long *uniqbuf = (long *)(buf_size + (char *)buf); album = ((struct album_data *)uniqbuf) - 1; rb->memset(&tcs, 0, sizeof(struct tagcache_search) ); album_count = 0; rb->tagcache_search(&tcs, tag_album); rb->tagcache_search_set_uniqbuf(&tcs, uniqbuf, UNIQBUF_SIZE); unsigned int l, old_l = 0; - album_names = plugin_buf; + album_names = buf; album[0].name_idx = 0; while (rb->tagcache_get_next(&tcs)) { - plugin_buf_size -= sizeof(struct album_data); + buf_size -= sizeof(struct album_data); l = rb->strlen(tcs.result) + 1; if ( album_count > 0 ) album[-album_count].name_idx = album[1-album_count].name_idx + old_l; - if ( l > plugin_buf_size ) + if ( l > buf_size ) /* not enough memory */ return ERROR_BUFFER_FULL; - rb->strcpy(plugin_buf, tcs.result); - plugin_buf_size -= l; - plugin_buf = l + (char *)plugin_buf; + rb->strcpy(buf, tcs.result); + buf_size -= l; + buf = l + (char *)buf; album[-album_count].seek = tcs.result_seek; old_l = l; album_count++; } rb->tagcache_search_finish(&tcs); - ALIGN_BUFFER(plugin_buf, plugin_buf_size, 4); + ALIGN_BUFFER(buf, buf_size, 4); int i; - struct album_data* tmp_album = (struct album_data*)plugin_buf; + struct album_data* tmp_album = (struct album_data*)buf; for (i = album_count - 1; i >= 0; i--) tmp_album[i] = album[-i]; album = tmp_album; - plugin_buf = album + album_count; - plugin_buf_size += UNIQBUF_SIZE * sizeof(long); + buf = album + album_count; + buf_size += UNIQBUF_SIZE * sizeof(long); return (album_count > 0) ? 0 : ERROR_NO_ALBUMS; } @@ -817,11 +817,11 @@ bool create_albumart_cache(void) if (!get_albumart_for_index_from_db(i, albumart_file, MAX_PATH)) continue; - input_bmp.data = plugin_buf; + input_bmp.data = buf; input_bmp.width = DISPLAY_WIDTH; input_bmp.height = DISPLAY_HEIGHT; ret = scaled_read_bmp_file(albumart_file, &input_bmp, - plugin_buf_size, format, &format_transposed); + buf_size, format, &format_transposed); if (ret <= 0) { rb->splash(HZ, "Could not read bmp"); continue; /* skip missing/broken files */ @@ -1810,9 +1810,9 @@ int create_empty_slide(bool force) #if LCD_DEPTH > 1 input_bmp.format = FORMAT_NATIVE; #endif - input_bmp.data = (char*)plugin_buf; + input_bmp.data = (char*)buf; ret = scaled_read_bmp_file(EMPTY_SLIDE_BMP, &input_bmp, - plugin_buf_size, + buf_size, FORMAT_NATIVE|FORMAT_RESIZE|FORMAT_KEEP_ASPECT, &format_transposed); if (!save_pfraw(EMPTY_SLIDE, &input_bmp)) @@ -2197,7 +2197,7 @@ int main(void) init_reflect_table(); - ALIGN_BUFFER(plugin_buf, plugin_buf_size, 4); + ALIGN_BUFFER(buf, buf_size, 4); ret = create_album_index(); if (ret == ERROR_BUFFER_FULL) { rb->splash(HZ, "Not enough memory for album names"); @@ -2207,7 +2207,7 @@ int main(void) return PLUGIN_ERROR; } - ALIGN_BUFFER(plugin_buf, plugin_buf_size, 4); + ALIGN_BUFFER(buf, buf_size, 4); number_of_slides = album_count; if ((cache_version != CACHE_VERSION) && !create_albumart_cache()) { rb->splash(HZ, "Could not create album art cache"); @@ -2224,17 +2224,17 @@ int main(void) #ifdef USEGSLIB long grey_buf_used; - if (!grey_init(plugin_buf, plugin_buf_size, GREY_BUFFERED|GREY_ON_COP, + if (!grey_init(buf, buf_size, GREY_BUFFERED|GREY_ON_COP, LCD_WIDTH, LCD_HEIGHT, &grey_buf_used)) { rb->splash(HZ, "Greylib init failed!"); return PLUGIN_ERROR; } grey_setfont(FONT_UI); - plugin_buf_size -= grey_buf_used; - plugin_buf = (void*)(grey_buf_used + (char*)plugin_buf); + buf_size -= grey_buf_used; + buf = (void*)(grey_buf_used + (char*)buf); #endif - buflib_init(&buf_ctx, (void *)plugin_buf, plugin_buf_size); + buflib_init(&buf_ctx, (void *)buf, buf_size); if (!(empty_slide_hid = read_pfraw(EMPTY_SLIDE, 0))) { @@ -2444,7 +2444,11 @@ enum plugin_status plugin_start(const void *parameter) #ifdef HAVE_ADJUSTABLE_CPU_FREQ rb->cpu_boost(true); #endif - plugin_buf = rb->plugin_get_buffer(&plugin_buf_size); +#if PLUGIN_BUFFER_SIZE > 0x10000 + buf = rb->plugin_get_buffer(&buf_size); +#else + buf = rb->plugin_get_audio_buffer(&buf_size); +#endif ret = main(); #ifdef HAVE_ADJUSTABLE_CPU_FREQ rb->cpu_boost(false); -- cgit v1.2.3