AudioProxy.cpp 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <AudioProxy.h>
  9. #include <ATLCommon.h>
  10. #include <SoundCVars.h>
  11. namespace Audio
  12. {
  13. ///////////////////////////////////////////////////////////////////////////////////////////////////
  14. CAudioProxy::~CAudioProxy()
  15. {
  16. Release(); // this should be okay to do if we no longer queue Release requests.
  17. }
  18. ///////////////////////////////////////////////////////////////////////////////////////////////////
  19. void CAudioProxy::Initialize(const char* sObjectName, void* ownerOverride, bool bInitAsync /* = true */)
  20. {
  21. if (HasId())
  22. {
  23. // Already has an ID assigned, nothing needed
  24. return;
  25. }
  26. m_ownerOverride = ownerOverride;
  27. Audio::SystemRequest::ReserveObject reserveObject;
  28. reserveObject.m_objectName = (sObjectName ? sObjectName : "");
  29. reserveObject.m_callback = [this](const Audio::SystemRequest::ReserveObject& request)
  30. {
  31. // Assign the new audio object ID...
  32. m_nAudioObjectID = request.m_objectId;
  33. m_waitingForId = false;
  34. // Now execute any requests queued while this was waiting for an ID assignment
  35. ExecuteQueuedRequests();
  36. };
  37. // 0: instance-specific initialization (default). So the bAsync flag is used to determine init type.
  38. // 1: All initialize sync
  39. // 2: All initialize async
  40. m_waitingForId = true;
  41. auto audioProxiesInitType = static_cast<AZ::u32>(Audio::CVars::s_AudioProxiesInitType);
  42. if ((bInitAsync && audioProxiesInitType == 0) || audioProxiesInitType == 2)
  43. {
  44. AZ::Interface<IAudioSystem>::Get()->PushRequest(AZStd::move(reserveObject));
  45. }
  46. else
  47. {
  48. reserveObject.m_flags = eARF_SYNC_CALLBACK;
  49. AZ::Interface<IAudioSystem>::Get()->PushRequestBlocking(AZStd::move(reserveObject));
  50. AZ_Assert(m_nAudioObjectID != INVALID_AUDIO_OBJECT_ID, "Failed to reserve audio object ID on AudioProxy '%s'", sObjectName);
  51. }
  52. }
  53. ///////////////////////////////////////////////////////////////////////////////////////////////////
  54. void CAudioProxy::ExecuteTrigger(TAudioControlID nTriggerID)
  55. {
  56. Audio::ObjectRequest::ExecuteTrigger execTrigger;
  57. execTrigger.m_triggerId = nTriggerID;
  58. execTrigger.m_owner = (m_ownerOverride ? m_ownerOverride : this);
  59. if (HasId())
  60. {
  61. execTrigger.m_audioObjectId = m_nAudioObjectID;
  62. AZ::Interface<IAudioSystem>::Get()->PushRequest(AZStd::move(execTrigger));
  63. }
  64. else
  65. {
  66. TryEnqueueRequest(AZStd::move(execTrigger));
  67. }
  68. }
  69. ///////////////////////////////////////////////////////////////////////////////////////////////////
  70. void CAudioProxy::ExecuteSourceTrigger(TAudioControlID nTriggerID, const SAudioSourceInfo& rSourceInfo)
  71. {
  72. Audio::ObjectRequest::ExecuteSourceTrigger execSourceTrigger;
  73. execSourceTrigger.m_triggerId = nTriggerID;
  74. execSourceTrigger.m_sourceInfo = rSourceInfo;
  75. execSourceTrigger.m_owner = (m_ownerOverride ? m_ownerOverride : this);
  76. if (HasId())
  77. {
  78. execSourceTrigger.m_audioObjectId = m_nAudioObjectID;
  79. AZ::Interface<IAudioSystem>::Get()->PushRequest(AZStd::move(execSourceTrigger));
  80. }
  81. else
  82. {
  83. TryEnqueueRequest(AZStd::move(execSourceTrigger));
  84. }
  85. }
  86. ///////////////////////////////////////////////////////////////////////////////////////////////////
  87. void CAudioProxy::StopAllTriggers()
  88. {
  89. Audio::ObjectRequest::StopAllTriggers stopAll;
  90. stopAll.m_owner = (m_ownerOverride ? m_ownerOverride : this);
  91. stopAll.m_filterByOwner = true;
  92. if (HasId())
  93. {
  94. stopAll.m_audioObjectId = m_nAudioObjectID;
  95. AZ::Interface<IAudioSystem>::Get()->PushRequest(AZStd::move(stopAll));
  96. }
  97. else
  98. {
  99. TryEnqueueRequest(AZStd::move(stopAll));
  100. }
  101. }
  102. ///////////////////////////////////////////////////////////////////////////////////////////////////
  103. void CAudioProxy::StopTrigger(TAudioControlID nTriggerID)
  104. {
  105. Audio::ObjectRequest::StopTrigger stopTrigger;
  106. stopTrigger.m_triggerId = nTriggerID;
  107. stopTrigger.m_owner = (m_ownerOverride ? m_ownerOverride : this);
  108. if (HasId())
  109. {
  110. stopTrigger.m_audioObjectId = m_nAudioObjectID;
  111. AZ::Interface<IAudioSystem>::Get()->PushRequest(AZStd::move(stopTrigger));
  112. }
  113. else
  114. {
  115. TryEnqueueRequest(AZStd::move(stopTrigger));
  116. }
  117. }
  118. ///////////////////////////////////////////////////////////////////////////////////////////////////
  119. void CAudioProxy::SetSwitchState(TAudioControlID nSwitchID, TAudioSwitchStateID nStateID)
  120. {
  121. Audio::ObjectRequest::SetSwitchValue setSwitch;
  122. setSwitch.m_switchId = nSwitchID;
  123. setSwitch.m_stateId = nStateID;
  124. if (HasId())
  125. {
  126. setSwitch.m_audioObjectId = m_nAudioObjectID;
  127. AZ::Interface<IAudioSystem>::Get()->PushRequest(AZStd::move(setSwitch));
  128. }
  129. else
  130. {
  131. TryEnqueueRequest(AZStd::move(setSwitch));
  132. }
  133. }
  134. ///////////////////////////////////////////////////////////////////////////////////////////////////
  135. void CAudioProxy::SetRtpcValue(TAudioControlID nRtpcID, float fValue)
  136. {
  137. Audio::ObjectRequest::SetParameterValue setParameter;
  138. setParameter.m_parameterId = nRtpcID;
  139. setParameter.m_value = fValue;
  140. if (HasId())
  141. {
  142. setParameter.m_audioObjectId = m_nAudioObjectID;
  143. AZ::Interface<IAudioSystem>::Get()->PushRequest(AZStd::move(setParameter));
  144. }
  145. else
  146. {
  147. TryEnqueueRequest(AZStd::move(setParameter));
  148. }
  149. }
  150. ///////////////////////////////////////////////////////////////////////////////////////////////////
  151. void CAudioProxy::SetObstructionCalcType(ObstructionType eObstructionType)
  152. {
  153. const size_t obstructionType = static_cast<size_t>(eObstructionType);
  154. if (obstructionType < AZ_ARRAY_SIZE(ATLInternalControlIDs::OOCStateIDs))
  155. {
  156. SetSwitchState(ATLInternalControlIDs::ObstructionOcclusionCalcSwitchID, ATLInternalControlIDs::OOCStateIDs[obstructionType]);
  157. }
  158. }
  159. ///////////////////////////////////////////////////////////////////////////////////////////////////
  160. void CAudioProxy::SetPosition(const SATLWorldPosition& refPosition)
  161. {
  162. Audio::ObjectRequest::SetPosition setPosition;
  163. if (HasId())
  164. {
  165. // Update position only if the delta exceeds a given value.
  166. if (Audio::CVars::s_PositionUpdateThreshold <= 0.f // <-- no gating
  167. || !refPosition.GetPositionVec().IsClose(m_oPosition.GetPositionVec(), Audio::CVars::s_PositionUpdateThreshold))
  168. {
  169. m_oPosition = refPosition;
  170. // Make sure the forward/up directions are normalized
  171. m_oPosition.NormalizeForwardVec();
  172. m_oPosition.NormalizeUpVec();
  173. setPosition.m_audioObjectId = m_nAudioObjectID;
  174. setPosition.m_position = m_oPosition;
  175. AZ::Interface<IAudioSystem>::Get()->PushRequest(AZStd::move(setPosition));
  176. }
  177. }
  178. else
  179. {
  180. // If a SetPosition is queued during init, don't need to check threshold.
  181. m_oPosition = refPosition;
  182. // Make sure the forward/up directions are normalized
  183. m_oPosition.NormalizeForwardVec();
  184. m_oPosition.NormalizeUpVec();
  185. setPosition.m_position = refPosition;
  186. TryEnqueueRequest(AZStd::move(setPosition));
  187. }
  188. }
  189. ///////////////////////////////////////////////////////////////////////////////////////////////////
  190. void CAudioProxy::SetPosition(const AZ::Vector3& refPosition)
  191. {
  192. SetPosition(SATLWorldPosition(refPosition));
  193. }
  194. ///////////////////////////////////////////////////////////////////////////////////////////////////
  195. void CAudioProxy::SetMultiplePositions(const MultiPositionParams& params)
  196. {
  197. Audio::ObjectRequest::SetMultiplePositions setMultiPosition;
  198. setMultiPosition.m_params = params;
  199. if (HasId())
  200. {
  201. setMultiPosition.m_audioObjectId = m_nAudioObjectID;
  202. AZ::Interface<IAudioSystem>::Get()->PushRequest(AZStd::move(setMultiPosition));
  203. }
  204. else
  205. {
  206. TryEnqueueRequest(AZStd::move(setMultiPosition));
  207. }
  208. }
  209. ///////////////////////////////////////////////////////////////////////////////////////////////////
  210. void CAudioProxy::SetEnvironmentAmount(TAudioEnvironmentID nEnvironmentID, float fValue)
  211. {
  212. Audio::ObjectRequest::SetEnvironmentValue setEnvironment;
  213. setEnvironment.m_environmentId = nEnvironmentID;
  214. setEnvironment.m_value = fValue;
  215. if (HasId())
  216. {
  217. setEnvironment.m_audioObjectId = m_nAudioObjectID;
  218. AZ::Interface<IAudioSystem>::Get()->PushRequest(AZStd::move(setEnvironment));
  219. }
  220. else
  221. {
  222. TryEnqueueRequest(AZStd::move(setEnvironment));
  223. }
  224. }
  225. ///////////////////////////////////////////////////////////////////////////////////////////////////
  226. void CAudioProxy::ResetEnvironments()
  227. {
  228. Audio::ObjectRequest::ResetEnvironments resetEnvironments;
  229. if (HasId())
  230. {
  231. resetEnvironments.m_audioObjectId = m_nAudioObjectID;
  232. AZ::Interface<IAudioSystem>::Get()->PushRequest(AZStd::move(resetEnvironments));
  233. }
  234. else
  235. {
  236. TryEnqueueRequest(AZStd::move(resetEnvironments));
  237. }
  238. }
  239. ///////////////////////////////////////////////////////////////////////////////////////////////////
  240. void CAudioProxy::ResetParameters()
  241. {
  242. Audio::ObjectRequest::ResetParameters resetParameters;
  243. if (HasId())
  244. {
  245. resetParameters.m_audioObjectId = m_nAudioObjectID;
  246. AZ::Interface<IAudioSystem>::Get()->PushRequest(AZStd::move(resetParameters));
  247. }
  248. else
  249. {
  250. TryEnqueueRequest(AZStd::move(resetParameters));
  251. }
  252. }
  253. ///////////////////////////////////////////////////////////////////////////////////////////////////
  254. void CAudioProxy::Release()
  255. {
  256. // If it has ID, push a Release request.
  257. // When the proxy is still waiting for an ID to be assigned,
  258. // set a flag which indicates that after executing all the queued
  259. // events it should be released.
  260. // After calling Release(), the pointer should not be used
  261. // anymore since it's been recycled back to the AudioSystem's pool.
  262. if (HasId())
  263. {
  264. Audio::ObjectRequest::Release releaseObject;
  265. releaseObject.m_audioObjectId = m_nAudioObjectID;
  266. AZ::Interface<IAudioSystem>::Get()->PushRequest(AZStd::move(releaseObject));
  267. }
  268. else if (m_waitingForId)
  269. {
  270. m_releaseAtEndOfQueue = true;
  271. return;
  272. }
  273. Reset();
  274. AZ::Interface<IAudioSystem>::Get()->RecycleAudioProxy(this);
  275. }
  276. ///////////////////////////////////////////////////////////////////////////////////////////////////
  277. void CAudioProxy::ExecuteQueuedRequests()
  278. {
  279. for (auto& requestVariant : m_queuedAudioRequests)
  280. {
  281. // Inject the audio object ID that was assigned, then kick off the requests.
  282. AZStd::visit(
  283. [this](auto&& request)
  284. {
  285. request.m_audioObjectId = m_nAudioObjectID;
  286. },
  287. requestVariant);
  288. }
  289. AZ::Interface<IAudioSystem>::Get()->PushRequests(m_queuedAudioRequests);
  290. m_queuedAudioRequests.clear();
  291. if (m_releaseAtEndOfQueue)
  292. {
  293. Release();
  294. }
  295. }
  296. ///////////////////////////////////////////////////////////////////////////////////////////////////
  297. bool CAudioProxy::HasId() const
  298. {
  299. return (m_nAudioObjectID != INVALID_AUDIO_OBJECT_ID);
  300. }
  301. ///////////////////////////////////////////////////////////////////////////////////////////////////
  302. void CAudioProxy::Reset()
  303. {
  304. m_nAudioObjectID = INVALID_AUDIO_OBJECT_ID;
  305. m_oPosition = {};
  306. m_ownerOverride = nullptr;
  307. m_releaseAtEndOfQueue = false;
  308. m_waitingForId = false;
  309. m_queuedAudioRequests.clear();
  310. }
  311. ///////////////////////////////////////////////////////////////////////////////////////////////////
  312. // Find Functors - Helpers for async queueing
  313. ///////////////////////////////////////////////////////////////////////////////////////////////////
  314. ///////////////////////////////////////////////////////////////////////////////////////////////////
  315. struct FindSetSwitchValue
  316. {
  317. explicit FindSetSwitchValue(const ObjectRequest::SetSwitchValue& request)
  318. : m_audioSwitchId(request.m_switchId)
  319. , m_audioStateId(request.m_stateId)
  320. {
  321. }
  322. bool operator()(AudioRequestVariant& refRequest)
  323. {
  324. bool found = false;
  325. if (auto setSwitchRequest = AZStd::get_if<Audio::ObjectRequest::SetSwitchValue>(&refRequest);
  326. setSwitchRequest != nullptr)
  327. {
  328. if (setSwitchRequest->m_switchId == m_audioSwitchId)
  329. {
  330. // A set command for this switch exists, update the value being set.
  331. found = true;
  332. setSwitchRequest->m_stateId = m_audioStateId;
  333. }
  334. }
  335. return found;
  336. }
  337. private:
  338. TAudioControlID m_audioSwitchId;
  339. TAudioSwitchStateID m_audioStateId;
  340. };
  341. ///////////////////////////////////////////////////////////////////////////////////////////////////
  342. struct FindSetParameterValue
  343. {
  344. explicit FindSetParameterValue(const Audio::ObjectRequest::SetParameterValue& request)
  345. : m_audioParameterId(request.m_parameterId)
  346. , m_audioParameterValue(request.m_value)
  347. {
  348. }
  349. bool operator()(AudioRequestVariant& refRequest)
  350. {
  351. bool found = false;
  352. if (auto setParameterRequest = AZStd::get_if<Audio::ObjectRequest::SetParameterValue>(&refRequest);
  353. setParameterRequest != nullptr)
  354. {
  355. if (setParameterRequest->m_parameterId == m_audioParameterId)
  356. {
  357. // A set command for this parameter exists, update the value being set.
  358. found = true;
  359. setParameterRequest->m_value = m_audioParameterValue;
  360. }
  361. }
  362. return found;
  363. }
  364. private:
  365. TAudioControlID m_audioParameterId;
  366. float m_audioParameterValue;
  367. };
  368. ///////////////////////////////////////////////////////////////////////////////////////////////////
  369. struct FindSetPosition
  370. {
  371. explicit FindSetPosition(const Audio::ObjectRequest::SetPosition& request)
  372. : m_position(request.m_position)
  373. {
  374. }
  375. bool operator()(AudioRequestVariant& refRequest)
  376. {
  377. bool found = false;
  378. if (auto setPositionRequest = AZStd::get_if<Audio::ObjectRequest::SetPosition>(&refRequest);
  379. setPositionRequest != nullptr)
  380. {
  381. // A set position request already exists, update the position.
  382. found = true;
  383. setPositionRequest->m_position = m_position;
  384. }
  385. if (auto setPositionRequest = AZStd::get_if<Audio::ObjectRequest::SetMultiplePositions>(&refRequest);
  386. setPositionRequest != nullptr)
  387. {
  388. // A multi-position request exists, setting a single position can't overwrite it.
  389. found = true;
  390. }
  391. return found;
  392. }
  393. private:
  394. const SATLWorldPosition& m_position;
  395. };
  396. ///////////////////////////////////////////////////////////////////////////////////////////////////
  397. struct FindSetMultiplePositions
  398. {
  399. explicit FindSetMultiplePositions(const Audio::ObjectRequest::SetMultiplePositions& request)
  400. : m_params(request.m_params)
  401. {
  402. }
  403. bool operator()(AudioRequestVariant& refRequest)
  404. {
  405. bool found = false;
  406. if (auto setPositionRequest = AZStd::get_if<Audio::ObjectRequest::SetPosition>(&refRequest);
  407. setPositionRequest != nullptr)
  408. {
  409. // A Multi-Position request will replace an existing single position request.
  410. Audio::ObjectRequest::SetMultiplePositions setMultiRequest;
  411. setMultiRequest.m_audioObjectId = setPositionRequest->m_audioObjectId;
  412. setMultiRequest.m_status = setPositionRequest->m_status;
  413. refRequest = AZStd::move(setMultiRequest);
  414. }
  415. if (auto setPositionRequest = AZStd::get_if<Audio::ObjectRequest::SetMultiplePositions>(&refRequest);
  416. setPositionRequest != nullptr)
  417. {
  418. // A MultiPosition request exists already (or was transformed into one), set the position data.
  419. setPositionRequest->m_params = AZStd::move(m_params);
  420. found = true;
  421. }
  422. return found;
  423. }
  424. private:
  425. const MultiPositionParams& m_params;
  426. };
  427. ///////////////////////////////////////////////////////////////////////////////////////////////////
  428. struct FindSetEnvironmentValue
  429. {
  430. explicit FindSetEnvironmentValue(const Audio::ObjectRequest::SetEnvironmentValue& request)
  431. : m_audioEnvironmentId(request.m_environmentId)
  432. , m_audioEnvironmentValue(request.m_value)
  433. {
  434. }
  435. bool operator()(AudioRequestVariant& refRequest)
  436. {
  437. bool found = false;
  438. if (auto setEnvironmentRequest = AZStd::get_if<Audio::ObjectRequest::SetEnvironmentValue>(&refRequest);
  439. setEnvironmentRequest != nullptr)
  440. {
  441. if (setEnvironmentRequest->m_environmentId == m_audioEnvironmentId)
  442. {
  443. // Update the value
  444. setEnvironmentRequest->m_value = m_audioEnvironmentValue;
  445. found = true;
  446. }
  447. }
  448. return found;
  449. }
  450. private:
  451. TAudioEnvironmentID m_audioEnvironmentId;
  452. float m_audioEnvironmentValue;
  453. };
  454. ///////////////////////////////////////////////////////////////////////////////////////////////////
  455. template<typename T>
  456. struct FindRequestType
  457. {
  458. FindRequestType() = default;
  459. bool operator()(const AudioRequestVariant& refRequest)
  460. {
  461. if (auto request = AZStd::get_if<T>(&refRequest); request != nullptr)
  462. {
  463. return true;
  464. }
  465. return false;
  466. }
  467. };
  468. ///////////////////////////////////////////////////////////////////////////////////////////////////
  469. void CAudioProxy::TryEnqueueRequest(AudioRequestVariant&& requestVariant)
  470. {
  471. bool addFront = false;
  472. bool shouldAdd = AZStd::visit(
  473. [this, &addFront](auto&& request) -> bool
  474. {
  475. using RequestType = AZStd::decay_t<decltype(request)>;
  476. if constexpr (AZStd::is_same_v<RequestType, Audio::ObjectRequest::ExecuteTrigger>
  477. || AZStd::is_same_v<RequestType, Audio::ObjectRequest::StopTrigger>
  478. || AZStd::is_same_v<RequestType, Audio::ObjectRequest::ExecuteSourceTrigger>)
  479. {
  480. // Always add these types of requests!
  481. return true;
  482. }
  483. else if constexpr (AZStd::is_same_v<RequestType, Audio::ObjectRequest::SetPosition>)
  484. {
  485. // Position should be set in front of queue, before other things happen.
  486. addFront = true;
  487. auto findIter = AZStd::find_if(m_queuedAudioRequests.begin(), m_queuedAudioRequests.end(), FindSetPosition(request));
  488. return (findIter == m_queuedAudioRequests.end());
  489. }
  490. else if constexpr (AZStd::is_same_v<RequestType, Audio::ObjectRequest::SetParameterValue>)
  491. {
  492. auto findIter =
  493. AZStd::find_if(m_queuedAudioRequests.begin(), m_queuedAudioRequests.end(), FindSetParameterValue(request));
  494. return (findIter == m_queuedAudioRequests.end());
  495. }
  496. else if constexpr (AZStd::is_same_v<RequestType, Audio::ObjectRequest::SetSwitchValue>)
  497. {
  498. auto findIter = AZStd::find_if(m_queuedAudioRequests.begin(), m_queuedAudioRequests.end(), FindSetSwitchValue(request));
  499. return (findIter == m_queuedAudioRequests.end());
  500. }
  501. else if constexpr (AZStd::is_same_v<RequestType, Audio::ObjectRequest::SetEnvironmentValue>)
  502. {
  503. auto findIter =
  504. AZStd::find_if(m_queuedAudioRequests.begin(), m_queuedAudioRequests.end(), FindSetEnvironmentValue(request));
  505. return (findIter == m_queuedAudioRequests.end());
  506. }
  507. else if constexpr (AZStd::is_same_v<RequestType, Audio::ObjectRequest::StopAllTriggers>
  508. || AZStd::is_same_v<RequestType, Audio::ObjectRequest::ResetParameters>
  509. || AZStd::is_same_v<RequestType, Audio::ObjectRequest::ResetEnvironments>
  510. || AZStd::is_same_v<RequestType, Audio::ObjectRequest::Release>)
  511. {
  512. // Generic find
  513. auto findIter = AZStd::find_if(m_queuedAudioRequests.begin(), m_queuedAudioRequests.end(), FindRequestType<RequestType>());
  514. return (findIter == m_queuedAudioRequests.end());
  515. }
  516. else if constexpr (AZStd::is_same_v<RequestType, Audio::ObjectRequest::SetMultiplePositions>)
  517. {
  518. // Position should be set in front of queue, before other things happen.
  519. addFront = true;
  520. auto findIter = AZStd::find_if(
  521. m_queuedAudioRequests.begin(), m_queuedAudioRequests.end(), FindSetMultiplePositions(request));
  522. return (findIter == m_queuedAudioRequests.end());
  523. }
  524. else
  525. {
  526. // Not implemented yet!
  527. // e.g. Audio::ObjectRequest::PrepareTrigger, Audio::ObjectRequest::UnprepareTrigger
  528. return false;
  529. }
  530. },
  531. requestVariant);
  532. if (shouldAdd)
  533. {
  534. if (addFront)
  535. {
  536. m_queuedAudioRequests.push_front(AZStd::move(requestVariant));
  537. }
  538. else
  539. {
  540. m_queuedAudioRequests.push_back(AZStd::move(requestVariant));
  541. }
  542. }
  543. }
  544. } // namespace Audio