Audiokinetic's Community Q&A is the forum where users can ask and answer questions within the Wwise and Strata communities. If you would like to get an answer from Audiokinetic's Technical support team, make sure you use the Support Tickets page.

BUG GetPlayingIDsFromGameObject returns 0 for all playIds

+2 votes

I get a bug when using AkSoundEngine.GetPlayingIDsFromGameObject in Unity. Here's my code:

uint[] playingIds = new uint[50];
uint count = 0;
AKRESULT result = AkSoundEngine.GetPlayingIDsFromGameObject(gameObject, ref count, playingIds);

If an event is plyaing on the gameObject this results in a count > 0 but playingIds is always full of only 0 (it doesn't contain any playing ids. This must be a bug right?

Edit: I'm on Wwise 2019.1.1.6977

asked Mar 13, 2020 in General Discussion by Simon S. (260 points)

1 Answer

–1 vote
the 2nd argument was explained in SDK:

"Number of items in array provided / Number of items filled in array",

you should change the initial value of the "count" to 1 or bigger. :)
answered Mar 8, 2022 by 05 (500 points)
I don't think this is correct. The SDK actually has a note about this:
"Note: It is possible to call GetPlayingIDsFromGameObject with io_ruNumItems = 0 to get the total size of the structure that should be allocated for out_aPlayingIDs."
https://www.audiokinetic.com/en/library/edge/?source=SDK&id=namespace_a_k_1_1_sound_engine_1_1_query_a8263cb018517fadf2220ca00d88f907f.html

You'll notice that the 3 arguments listed have "in_", "out_" or "io_" prefixes.  

```
AkGameObjectID in_GameObjId,
AkUint32& io_ruNumIDs,
AkPlayingId* out_aPlayingIDs
```

It expects a valid GameObjectId as an input, it outputs the PlayingIDs to the out_aPlayingIDs, but the 2nd argument has an "io_" prefix to note that it is both an input AND an output. If you input 0, it should update that 2nd reference argument with the correct number of PlayingIds that get returned in out_aPlayingIDs.  That's super useful if you need to iterate over the expected list of PlayingIds because it gives you a nice number to use for a loop over the raw pointer out_aPlayingIDs.

I'm having the same problem as OP though where I post an Event from a specific AkComponent, then I use GetPlayingIDsFromGameObject after the event has been posted and the AKRESULT returns AK_Fail.
Also having this issue in Wwise 2022_1. NumIDs might come back with a value greater than 0 but the actual id's in the array are all 0.
...