Rockbox Development > Starting Development and Compiling
Running a .rock file from a menu
mschneider:
I've configured a menu with a new option "goto *insert plugin here*". Now I've set a path in settings.h for the files and tried using the function plugin_load to run it but i just get a freeze.
I would configure in settings.h:
--- Code: ---#define PLUGIN PLUGIN_GAMES_DIR "/bubbles.rock"
--- End code ---
I would then insert it into a context menu in onplay.c as MENUITEM_FUNCTION with the function looking something like this:
--- Code: ---void goto_plugin(void)
{
plugin_load(PLUGIN, NULL);
return;
}
--- End code ---
Everything compiles but whenever i select the item in the menu everything just freezes. Is there some other function i could use or am i doing something wrong?
linuxstb:
The Credits screen is a plugin, called from a menu. Finding the code that loads that should give you a clue.
LinusN:
The code looks conceptually correct, but I hope you aren't using PLUGIN as the name for your plugin #define. It would be easier to help you if you showed us the actual code. Do you get any warnings when you compile it?
mschneider:
yes i've taken a look at the main menu file that accesses the credits and it's doing pretty much the same thing (mine is not in a conditional). Here's my modification in settings.h:
--- Code: ---#define FMPRESET_PATH ROCKBOX_DIR "/fmpresets"
#define VIEWERS_CONFIG ROCKBOX_DIR "/viewers.config"
#define CONFIGFILE ROCKBOX_DIR "/config.cfg"
#define FIXEDSETTINGSFILE ROCKBOX_DIR "/fixed.cfg"
#define CUBE PLUGIN_DEMOS_DIR "/cube.rock"
#define MAX_FILENAME 32
#define BOOKMARK_NO 0
#define BOOKMARK_YES 1
#define BOOKMARK_ASK 2
--- End code ---
And here is what i'm doing in onplay.c to modify the wps context menu:
--- Code: ---static void cube_demo(void)
{
api->audio_stop();
plugin_load(CUBE, NULL);
return;
}
MENUITEM_FUNCTION(view_cue_item, 0, ID2P(LANG_BROWSE_CUESHEET),
view_cue, NULL, view_cue_item_callback, Icon_NOICON);
/* CONTEXT_WPS items */
MENUITEM_FUNCTION(browse_id3_item, 0, ID2P(LANG_MENU_SHOW_ID3_INFO),
browse_id3, NULL, NULL, Icon_NOICON);
#ifdef HAVE_PITCHSCREEN
MENUITEM_FUNCTION(pitch_screen_item, 0, ID2P(LANG_PITCH),
pitch_screen, NULL, NULL, Icon_Audio);
#endif
MENUITEM_FUNCTION(goto_demo, 0, "Goto Demo", cube_demo, NULL, NULL, Icon_NOICON);
--- End code ---
...and further down the menu is made:
--- Code: ---
MAKE_ONPLAYMENU( wps_onplay_menu, ID2P(LANG_ONPLAY_MENU_TITLE),
onplaymenu_callback, Icon_Audio,
&sound_settings, &wps_playlist_menu, &cat_playlist_menu,
&goto_demo,
#ifdef HAVE_TAGCACHE
&rating_item,
#endif
--- End code ---
Everything compiles fine and the option is added to the context menu but whenever I select the item audio stops (like i wanted it too), but then everything just freezes. So I'm not sure if the audio is actually stopping because I told it too or because of the freeze. This makes me think that there is something wrong with the function, but I can't find anything.
LinusN:
Interesting. What is this api-> pointer? There is no such thing in the current Rockbox source.
I tried your code in the simulator, and it worked perfectly (after removing the api-> pointer usage).
What target platform do you use?
*edit* I have now run it on my H140 player as well without problems. Works perfectly.
Navigation
[0] Message Index
[#] Next page
Go to full version