Rockbox.org home
Downloads
Release release
Dev builds dev builds
Extras extras
themes themes
Documentation
Manual manual
Wiki wiki
Device Status device status
Support
Forums forums
Mailing lists mailing lists
IRC IRC
Development
Bugs bugs
Patches patches
Dev Guide dev guide
Search



Donate

Rockbox Technical Forums


Login with username, password and session length
Home Help Search Staff List Login Register
News:

Thank You for your continued support and contributions!

+  Rockbox Technical Forums
|-+  Rockbox Development
| |-+  Starting Development and Compiling
| | |-+  Running a .rock file from a menu
« previous next »
  • Print
Pages: [1]

Author Topic: Running a .rock file from a menu  (Read 1968 times)

Offline mschneider

  • Member
  • *
  • Posts: 235
Running a .rock file from a menu
« on: January 02, 2008, 08:14:22 PM »
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: [Select]
#define     PLUGIN    PLUGIN_GAMES_DIR "/bubbles.rock"

I would then insert it into a context menu in onplay.c as MENUITEM_FUNCTION with the function looking something like this:

Code: [Select]
void goto_plugin(void)
{
    plugin_load(PLUGIN, NULL);
    return;
}

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?
Logged

Offline linuxstb

  • Developer
  • Member
  • *
  • Posts: 1163
Re: Running a .rock file from a menu
« Reply #1 on: January 02, 2008, 08:15:55 PM »
The Credits screen is a plugin, called from a menu.  Finding the code that loads that should give you a clue.
Logged

Offline LinusN

  • Member
  • *
  • Posts: 1914
Re: Running a .rock file from a menu
« Reply #2 on: January 03, 2008, 04:33:12 AM »
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?
Logged
Archos Jukebox 6000, Recorder, FM Recorder/iAudio X5/iriver H1x0, H3x0/Toshiba Gigabeat F20/iPod G5, G5.5

Offline mschneider

  • Member
  • *
  • Posts: 235
Re: Running a .rock file from a menu
« Reply #3 on: January 03, 2008, 09:06:03 PM »
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: [Select]
#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


And here is what i'm doing in onplay.c to modify the wps context menu:

Code: [Select]
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);

...and further down the menu is made:

Code: [Select]
            
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
           

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.
Logged

Offline LinusN

  • Member
  • *
  • Posts: 1914
Re: Running a .rock file from a menu
« Reply #4 on: January 04, 2008, 03:35:08 AM »
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.
« Last Edit: January 04, 2008, 06:36:35 AM by LinusN »
Logged
Archos Jukebox 6000, Recorder, FM Recorder/iAudio X5/iriver H1x0, H3x0/Toshiba Gigabeat F20/iPod G5, G5.5

Offline Job Van Dam

  • Member
  • *
  • Posts: 167
Re: Running a .rock file from a menu
« Reply #5 on: January 04, 2008, 06:45:22 PM »
Wow great code mschneider, I can defintely use this example in the future to make my own changes. Thanks alot.
Logged

Offline mschneider

  • Member
  • *
  • Posts: 235
Re: Running a .rock file from a menu
« Reply #6 on: January 05, 2008, 12:25:05 PM »
Yes it seems the api pointer was the problem. I'm really not sure why it was there (I'm pretty new to coding), I guess I assumed that because the function was part of the api I needed to point to it. Everything works now - thanks for the help!
Logged

  • Print
Pages: [1]
« previous next »
+  Rockbox Technical Forums
|-+  Rockbox Development
| |-+  Starting Development and Compiling
| | |-+  Running a .rock file from a menu
 

  • SMF 2.0.17 | SMF © 2019, Simple Machines
  • Rockbox Privacy Policy
  • XHTML
  • RSS
  • WAP2

Page created in 0.082 seconds with 15 queries.