2021-03-28 22:49:05 +02:00
|
|
|
#ifndef JAISOUNDHANDLES_H
|
|
|
|
|
#define JAISOUNDHANDLES_H
|
|
|
|
|
|
2021-09-30 07:13:49 -07:00
|
|
|
#include "JSystem/JAudio2/JAISound.h"
|
|
|
|
|
#include "JSystem/JUtility/JUTAssert.h"
|
2021-03-28 22:49:05 +02:00
|
|
|
|
2021-09-30 07:13:49 -07:00
|
|
|
class JAISound;
|
|
|
|
|
class JAISoundID;
|
|
|
|
|
|
|
|
|
|
class JAISoundHandle {
|
|
|
|
|
public:
|
2022-12-30 16:19:57 -07:00
|
|
|
JAISoundHandle() {sound_ = NULL;};
|
2023-09-15 05:20:09 -07:00
|
|
|
~JAISoundHandle() { releaseSound(); }
|
2021-09-30 07:13:49 -07:00
|
|
|
|
|
|
|
|
bool isSoundAttached() const { return sound_ != NULL; }
|
|
|
|
|
|
|
|
|
|
JAISound* operator->() const {
|
2023-09-16 10:17:56 -07:00
|
|
|
JUT_ASSERT(58, sound_ != 0);
|
2021-09-30 07:13:49 -07:00
|
|
|
return sound_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
operator bool() const { return isSoundAttached(); }
|
|
|
|
|
|
|
|
|
|
void releaseSound();
|
|
|
|
|
|
|
|
|
|
JAISound* getSound() { return sound_; }
|
|
|
|
|
|
|
|
|
|
JAISound* sound_; // member from assert in operator->()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class JAISoundHandles {
|
|
|
|
|
public:
|
|
|
|
|
JAISoundHandles(JAISoundHandle* pHandle, int param_1) {
|
2023-02-16 13:09:22 -08:00
|
|
|
mSoundHandle = pHandle;
|
2021-09-30 07:13:49 -07:00
|
|
|
numHandles_ = param_1;
|
|
|
|
|
};
|
|
|
|
|
|
2024-01-30 19:08:37 -05:00
|
|
|
JAISoundHandle& operator[](int n) { return mSoundHandle[n]; }
|
|
|
|
|
|
2023-08-01 10:17:21 +03:00
|
|
|
JAISoundHandle* getHandleSoundID(JAISoundID);
|
2021-09-30 07:13:49 -07:00
|
|
|
JAISoundHandle* getFreeHandle();
|
|
|
|
|
|
|
|
|
|
private:
|
2023-02-16 13:09:22 -08:00
|
|
|
JAISoundHandle* mSoundHandle;
|
2021-09-30 07:13:49 -07:00
|
|
|
int numHandles_;
|
|
|
|
|
};
|
|
|
|
|
|
2021-03-28 22:49:05 +02:00
|
|
|
#endif /* JAISOUNDHANDLES_H */
|