Hi guys,
I’m loading music using RWops so as to benefit from the easy asset loading
on Android. Here’s my code (ASSERT macros basically just check that an
expression is true):
- SDL_RWops* binary_file;
binary_file = SDL_RWFromFile(source_file, “rb”); // read binary
ASSERT(binary_file, “Opening music file using SDL_RWops”);
// Attempt to read the file contents as music
Mix_Music* music;
ASSERT_MIX(music = Mix_LoadMUS_RW(binary_file),
“Extracting music from SDL_RWops structure”);
// Attempt to play the music
ASSERT_MIX(Mix_PlayMusic(music, -1) != -1, “Setting music to loop”);*
This works: all the assertions check out and the music plays… for maybe
10-15 seconds. Then the app crashes.
I feel I’m close to a breakthrough here -I haven’t managed to get sound
working on android via SDL till now- but it’s so close yet so far. Does
anybody know why I might be having issues here? The same code runs fine on
Linux (ie. doesn’t crash even after a full loop of the music).
I’m initialising SDL_Mixer as follows (that’s frequency and chunk size btw):
Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, MIX_DEFAULT_CHANNELS, 1024
);
Maybe it’s running out of buffer or something? Logcat sometimes show up a
bunch of warning entries just before crashing, but there are no errors:
W/dalvikvm(22087): JNI WARNING: DeleteLocalRef(0x4a32cde8) failed to find
entry (valid=1)
Any ideas?
Thanks,
William