fix red
[Rockbox.git] / apps / plugin.c
blobbc1e8cbb7a7b8da36df407ef9eea1c0c76320349
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2002 Björn Stenberg
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
19 #include "plugin.h"
20 #include <ctype.h>
21 #include <string.h>
22 #include <sprintf.h>
23 #include <stdlib.h>
24 #include "debug.h"
25 #include "i2c.h"
26 #include "lang.h"
27 #include "led.h"
28 #include "keyboard.h"
29 #include "buffer.h"
30 #include "backlight.h"
31 #include "sound_menu.h"
32 #include "mp3data.h"
33 #include "powermgmt.h"
34 #include "splash.h"
35 #include "logf.h"
36 #include "option_select.h"
37 #include "talk.h"
39 #if CONFIG_CHARGING
40 #include "power.h"
41 #endif
43 #ifdef HAVE_LCD_BITMAP
44 #include "scrollbar.h"
45 #include "peakmeter.h"
46 #include "bmp.h"
47 #include "bidi.h"
48 #endif
50 #ifdef SIMULATOR
51 static unsigned char pluginbuf[PLUGIN_BUFFER_SIZE];
52 void *sim_plugin_load(char *plugin, void **pd);
53 void sim_plugin_close(void *pd);
54 void sim_lcd_ex_init(int shades, unsigned long (*getpixel)(int, int));
55 void sim_lcd_ex_update_rect(int x, int y, int width, int height);
56 #else
57 #define sim_plugin_close(x)
58 extern unsigned char pluginbuf[];
59 #include "bitswap.h"
60 #endif
62 /* for actual plugins only, not for codecs */
63 static bool plugin_loaded = false;
64 static int plugin_size = 0;
65 static bool (*pfn_tsr_exit)(bool reenter) = NULL; /* TSR exit callback */
66 static char current_plugin[MAX_PATH];
68 char *plugin_get_current_filename(void);
70 extern struct thread_entry threads[MAXTHREADS];
72 static const struct plugin_api rockbox_api = {
74 /* lcd */
75 lcd_set_contrast,
76 lcd_update,
77 lcd_clear_display,
78 lcd_getstringsize,
79 lcd_putsxy,
80 lcd_puts,
81 lcd_puts_scroll,
82 lcd_stop_scroll,
83 #ifdef HAVE_LCD_CHARCELLS
84 lcd_define_pattern,
85 lcd_get_locked_pattern,
86 lcd_unlock_pattern,
87 lcd_putc,
88 lcd_put_cursor,
89 lcd_remove_cursor,
90 lcd_icon,
91 lcd_double_height,
92 #else
93 &lcd_framebuffer[0][0],
94 lcd_update_rect,
95 lcd_set_drawmode,
96 lcd_get_drawmode,
97 lcd_setfont,
98 lcd_drawpixel,
99 lcd_drawline,
100 lcd_hline,
101 lcd_vline,
102 lcd_drawrect,
103 lcd_fillrect,
104 lcd_mono_bitmap_part,
105 lcd_mono_bitmap,
106 #if LCD_DEPTH > 1
107 lcd_set_foreground,
108 lcd_get_foreground,
109 lcd_set_background,
110 lcd_get_background,
111 lcd_bitmap_part,
112 lcd_bitmap,
113 lcd_get_backdrop,
114 lcd_set_backdrop,
115 #endif
116 #if LCD_DEPTH == 16
117 lcd_bitmap_transparent_part,
118 lcd_bitmap_transparent,
119 lcd_blit_yuv,
120 #if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200) || defined(SANSA_C200) \
121 || defined (IRIVER_H10)
122 lcd_yuv_set_options,
123 #endif
124 #elif (LCD_DEPTH < 4) && !defined(SIMULATOR)
125 lcd_blit_mono,
126 lcd_blit_grey_phase,
127 #endif /* LCD_DEPTH */
128 lcd_puts_style,
129 lcd_puts_scroll_style,
130 #ifdef HAVE_LCD_INVERT
131 lcd_set_invert_display,
132 #endif /* HAVE_LCD_INVERT */
133 #ifdef HAVE_LCD_ENABLE
134 lcd_set_enable_hook,
135 &button_queue,
136 #endif
137 bidi_l2v,
138 font_get_bits,
139 font_load,
140 font_get,
141 font_getstringsize,
142 font_get_width,
143 screen_clear_area,
144 gui_scrollbar_draw,
145 #endif
147 backlight_on,
148 backlight_off,
149 backlight_set_timeout,
150 #ifdef HAVE_BACKLIGHT_BRIGHTNESS
151 backlight_set_brightness,
152 #endif /* HAVE_BACKLIGHT_BRIGHTNESS */
154 #if CONFIG_CHARGING
155 backlight_set_timeout_plugged,
156 #endif
157 is_backlight_on,
158 gui_syncsplash,
160 #ifdef HAVE_REMOTE_LCD
161 /* remote lcd */
162 lcd_remote_set_contrast,
163 lcd_remote_clear_display,
164 lcd_remote_puts,
165 lcd_remote_puts_scroll,
166 lcd_remote_stop_scroll,
167 lcd_remote_set_drawmode,
168 lcd_remote_get_drawmode,
169 lcd_remote_setfont,
170 lcd_remote_getstringsize,
171 lcd_remote_drawpixel,
172 lcd_remote_drawline,
173 lcd_remote_hline,
174 lcd_remote_vline,
175 lcd_remote_drawrect,
176 lcd_remote_fillrect,
177 lcd_remote_mono_bitmap_part,
178 lcd_remote_mono_bitmap,
179 lcd_remote_putsxy,
180 lcd_remote_puts_style,
181 lcd_remote_puts_scroll_style,
182 &lcd_remote_framebuffer[0][0],
183 lcd_remote_update,
184 lcd_remote_update_rect,
186 remote_backlight_on,
187 remote_backlight_off,
188 remote_backlight_set_timeout,
189 #if CONFIG_CHARGING
190 remote_backlight_set_timeout_plugged,
191 #endif
192 #endif /* HAVE_REMOTE_LCD */
193 #if NB_SCREENS == 2
194 {&screens[SCREEN_MAIN], &screens[SCREEN_REMOTE]},
195 #else
196 {&screens[SCREEN_MAIN]},
197 #endif
198 #if defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1)
199 lcd_remote_set_foreground,
200 lcd_remote_get_foreground,
201 lcd_remote_set_background,
202 lcd_remote_get_background,
203 lcd_remote_bitmap_part,
204 lcd_remote_bitmap,
205 #endif
206 viewport_set_defaults,
208 /* list */
209 gui_synclist_init,
210 gui_synclist_set_nb_items,
211 gui_synclist_set_icon_callback,
212 gui_synclist_get_nb_items,
213 gui_synclist_get_sel_pos,
214 gui_synclist_draw,
215 gui_synclist_select_item,
216 gui_synclist_add_item,
217 gui_synclist_del_item,
218 gui_synclist_limit_scroll,
219 gui_synclist_do_button,
220 gui_synclist_set_title,
221 simplelist_info_init,
222 simplelist_show_list,
224 /* button */
225 button_get,
226 button_get_w_tmo,
227 button_status,
228 #ifdef HAVE_BUTTON_DATA
229 button_get_data,
230 #endif
231 button_clear_queue,
232 button_queue_count,
233 #ifdef HAS_BUTTON_HOLD
234 button_hold,
235 #endif
236 #ifdef HAVE_TOUCHPAD
237 touchpad_set_mode,
238 #endif
240 #ifdef HAVE_BUTTON_LIGHT
241 buttonlight_set_timeout,
242 buttonlight_off,
243 buttonlight_on,
244 #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
245 buttonlight_set_brightness,
246 #endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */
247 #endif /* HAVE_BUTTON_LIGHT */
249 /* file */
250 (open_func)PREFIX(open),
251 PREFIX(close),
252 (read_func)PREFIX(read),
253 PREFIX(lseek),
254 (creat_func)PREFIX(creat),
255 (write_func)PREFIX(write),
256 PREFIX(remove),
257 PREFIX(rename),
258 PREFIX(ftruncate),
259 PREFIX(filesize),
260 fdprintf,
261 read_line,
262 settings_parseline,
263 ata_sleep,
264 #ifndef SIMULATOR
265 ata_disk_is_active,
266 #endif
267 ata_spin,
268 ata_spindown,
269 reload_directory,
270 create_numbered_filename,
271 file_exists,
273 /* dir */
274 opendir,
275 closedir,
276 readdir,
277 mkdir,
278 rmdir,
279 dir_exists,
281 /* kernel/ system */
282 PREFIX(sleep),
283 yield,
284 &current_tick,
285 default_event_handler,
286 default_event_handler_ex,
287 threads,
288 create_thread,
289 thread_exit,
290 thread_wait,
291 #if (CONFIG_CODEC == SWCODEC)
292 mutex_init,
293 mutex_lock,
294 mutex_unlock,
295 align_buffer,
296 #endif
298 reset_poweroff_timer,
299 #ifndef SIMULATOR
300 system_memory_guard,
301 &cpu_frequency,
303 #ifdef HAVE_ADJUSTABLE_CPU_FREQ
304 #ifdef CPU_BOOST_LOGGING
305 cpu_boost_,
306 #else
307 cpu_boost,
308 #endif
309 #endif /* HAVE_ADJUSTABLE_CPU_FREQ */
310 #endif /* !SIMULATOR */
311 #ifdef HAVE_SCHEDULER_BOOSTCTRL
312 trigger_cpu_boost,
313 cancel_cpu_boost,
314 #endif
315 #ifdef CACHE_FUNCTIONS_AS_CALL
316 flush_icache,
317 invalidate_icache,
318 #endif
319 timer_register,
320 timer_unregister,
321 timer_set_period,
323 queue_init,
324 queue_delete,
325 queue_post,
326 queue_wait_w_tmo,
327 #if CONFIG_CODEC == SWCODEC
328 queue_enable_queue_send,
329 queue_empty,
330 queue_wait,
331 queue_send,
332 queue_reply,
333 #endif
334 usb_acknowledge,
335 #ifdef RB_PROFILE
336 profile_thread,
337 profstop,
338 profile_func_enter,
339 profile_func_exit,
340 #endif
342 #ifdef SIMULATOR
343 /* special simulator hooks */
344 #if defined(HAVE_LCD_BITMAP) && LCD_DEPTH < 8
345 sim_lcd_ex_init,
346 sim_lcd_ex_update_rect,
347 #endif
348 #endif
350 /* strings and memory */
351 snprintf,
352 vsnprintf,
353 strcpy,
354 strncpy,
355 strlen,
356 strrchr,
357 strcmp,
358 strncmp,
359 strcasecmp,
360 strncasecmp,
361 memset,
362 memcpy,
363 memmove,
364 _ctype_,
365 atoi,
366 strchr,
367 strcat,
368 memchr,
369 memcmp,
370 strcasestr,
371 strtok_r,
372 /* unicode stuff */
373 utf8decode,
374 iso_decode,
375 utf16LEdecode,
376 utf16BEdecode,
377 utf8encode,
378 utf8length,
379 utf8seek,
381 /* sound */
382 sound_set,
383 sound_default,
384 sound_min,
385 sound_max,
386 sound_unit,
387 sound_val2phys,
388 #ifndef SIMULATOR
389 mp3_play_data,
390 mp3_play_pause,
391 mp3_play_stop,
392 mp3_is_playing,
393 #if CONFIG_CODEC != SWCODEC
394 bitswap,
395 #endif
396 #endif
397 #if CONFIG_CODEC == SWCODEC
398 &audio_master_sampr_list[0],
399 &hw_freq_sampr[0],
400 pcm_apply_settings,
401 pcm_play_data,
402 pcm_play_stop,
403 pcm_set_frequency,
404 pcm_is_playing,
405 pcm_is_paused,
406 pcm_play_pause,
407 pcm_get_bytes_waiting,
408 pcm_calculate_peaks,
409 pcm_play_lock,
410 pcm_play_unlock,
411 #ifdef HAVE_RECORDING
412 &rec_freq_sampr[0],
413 pcm_init_recording,
414 pcm_close_recording,
415 pcm_record_data,
416 pcm_record_more,
417 pcm_stop_recording,
418 pcm_calculate_rec_peaks,
419 audio_set_recording_gain,
420 #endif /* HAVE_RECORDING */
421 #if INPUT_SRC_CAPS != 0
422 audio_set_output_source,
423 audio_set_input_source,
424 #endif
425 dsp_set_crossfeed,
426 dsp_set_eq,
427 dsp_dither_enable,
428 dsp_configure,
429 dsp_process,
430 #endif /* CONFIG_CODEC == SWCODEC */
432 /* playback control */
433 playlist_amount,
434 playlist_resume,
435 playlist_start,
436 PREFIX(audio_play),
437 audio_stop,
438 audio_pause,
439 audio_resume,
440 audio_next,
441 audio_prev,
442 audio_ff_rewind,
443 audio_next_track,
444 audio_status,
445 audio_has_changed_track,
446 audio_current_track,
447 audio_flush_and_reload_tracks,
448 audio_get_file_pos,
449 #if !defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC)
450 mpeg_get_last_header,
451 #endif
452 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) || \
453 (CONFIG_CODEC == SWCODEC)
454 sound_set_pitch,
455 #endif
457 #if !defined(SIMULATOR) && (CONFIG_CODEC != SWCODEC)
458 /* MAS communication */
459 mas_readmem,
460 mas_writemem,
461 mas_readreg,
462 mas_writereg,
463 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
464 mas_codec_writereg,
465 mas_codec_readreg,
466 i2c_begin,
467 i2c_end,
468 i2c_write,
469 #endif
470 #endif /* !SIMULATOR && CONFIG_CODEC != SWCODEC */
472 /* menu */
473 do_menu,
474 /* statusbars */
475 &statusbars,
476 gui_syncstatusbar_draw,
477 /* options */
478 find_setting,
479 option_screen,
480 set_option,
481 set_bool_options,
482 set_int,
483 set_bool,
484 #ifdef HAVE_LCD_COLOR
485 set_color,
486 #endif
488 /* action handling */
489 get_custom_action,
490 get_action,
491 action_userabort,
493 /* power */
494 battery_level,
495 battery_level_safe,
496 battery_time,
497 #ifndef SIMULATOR
498 battery_voltage,
499 #endif
500 #if CONFIG_CHARGING
501 charger_inserted,
502 # if CONFIG_CHARGING == CHARGING_MONITOR
503 charging_state,
504 # endif
505 #endif
506 #ifdef HAVE_USB_POWER
507 usb_powered,
508 #endif
510 /* misc */
511 srand,
512 rand,
513 (qsort_func)qsort,
514 kbd_input,
515 get_time,
516 set_time,
517 #if CONFIG_RTC
518 mktime,
519 #endif
520 plugin_get_buffer,
521 plugin_get_audio_buffer,
522 plugin_tsr,
523 plugin_get_current_filename,
524 #ifdef PLUGIN_USE_IRAM
525 plugin_iram_init,
526 #endif
527 #if defined(DEBUG) || defined(SIMULATOR)
528 debugf,
529 #endif
530 #ifdef ROCKBOX_HAS_LOGF
531 _logf,
532 #endif
533 &global_settings,
534 &global_status,
535 talk_disable,
536 #if CONFIG_CODEC == SWCODEC
537 codec_load_file,
538 get_codec_filename,
539 get_metadata,
540 #endif
541 mp3info,
542 count_mp3_frames,
543 create_xing_header,
544 find_next_frame,
545 #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
546 peak_meter_scale_value,
547 peak_meter_set_use_dbfs,
548 peak_meter_get_use_dbfs,
549 #endif
550 #ifdef HAVE_LCD_BITMAP
551 read_bmp_file,
552 screen_dump_set_hook,
553 #endif
554 show_logo,
555 tree_get_context,
556 set_current_file,
557 set_dirfilter,
559 #ifdef HAVE_WHEEL_POSITION
560 wheel_status,
561 wheel_send_events,
562 #endif
564 #ifdef IRIVER_H100_SERIES
565 /* Routines for the iriver_flash -plugin. */
566 detect_original_firmware,
567 detect_flashed_ramimage,
568 detect_flashed_romimage,
569 #endif
570 led,
571 #if (CONFIG_CODEC == SWCODEC)
572 bufopen,
573 bufalloc,
574 bufclose,
575 bufseek,
576 bufadvance,
577 bufread,
578 bufgetdata,
579 bufgettail,
580 bufcuttail,
582 buf_get_offset,
583 buf_handle_offset,
584 buf_request_buffer_handle,
585 buf_set_base_handle,
586 buf_used,
587 #endif
589 #ifdef HAVE_TAGCACHE
590 tagcache_search,
591 tagcache_search_set_uniqbuf,
592 tagcache_search_add_filter,
593 tagcache_get_next,
594 tagcache_retrieve,
595 tagcache_search_finish,
596 #endif
598 #ifdef HAVE_ALBUMART
599 find_albumart,
600 search_albumart_files,
601 #endif
603 /* new stuff at the end, sort into place next time
604 the API gets incompatible */
605 #ifdef HAVE_TAGCACHE
606 tagcache_get_numeric,
607 #endif
610 int plugin_load(const char* plugin, const void* parameter)
612 int rc;
613 struct plugin_header *hdr;
614 #ifdef SIMULATOR
615 void *pd;
616 #else /* !SIMULATOR */
617 int fd;
618 ssize_t readsize;
619 #if NUM_CORES > 1
620 unsigned my_core;
621 #endif
622 #endif /* !SIMULATOR */
624 #if LCD_DEPTH > 1
625 fb_data* old_backdrop;
626 #endif
628 if (pfn_tsr_exit != NULL) /* if we have a resident old plugin: */
630 if (pfn_tsr_exit(!strcmp(current_plugin, plugin)) == false )
632 /* not allowing another plugin to load */
633 return PLUGIN_OK;
635 pfn_tsr_exit = NULL;
636 plugin_loaded = false;
639 gui_syncsplash(0, ID2P(LANG_WAIT));
640 strcpy(current_plugin, plugin);
642 #ifdef SIMULATOR
643 hdr = sim_plugin_load((char *)plugin, &pd);
644 if (pd == NULL) {
645 gui_syncsplash(HZ*2, str(LANG_PLUGIN_CANT_OPEN), plugin);
646 return -1;
648 if (hdr == NULL
649 || hdr->magic != PLUGIN_MAGIC
650 || hdr->target_id != TARGET_ID) {
651 sim_plugin_close(pd);
652 gui_syncsplash(HZ*2, str(LANG_PLUGIN_WRONG_MODEL));
653 return -1;
655 if (hdr->api_version > PLUGIN_API_VERSION
656 || hdr->api_version < PLUGIN_MIN_API_VERSION) {
657 sim_plugin_close(pd);
658 gui_syncsplash(HZ*2, str(LANG_PLUGIN_WRONG_VERSION));
659 return -1;
661 #else
662 fd = open(plugin, O_RDONLY);
663 if (fd < 0) {
664 gui_syncsplash(HZ*2, str(LANG_PLUGIN_CANT_OPEN), plugin);
665 return fd;
667 #if NUM_CORES > 1
668 /* Make sure COP cache is flushed and invalidated before loading */
669 my_core = switch_core(CURRENT_CORE ^ 1);
670 invalidate_icache();
671 switch_core(my_core);
672 #endif
674 readsize = read(fd, pluginbuf, PLUGIN_BUFFER_SIZE);
675 close(fd);
677 if (readsize < 0) {
678 gui_syncsplash(HZ*2, str(LANG_READ_FAILED), plugin);
679 return -1;
681 hdr = (struct plugin_header *)pluginbuf;
683 if ((unsigned)readsize <= sizeof(struct plugin_header)
684 || hdr->magic != PLUGIN_MAGIC
685 || hdr->target_id != TARGET_ID
686 || hdr->load_addr != pluginbuf
687 || hdr->end_addr > pluginbuf + PLUGIN_BUFFER_SIZE) {
688 gui_syncsplash(HZ*2, str(LANG_PLUGIN_WRONG_MODEL));
689 return -1;
691 if (hdr->api_version > PLUGIN_API_VERSION
692 || hdr->api_version < PLUGIN_MIN_API_VERSION) {
693 gui_syncsplash(HZ*2, str(LANG_PLUGIN_WRONG_VERSION));
694 return -1;
696 plugin_size = hdr->end_addr - pluginbuf;
698 /* zero out bss area only, above guards end of pluginbuf */
699 if (plugin_size > readsize)
700 memset(pluginbuf + readsize, 0, plugin_size - readsize);
701 #endif
703 plugin_loaded = true;
706 #if defined HAVE_LCD_BITMAP && LCD_DEPTH > 1
707 old_backdrop = lcd_get_backdrop();
708 #endif
709 lcd_clear_display();
710 lcd_update();
712 #ifdef HAVE_REMOTE_LCD
713 lcd_remote_clear_display();
714 lcd_remote_update();
715 #endif
717 invalidate_icache();
719 rc = hdr->entry_point(&rockbox_api, parameter);
721 button_clear_queue();
723 #ifdef HAVE_LCD_BITMAP
724 #if LCD_DEPTH > 1
725 lcd_set_backdrop(old_backdrop);
726 #ifdef HAVE_LCD_COLOR
727 lcd_set_drawinfo(DRMODE_SOLID, global_settings.fg_color,
728 global_settings.bg_color);
729 #else
730 lcd_set_drawinfo(DRMODE_SOLID, LCD_DEFAULT_FG, LCD_DEFAULT_BG);
731 #endif
732 #else /* LCD_DEPTH == 1 */
733 lcd_set_drawmode(DRMODE_SOLID);
734 #endif /* LCD_DEPTH */
735 #endif /* HAVE_LCD_BITMAP */
737 lcd_clear_display();
738 lcd_update();
740 #ifdef HAVE_REMOTE_LCD
741 #if LCD_REMOTE_DEPTH > 1
742 lcd_remote_set_drawinfo(DRMODE_SOLID, LCD_REMOTE_DEFAULT_FG,
743 LCD_REMOTE_DEFAULT_BG);
744 #else
745 lcd_remote_set_drawmode(DRMODE_SOLID);
746 #endif
747 lcd_remote_clear_display();
750 lcd_remote_update();
753 #endif
755 if (pfn_tsr_exit == NULL)
756 plugin_loaded = false;
758 sim_plugin_close(pd);
760 switch (rc) {
761 case PLUGIN_OK:
762 break;
764 case PLUGIN_USB_CONNECTED:
765 return PLUGIN_USB_CONNECTED;
767 default:
768 gui_syncsplash(HZ*2, str(LANG_PLUGIN_ERROR));
769 break;
771 return PLUGIN_OK;
774 /* Returns a pointer to the portion of the plugin buffer that is not already
775 being used. If no plugin is loaded, returns the entire plugin buffer */
776 void* plugin_get_buffer(size_t *buffer_size)
778 int buffer_pos;
780 if (plugin_loaded)
782 if (plugin_size >= PLUGIN_BUFFER_SIZE)
783 return NULL;
785 *buffer_size = PLUGIN_BUFFER_SIZE-plugin_size;
786 buffer_pos = plugin_size;
788 else
790 *buffer_size = PLUGIN_BUFFER_SIZE;
791 buffer_pos = 0;
794 return &pluginbuf[buffer_pos];
797 /* Returns a pointer to the mp3 buffer.
798 Playback gets stopped, to avoid conflicts.
799 Talk buffer is stolen as well.
801 void* plugin_get_audio_buffer(size_t *buffer_size)
803 #if CONFIG_CODEC == SWCODEC
804 return audio_get_buffer(true, buffer_size);
805 #else
806 audio_stop();
807 talk_buffer_steal(); /* we use the mp3 buffer, need to tell */
808 *buffer_size = audiobufend - audiobuf;
809 return audiobuf;
810 #endif
813 #ifdef PLUGIN_USE_IRAM
814 /* Initializes plugin IRAM */
815 void plugin_iram_init(char *iramstart, char *iramcopy, size_t iram_size,
816 char *iedata, size_t iedata_size)
818 /* We need to stop audio playback in order to use codec IRAM */
819 audio_hard_stop();
820 memcpy(iramstart, iramcopy, iram_size);
821 memset(iedata, 0, iedata_size);
822 memset(iramcopy, 0, iram_size);
823 #if NUM_CORES > 1
824 /* writeback cleared iedata and iramcopy areas */
825 flush_icache();
826 #endif
828 #endif /* PLUGIN_USE_IRAM */
830 /* The plugin wants to stay resident after leaving its main function, e.g.
831 runs from timer or own thread. The callback is registered to later
832 instruct it to free its resources before a new plugin gets loaded. */
833 void plugin_tsr(bool (*exit_callback)(bool))
835 pfn_tsr_exit = exit_callback; /* remember the callback for later */
838 char *plugin_get_current_filename(void)
840 return current_plugin;