This site is no longer active and is available for archival purposes only. Registration and login is disabled.

OpenAL on Android: Is this a threading issue?

OpenAL on Android: Is this a threading issue?

Postby coreman2200 » Apr 26, 2012 @ 5:12pm

I've taken upon a rather ambitious game dev project using Edgelib as middleware. I've stumbled through all of my other concerns (rather valiantly lol :) but this one I'm rather stumped on.

The game project required OGG Vorbis for the background audio, and obviously as Hekkus offered no such functionality and we are still seeking cross-platform portability, I had decided to implement OpenAL Soft for such uses, with the tremolo library for very quick ogg vorbis file decoding. After a bit I got OpenAL Soft to run as it should ~ sound effects work as they should, etc. I've finally gotten the music to start streaming, too, but then the issue arises.

Depending on the size of the buffers, the music will play for some bit of time (note that I set the initial buffers in the ESound_LoadMusic function) ~ somewhere between the load function and the play function, however, the file it seems is either seemingly deleted (*sometimes* you see a GC_CONCURRENT notice in the Android log saying that it has released an amount of memory equal to the size of the ogg file that had been loaded via a package) or otherwise un-accessible when a buffer needs to be updated with more decoded data.

I may very well just be reaching, here, but I was wondering if this is a threading issue - it loads the file in a separate thread, so the play/decode functions don't have the same access to this data (if it isn't, in fact, already purged from memory). What led me to think this is that when I move all of the initializing functions (setting the ogg_file, etc) to the ESound_PlayMusic function, it immediately crashes as soon as it gets to trying to decode any data supposedly stored in a SOUND_MUSIC struct.

Just trying to figure out how to handle that situation, as I'm wellllll into (further) murky waters when it comes to threading ~ I've very little hands-on experience in that realm of development... I guess this'd be a great way to be introduced ha.

Any help would be more than appreciated ~ any further details, I'm happy to provide.

pm Member
Posts: 4
Joined: Oct 22, 2011 @ 8:22am

Re: OpenAL on Android: Is this a threading issue?

Postby coreman2200 » Apr 26, 2012 @ 11:17pm

Well, while not specifically the answer to my question, I did finally resolve the issue :)

I just re-jiggered the LoadBufferMemory function used for sound effects to essentially just Copy the memory from the data source to some newly allocated space pointed to by the data var in my SOUND_MUSIC struct, like so:

Code: Select all

void LoadBufferMemory(SOUND_MUSIC *music, void *memory, unsigned long memorysize)
    //LOGA("Loading Buffer Memory..");
    music->data = (char *)ClassEMemory::Alloc(memorysize);  //Reserve the space..
    ClassEMemory::Set(music->data, 0, memorysize);  // Initialize to zero (maybe unnecessary?
    ClassEMemory::Copy(music->data, (unsigned char *)memory, memorysize); // Copy data over..
    memory = music->data; // I changed what memory was pointing to in case it is passed on, later
    music->dataSize = music->stream.size = memorysize; // Remember file size
    music->stream.buffer = music->data; // Set the stream buffer to where data points
    //LOGA("Loading Buffer Memory Complete.");
11 lines; 7 keywds; 1 nums; 59 ops; 0 strs; 8 coms    Syntactic Coloring v0.4 - Dan East  

There was originally a call to alBufferData in there, somewhere but as I have that handled, elsewhere, it was unnecessary/possibly problematic.

Works well, now :)
pm Member
Posts: 4
Joined: Oct 22, 2011 @ 8:22am

Return to EDGELIB


Forum Description

Powerful and affordable C++ middleware solution covering true multi-platform 2D, 3D and network features for Apple iPhone, Windows Mobile, Symbian S60, UIQ, Linux and Windows desktop.



Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum