Update lcd-as-memframe.S to only rotate YUV data for portrait LCDs (and remove the...
[kugel-rb.git] / apps / plugin.c
bloba220e8c429b26e0bac13b01db0f6647a6d361e7a
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) || defined(COWON_D2)
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 ata_disk_is_active,
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
609 gui_syncyesno_run,
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;