Saturday, February 26, 2011

MP3 Performance Testing

I built gmu for iz2s to compare against rockbox and see what I could dig up on the stutter problem.  I'm lazy so I only built the mpg123 codec library for gmu, but as a bonus that codec comes with the standalone mpg123 command line player.  Now the standalone mpg123 executable linked against libmpg123.so works fine, but gmu stutters just like rockbox.  So opened up top in an ssh window to investigate.  The standalone exe uses very little memory, and no threads or SDL.  It seemed to hover around 12% CPU.  GMU used about 6MB (and might have been leaking more) launched several threads, one of which used about 15% CPU and another which used about 5%.  At 6MB, there was memory to spare, so I think we can rule that out as the stutter problem.  So I think that leaves SDL and pthreads.  That 5% CPU process stands out as suspicious.  Is the SDL event loop or screen refresh code keeping the processor that busy?  Hopefully the event loop is doing nothing.  So screen refreshing?  Hmm, I think maybe gmu can run without the screen.  I'll have to read up on that. 

Anyhow 5% still doesn't seem all that bad, so I'll have to look at the pthread context switching.  Perhaps major improvements have been made in recent years.

In other news, I traded one of my troublesome 4GB SD cards for an older 2GB card which seems to make the zipit happier.  It's already survived several reboots and one actual SD card removal on my ubooted zipit.  Right not it's loaded up with the new z2lite userland, which runs the rockbox I built for wejp's userland just fine.  No stuttering, so far.  It also appears to be able to change codecs on the fly, and it even kept track of rockbox theme changes.  Now I just gotta grab a few of the ipod video 320x240 themes and try them out.  The "retroTape" theme looks like fun, while "Big info" and "DriveBox" might be good for the car.





Here's the zipit running the "Big info" theme.  I think I can read that from the driver seat.

Tuesday, February 22, 2011

Scratchbox and script practice

Turns out sound *does* work in IZ2Se after all.  It was all in the SD card.  As soon as I switched from a 4GB card to a smaller one suitable for for the stock Zipit Z2 kernel the ALSA goodies all magically started to function.  So now I just had to make some nifty scripts to work around the other issue with the SD cards - they all seem to fail/timeout somewhere in the rockbox threads whenever rockbox wants to write something to the SD card.  I already fudged the executable to do all it's working file manipulation out of /tmp, so I just needed a script to move the save state files into /tmp before starting rockbox and out to the .rockbox dir when it's done.  I also wanted to give a chance to go to headphones only before starting, and restore the speaker afterward.  It took a bit of work, but I think I have a script that'll do all that in either flavor of IZ2S and even in WEJP's os.

Rename this to rb and put it in your bin directory to make things easy.

Even so, the IZ2S version of rockbox seems to stutter a bit on startup of the first song played.  It doesn't do that on WEJP's os so maybe it's the older pthreads lib, or the older kernel, or even possibly just a slower SD card.  I don't know, so I think I might have to take another look at porting GMU to IZ2S, just in case.  But that's got a bunch of dependencies, so it seemed like a good idea to practice my lame scratchbox build skills on something a bit lighter.  I took a peek at the nanonote apps and selected nightsky since it only seemed to add SDL_image to my library list.  I ended up making a new libpng and zlib as well, but I'm not actually sure if they're needed.  I also converted all the doubles to floats since I seemed to be getting NAN errors.  What does the pxa270 compiler do when you ask for doubles?  It's already slow enough at emulating regular floating point numbers.

Anyhow, I can't see how you need double precision floats to display dots on a 320x240 screen, so it should be ok.  Don't blame me if you get lost in the woods at night though...


Here's a nightsky executable for IZ2S, along with the SDL shared libraries.

nightsky-iz2s.zip

Tuesday, February 15, 2011

Rockbox in Scratchbox

Well, I finally caved and assembled a system capable of running the scratchbox development VM for IZ2S.  And imagine that, it seems to work.  Sorta kinda.

I like all the goodies in IZ2Se, but I can't get any sound out of it.  Not even with the madplay and mpg123 executables that come with it.  But if I borrow the libSDL from IZ2Se and install it in the older IZ2S 2.05beta along with the scratchbox built rockbox, it makes noise.  Still needs work though.  I need to strip it down and tweak it a bit so it doesn't push the cpu and memory to the limits.  But this'll be really convenient because now I can load up a micro SD for the zipit with a single FAT partition containing IZ2S, rockbox, and a bunch of music.  And I can do that from Windows, Linux, or whatever.  Yay!

rockbox-iz2s.zip
libSDL is in nightsky-iz2s.zip
and
qemacs for IZ2S (everyone wants that, right?)

Tuesday, February 8, 2011

Buttons and Links

I think I figured out how the rockbox buttons are supposed to work in the SDL app.  It wants a 3x3 square of buttons that fit on the number pad.  So I filled in the missing buttons on the zipit using the O and P buttons just under the d-pad for the missing top-left and top-right buttons.  The comma and period fill in for the missing bottom-left and bottom-right buttons.  I also mapped the Zipit logo key as the top-left "Main Menu" button and the space bar as the center "Pause/Play" button for good measure.  You can never have too many redundant buttons, especially given that I can't predict how the various zipit userlands will map them.  The mouse scroll buttons turned out to be a red herring, and the volume keys on the side of the zipit work just fine when mapped to the rockbox top-middle and bottom-middle buttons.  So if anyone ever wants to run this with a usb scrolling mouse it should still work now.

Next up I'd like to add a function to toggle the headphones and speakers and hook  it up to the Q button which is nearest to the headphone jack.  That way I can avoid the alsamixer before running rockbox.  Or maybe I'll just add an alsactrl call to the rb startup script.  Hmm.

Anyhow, I made a new build and attempted to static link sdl and uclibc so I could use the same package in any userland with an updated kernel, but it still only works completely in the wejp userland.  On z2sid it runs the gui, but segfaults loading the codecs to play the songs.  So close...

rockbox-z2.tgz

Monday, February 7, 2011

Tweaking Rockbox

Not much to talk about today.  I did manage to get the +/- keys on the side of the zipit to control the volume in the Rockbox "While Playing Screen".  Yay.  Apparently the SDL app code expects to get that info from the scrollwheel and there's no such thing on the zipit.  So I disabled the wheelmouse hacks and voila, volume control.

Unfortunately the +/- keys are oriented wrong way on the zipit so when the volume works correctly the scroll action in the menus is backwards. Needs more work.  I also still need to do some more thinking on where I want to keep the runtime config files.  I got rid of the write permission errors by moving them to /tmp for now, but they really should go either in $HOME or /.rockbox.  Probably the rockbox dir since multiple users are unlikely on a zipit and that keeps it all self-contained.

I think I might try a static uclibc and sdl link soon.  In theory that should allow me do to one build for all the zipit Z2 userlands with an updated kernel, and one build for stock kernel systems like IZ2S.  I did actually try a build for IZ2S, but it just displayed the splash screen and promptly segfaulted.  Maybe I can track that down with strace, once I get the buttons and config file paths all sorted out to my liking.

Meanwhile, here's my patch file thus far and some Makefile and autoconf.h tweaks.  They're not yet up to official rockbox standards, but that can wait until it works a bit better.

rockbox-z2-patch.zip