MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / play

Method play

extlibs/soloud/src/core/soloud_core_basicops.cpp:32–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30namespace SoLoud
31{
32 handle Soloud::play(AudioSource &aSound, float aVolume, float aPan, bool aPaused, unsigned int aBus)
33 {
34 if (aSound.mFlags & AudioSource::SINGLE_INSTANCE)
35 {
36 // Only one instance allowed, stop others
37 aSound.stop();
38 }
39
40 // Creation of an audio instance may take significant amount of time,
41 // so let's not do it inside the audio thread mutex.
42 aSound.mSoloud = this;
43 SoLoud::AudioSourceInstance *instance = aSound.createInstance();
44
45 lockAudioMutex();
46 int ch = findFreeVoice();
47 if (ch < 0)
48 {
49 unlockAudioMutex();
50 delete instance;
51 return UNKNOWN_ERROR;
52 }
53 if (!aSound.mAudioSourceID)
54 {
55 aSound.mAudioSourceID = mAudioSourceID;
56 mAudioSourceID++;
57 }
58 mVoice[ch] = instance;
59 mVoice[ch]->mAudioSourceID = aSound.mAudioSourceID;
60 mVoice[ch]->mBusHandle = aBus;
61 mVoice[ch]->init(aSound, mPlayIndex);
62 m3dData[ch].init(aSound);
63
64 mPlayIndex++;
65
66 // 20 bits, skip the last one (top bits full = voice group)
67 if (mPlayIndex == 0xfffff)
68 {
69 mPlayIndex = 0;
70 }
71
72 if (aPaused)
73 {
74 mVoice[ch]->mFlags |= AudioSourceInstance::PAUSED;
75 }
76
77 setVoicePan(ch, aPan);
78 if (aVolume < 0)
79 {
80 setVoiceVolume(ch, aSound.mVolume);
81 }
82 else
83 {
84 setVoiceVolume(ch, aVolume);
85 }
86
87 // Fix initial voice volume ramp up
88 int i;
89 for (i = 0; i < MAX_CHANNELS; i++)

Callers

nothing calls this directly

Calls 3

stopMethod · 0.45
createInstanceMethod · 0.45
initMethod · 0.45

Tested by

no test coverage detected