To be honest, no. Your problem here is massive memory allocations. I'm seeing 1) the ogg file, 2) the write buffer (about 11x the ogg file size), and 3) the result buffer (same as # 2). That means for every minute of 44.1kHz stereo 128kbit audio you are using 21MB of RAM!
A better solution:
A better solution:
- Use an audio library that supports PCM buffers instead of WAV. Make sure it supports partial buffers (it asks for small amounts of audio data at a time)
- Make your custom file format reader support long-lived Stream instances with seeking, then pass that to VorbisReader...
-
Decode the ogg file as needed (only decode as much as you need to fill the requested buffer size)