Results 1 to 2 of 2

Thread: Too many objects on Android JNI

  1. #1
    Newbie
    Join Date
    Mar 2015
    Posts
    1

    Too many objects on Android JNI

    Hello,
    I'm using OpenSL ES on Android via JNI to play sounds.

    I use an asset and a source for each sound, but I can't destroy them. The destroy method works on the source, but not on asset. In this way the engine stores objects and I reach the limit of 30 sounds very soon simply using the app.

    The destroy method is called in a callback on the buffer queue as the decode is done. Calling the destroy method on the player object, my app is in Application Not Responding state.

    Which is the best way to create and destroy sound sources?

  2. #2
    Member
    Join Date
    Mar 2009
    Location
    Sweden
    Posts
    64
    Hi Dariux881,

    It sounds like you are working cross-context and destroying a player in a callback, and then when the callback returns the execution thread does not have a context in which to work. Since your callback is still active, I'm guessing the implementation can't do a complete cleanup of the player and sources. Therefore your sources are still hanging around even though the player object is no longer valid. Note that contexts are implementation specific.

    I suggest you take a look at section 3.3 of the OpenSL ES 1.0.1 spec. To handle avoid cross-context issues, post a message to the main thread in your callback and clean up your players from your main thread. I recommend that you create and destroy all your objects from the main thread and not in callbacks.

    Best,

    Erik
    Erik Noreke,
    Working Group Chair OpenSL ES, OpenMAX AL and Safety Critical

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean