0

I'm trying to extend a piece of code that uses the SuperPowered audio library in an iOS application. In particular, I'm interested in the void playerEventCallback(void *clientData, SuperpoweredAdvancedAudioPlayerEvent event, void *value)callback, which gets passed a pointer to the managing SuperPowered object when the audio player is created:

SuperpoweredAdvancedAudioPlayer(void *clientData, SuperpoweredAdvancedAudioPlayerCallback callback, unsigned int sampleRate, unsigned char cachedPointCount, unsigned int internalBufferSizeSeconds = 2, unsigned int negativeSeconds = 0);

If I understand the code right, nothing prevents me from modifying this situation for my own purpose, passing, for example, a pointer to an object in an array, which would identify the player that is/was running, instead of the managing SuperPowered object.

Can I do that, or is there a consequence I should be aware of?

Kheldar
  • 5,361
  • 3
  • 34
  • 63

1 Answers1

0

I ended up doing exactly that, passing an instance of a struct defined as follows:

struct AudioPlayerWithIndex {

    int index;
    SuperpoweredAdvancedAudioPlayer* player;
    Superpowered* superpoweredInstance;

    AudioPlayerWithIndex(int index, SuperpoweredAdvancedAudioPlayer* player, Superpowered* superpoweredInstance) : index(index), player(player), superpoweredInstance(superpoweredInstance) {}
};
Kheldar
  • 5,361
  • 3
  • 34
  • 63
  • @MiliShah As I remember it, placed directly into the Superpowered.mm file you define, as per the doc. Called where your application needs it... – Kheldar Sep 27 '18 at 12:33