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