summaryrefslogtreecommitdiff
path: root/libs/JSystem/src/JAudio2/JAISoundStarter.cpp
blob: 6de5c0c281ec02a94d77b41330ac840ad6fa235a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "JSystem/JSystem.h" // IWYU pragma: keep

#include "JSystem/JAudio2/JAISoundStarter.h"
#include "JSystem/JAudio2/JAISoundHandles.h"

JAISoundStarter::JAISoundStarter(bool setInstance) :
    JASGlobalInstance<JAISoundStarter>(setInstance) {}

JAISoundStarter::~JAISoundStarter() {}

bool JAISoundStarter::startLevelSound(JAISoundID id, JAISoundHandle* handlePtr, const JGeometry::TVec3<f32>* posPtr) {
    JUT_ASSERT(20, handlePtr);
    JAISoundHandle* handlePtr2 = handlePtr;
    if (*handlePtr2) {
        if ((*handlePtr2)->getID() == id) {
            (*handlePtr2)->updateLifeTime(1);
            if (posPtr != NULL) {
                (*handlePtr2)->setPos(*posPtr);
            }
            return true;
        }
    }

    bool rt = startSound(id, handlePtr, posPtr);
    if (rt && *handlePtr2) {
        (*handlePtr2)->setLifeTime(1, false);
    }
    return rt;
}