Rockbox Technical Forums

Rockbox Development => Starting Development and Compiling => Topic started by: gama on December 12, 2012, 10:03:08 PM

Title: [QUESTION] Maximun amount of memory available for codecs?
Post by: gama on December 12, 2012, 10:03:08 PM
Hi,

  I'm working on some codec that needs a large amount of memory (~ 4MB).  When using codec_malloc the codec can only get around 500 KB of free memory, but it needs more than that for loading a song.  I have only tryied increasing the CODEC_SIZE value, but if I change it to something like 8MB the player won't load rockbox at all.

So, is there any safe way to get more free memory for the codec?.  I know my target has around 32MB of free ram, can I use that in a codec?.

My player is SamsungYPR0 with lightROM installed.  And the codec I'm working on is an update to the game_music_emu's vgm codec.  It now has support for some vgm tunes that has some big ROM data sections in them.

Thanks in advance.
Title: Re: [QUESTION] Maximun amount of memory available for codecs?
Post by: saratoga on December 12, 2012, 10:14:21 PM
By default codecs have a total of 1MB available, which is split between static allocations and malloc.  You can try to increase the codec size, but I'm not sure how that will work on application targets like the R0.  You can get a rough idea of how much memory is available by looking at the audio buffer in the debug screen, as it uses all available free memory.

Would it make more sense to use your codec as a plugin?  Plugins can use almost the entire system memory and are not restricted to streaming a single file at a time from the disk.
Title: Re: [QUESTION] Maximun amount of memory available for codecs?
Post by: gama on December 13, 2012, 05:05:10 PM
Thanks for your answer,  I tryied increasing the CODEC_SIZE for the R0 (tested with 4MB and 8MB) but the player won't load rockbox at all.  Not sure what is happening there.  I'm using the lightROM so there should be a lot of memory available.  Is there any way to get some log information when the rockbox executable is loaded?

And yes, turning the codec into a plugin should solve the memory problems, but that is not what I intended. 
I will try to find why the player hangs when I increase the codec buffer size.
Title: Re: [QUESTION] Maximun amount of memory available for codecs?
Post by: saratoga on December 13, 2012, 05:12:48 PM
Thanks for your answer,  I tryied increasing the CODEC_SIZE for the R0 (tested with 4MB and 8MB) but the player won't load rockbox at all.  Not sure what is happening there.  I'm using the lightROM so there should be a lot of memory available.  Is there any way to get some log information when the rockbox executable is loaded?

Rockbox won't provide any logs, but perhaps the underlying linux system on the R0 does? 

Alternatively, you can look at the size of the audio buffer like I suggested.  If its less then 3MB, increasing the codec size by 3MB will not be possible without figuring out a way to tell the underlying system to give rockbox more memory.  You'll need to have at least ~100KB of audio buffer to even boot rockbox, ideally more.