IAudioSystem.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  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. #pragma once
  9. #include <AzCore/Component/Component.h>
  10. #include <AzCore/EBus/EBus.h>
  11. #include <AzCore/Interface/Interface.h>
  12. #include <AzCore/Math/Crc.h>
  13. #include <AzCore/Math/Vector3.h>
  14. #include <AzCore/std/containers/variant.h>
  15. #include <AzCore/std/parallel/mutex.h>
  16. #include <IAudioInterfacesCommonData.h>
  17. // External forward declarations.
  18. struct SSystemInitParams;
  19. namespace Audio
  20. {
  21. enum EATLDataScope : TATLEnumFlagsType
  22. {
  23. eADS_NONE = 0,
  24. eADS_GLOBAL = 1,
  25. eADS_LEVEL_SPECIFIC = 2,
  26. eADS_ALL = 3,
  27. };
  28. enum EAudioControlType : TATLEnumFlagsType
  29. {
  30. eACT_NONE = 0,
  31. eACT_AUDIO_OBJECT = 1,
  32. eACT_TRIGGER = 2,
  33. eACT_RTPC = 3,
  34. eACT_SWITCH = 4,
  35. eACT_SWITCH_STATE = 5,
  36. eACT_PRELOAD = 6,
  37. eACT_ENVIRONMENT = 7,
  38. };
  39. ///////////////////////////////////////////////////////////////////////////////////////////////////
  40. template <typename T>
  41. AZ_FORCE_INLINE T AudioStringToID(const char* const source)
  42. {
  43. return static_cast<T>(AZ::Crc32(source));
  44. }
  45. ///////////////////////////////////////////////////////////////////////////////////////////////////
  46. #define AUDIO_REQUEST_TYPE(NAMESPACE, CLASS, GUID) \
  47. AZ_RTTI(Audio::NAMESPACE::CLASS, GUID, Audio::AudioRequestBase); \
  48. using CallbackType = AZStd::function<void(const CLASS&)>; \
  49. CallbackType m_callback;
  50. class AudioRequestBase
  51. {
  52. public:
  53. AZ_RTTI(Audio::AudioRequestBase, "{1D31EE4F-8D7F-41FD-87C0-C9BB76555570}");
  54. AudioRequestBase() = default;
  55. virtual ~AudioRequestBase() = default;
  56. AZ_DISABLE_COPY(AudioRequestBase);
  57. // The audio object to operate on, if applicable.
  58. // For audio requests under the Audio::Object namespace, this is applicable.
  59. // If the audio object id is invalid, the request will operate on the global audio object.
  60. TAudioObjectID m_audioObjectId{ INVALID_AUDIO_OBJECT_ID };
  61. EAudioRequestStatus m_status{ EAudioRequestStatus::None };
  62. AZ::u32 m_flags{ 0 };
  63. };
  64. namespace SystemRequest
  65. {
  66. struct Initialize
  67. : public AudioRequestBase
  68. {
  69. AUDIO_REQUEST_TYPE(SystemRequest, Initialize, "{8C777214-109E-4C44-A0F5-FCECF601C1E6}");
  70. };
  71. struct Shutdown
  72. : public AudioRequestBase
  73. {
  74. AUDIO_REQUEST_TYPE(SystemRequest, Shutdown, "{33F13AAE-3E08-4C9A-939B-2D111403DD76}");
  75. };
  76. struct ReserveObject
  77. : public AudioRequestBase
  78. {
  79. AUDIO_REQUEST_TYPE(SystemRequest, ReserveObject, "{A0FA000F-EBE1-4DCB-ADA8-9C05B27D71E9}");
  80. TAudioObjectID m_objectId{ INVALID_AUDIO_OBJECT_ID }; // this will receive the new id
  81. AZStd::string m_objectName;
  82. };
  83. struct CreateSource
  84. : public AudioRequestBase
  85. {
  86. AUDIO_REQUEST_TYPE(SystemRequest, CreateSource, "{0EE11CCC-9343-4C2B-BB17-191AA673C674}");
  87. CreateSource(const SAudioInputConfig& config)
  88. : m_sourceConfig{ config }
  89. {
  90. }
  91. SAudioInputConfig m_sourceConfig{};
  92. };
  93. struct DestroySource
  94. : public AudioRequestBase
  95. {
  96. AUDIO_REQUEST_TYPE(SystemRequest, DestroySource, "{14537418-E888-4078-921D-BD7D24A65269}");
  97. DestroySource(TAudioSourceId sourceId)
  98. : m_sourceId{ sourceId }
  99. {
  100. }
  101. TAudioSourceId m_sourceId{ INVALID_AUDIO_SOURCE_ID };
  102. };
  103. struct LoadControls
  104. : public AudioRequestBase
  105. {
  106. AUDIO_REQUEST_TYPE(SystemRequest, LoadControls, "{C47AC196-176B-42F2-9ECE-5D5FFF06BAAB}");
  107. AZStd::string m_controlsPath;
  108. EATLDataScope m_scope{ eADS_NONE };
  109. };
  110. struct UnloadControls
  111. : public AudioRequestBase
  112. {
  113. AUDIO_REQUEST_TYPE(SystemRequest, UnloadControls, "{1AAAFBF5-B5A1-4BF0-94A4-58CA2726F9BF}");
  114. EATLDataScope m_scope{ eADS_NONE };
  115. };
  116. struct LoadBank
  117. : public AudioRequestBase
  118. {
  119. AUDIO_REQUEST_TYPE(SystemRequest, LoadBank, "{12A333E0-1BFC-4A96-8FF9-51A677150268}");
  120. TAudioPreloadRequestID m_preloadRequestId{ INVALID_AUDIO_PRELOAD_REQUEST_ID };
  121. bool m_asyncLoad{ true };
  122. bool m_autoLoadOnly{ false };
  123. };
  124. struct UnloadBank
  125. : public AudioRequestBase
  126. {
  127. AUDIO_REQUEST_TYPE(SystemRequest, UnloadBank, "{974C6644-000C-4710-8EB5-35FC1CD2A7CE}");
  128. TAudioPreloadRequestID m_preloadRequestId{ INVALID_AUDIO_PRELOAD_REQUEST_ID };
  129. };
  130. struct UnloadBanksByScope
  131. : public AudioRequestBase
  132. {
  133. AUDIO_REQUEST_TYPE(SystemRequest, UnloadBanksByScope, "{15F9FF1D-3444-4317-AA9A-F27C369C5BBD}");
  134. EATLDataScope m_scope{ eADS_NONE };
  135. };
  136. struct ReloadAll
  137. : public AudioRequestBase
  138. {
  139. AUDIO_REQUEST_TYPE(SystemRequest, ReloadAll, "{318F4F8E-6733-43C3-BC2B-D6BA588854D5}");
  140. AZStd::string m_controlsPath;
  141. AZStd::string m_levelName;
  142. TAudioPreloadRequestID m_levelPreloadId{ INVALID_AUDIO_PRELOAD_REQUEST_ID };
  143. };
  144. struct LoseFocus
  145. : public AudioRequestBase
  146. {
  147. AUDIO_REQUEST_TYPE(SystemRequest, LoseFocus, "{8F316485-BDC4-43F2-9333-E85B107C1321}");
  148. };
  149. struct GetFocus
  150. : public AudioRequestBase
  151. {
  152. AUDIO_REQUEST_TYPE(SystemRequest, GetFocus, "{ABBB7450-767B-4B46-825C-19970C1A15DE}");
  153. };
  154. struct MuteAll
  155. : public AudioRequestBase
  156. {
  157. AUDIO_REQUEST_TYPE(SystemRequest, MuteAll, "{9D3888DC-789D-4570-AB2E-85EB21509AA5}");
  158. };
  159. struct UnmuteAll
  160. : public AudioRequestBase
  161. {
  162. AUDIO_REQUEST_TYPE(SystemRequest, UnmuteAll, "{7A3AEF49-3152-44F5-AF51-A5D050611161}");
  163. };
  164. struct StopAllAudio
  165. : public AudioRequestBase
  166. {
  167. AUDIO_REQUEST_TYPE(SystemRequest, StopAllAudio, "{5D07B532-E4F5-4D37-826F-AAA26A53DFE7}");
  168. };
  169. struct DrawDebug
  170. : public AudioRequestBase
  171. {
  172. AUDIO_REQUEST_TYPE(SystemRequest, DrawDebug, "{D85EDE10-382C-4748-B888-C442008D6401}");
  173. };
  174. struct ChangeLanguage
  175. : public AudioRequestBase
  176. {
  177. AUDIO_REQUEST_TYPE(SystemRequest, ChangeLanguage, "{7AEEEF69-9685-4473-9EDB-ADC5D467998C}");
  178. };
  179. struct SetPanningMode
  180. : public AudioRequestBase
  181. {
  182. AUDIO_REQUEST_TYPE(SystemRequest, SetPanningMode, "{FEB8075C-4DE1-4117-AE61-E196800BA222}");
  183. PanningMode m_panningMode{ PanningMode::Speakers };
  184. };
  185. } // namespace System
  186. namespace ObjectRequest
  187. {
  188. struct ExecuteTrigger
  189. : public AudioRequestBase
  190. {
  191. AUDIO_REQUEST_TYPE(ObjectRequest, ExecuteTrigger, "{E801D6A2-EB87-4733-AC8C-AEEE91E47847}");
  192. TAudioControlID m_triggerId{ INVALID_AUDIO_CONTROL_ID };
  193. void* m_owner{ nullptr };
  194. };
  195. struct ExecuteSourceTrigger : public AudioRequestBase
  196. {
  197. AUDIO_REQUEST_TYPE(ObjectRequest, ExecuteSourceTrigger, "{FDA0D264-F66C-40A4-BD07-28986D2B8882}");
  198. TAudioControlID m_triggerId{ INVALID_AUDIO_CONTROL_ID };
  199. SAudioSourceInfo m_sourceInfo{};
  200. void* m_owner{ nullptr };
  201. };
  202. struct PrepareTrigger
  203. : public AudioRequestBase
  204. {
  205. AUDIO_REQUEST_TYPE(ObjectRequest, PrepareTrigger, "{33B13ED8-A2DC-407D-8C5B-CEC2444822F5}");
  206. TAudioControlID m_triggerId{ INVALID_AUDIO_CONTROL_ID };
  207. };
  208. struct UnprepareTrigger
  209. : public AudioRequestBase
  210. {
  211. AUDIO_REQUEST_TYPE(ObjectRequest, UnprepareTrigger, "{358F485D-25F2-4EBF-AA50-AE6972221535}");
  212. TAudioControlID m_triggerId{ INVALID_AUDIO_CONTROL_ID };
  213. };
  214. struct StopTrigger
  215. : public AudioRequestBase
  216. {
  217. AUDIO_REQUEST_TYPE(ObjectRequest, StopTrigger, "{91CCADDD-03E0-47F6-BB17-33576D793175}");
  218. TAudioControlID m_triggerId{ INVALID_AUDIO_CONTROL_ID };
  219. void* m_owner{ nullptr };
  220. };
  221. struct StopAllTriggers
  222. : public AudioRequestBase
  223. {
  224. AUDIO_REQUEST_TYPE(ObjectRequest, StopAllTriggers, "{7A222303-A170-4805-9A15-B82B26EFFBF8}");
  225. bool m_filterByOwner{ false };
  226. void* m_owner{ nullptr };
  227. };
  228. struct SetPosition
  229. : public AudioRequestBase
  230. {
  231. AUDIO_REQUEST_TYPE(ObjectRequest, SetPosition, "{A7AAA8D1-75A7-4F94-A3ED-3D5A80429569}");
  232. SATLWorldPosition m_position{};
  233. };
  234. struct SetParameterValue
  235. : public AudioRequestBase
  236. {
  237. AUDIO_REQUEST_TYPE(ObjectRequest, SetParameterValue, "{10D950F1-2860-4A22-B34A-CBE9586D4555}");
  238. TAudioControlID m_parameterId{ INVALID_AUDIO_CONTROL_ID };
  239. float m_value{ 0.f };
  240. };
  241. struct SetSwitchValue
  242. : public AudioRequestBase
  243. {
  244. AUDIO_REQUEST_TYPE(ObjectRequest, SetSwitchValue, "{86A43DD6-8BC9-4446-970C-4078BDB46E0B}");
  245. TAudioControlID m_switchId{ INVALID_AUDIO_CONTROL_ID };
  246. TAudioSwitchStateID m_stateId{ INVALID_AUDIO_SWITCH_STATE_ID };
  247. };
  248. struct SetEnvironmentValue
  249. : public AudioRequestBase
  250. {
  251. AUDIO_REQUEST_TYPE(ObjectRequest, SetEnvironmentValue, "{E9BAA202-5CBF-4313-930B-7CAB81CB7FFF}");
  252. TAudioEnvironmentID m_environmentId{ INVALID_AUDIO_ENVIRONMENT_ID };
  253. float m_value{ 0.f };
  254. };
  255. struct ResetEnvironments
  256. : public AudioRequestBase
  257. {
  258. AUDIO_REQUEST_TYPE(ObjectRequest, ResetEnvironments, "{5B92F5C5-DD55-46D9-9666-57F30D0E8CA3}");
  259. };
  260. struct ResetParameters
  261. : public AudioRequestBase
  262. {
  263. AUDIO_REQUEST_TYPE(ObjectRequest, ResetParameters, "{C94D1F26-9331-47B4-8A81-61C3A3526664}");
  264. };
  265. struct Release
  266. : public AudioRequestBase
  267. {
  268. AUDIO_REQUEST_TYPE(ObjectRequest, Release, "{8C7995B6-AD5C-45AB-AEEE-2AA823843FBC}");
  269. };
  270. struct SetMultiplePositions
  271. : public AudioRequestBase
  272. {
  273. AUDIO_REQUEST_TYPE(ObjectRequest, SetMultiplePositions, "{228E557D-C8FE-457F-8983-7E88870AF89C}");
  274. MultiPositionParams m_params{};
  275. };
  276. } // namespace Object
  277. namespace CallbackRequest
  278. {
  279. struct ReportFinishedEvent
  280. : public AudioRequestBase
  281. {
  282. AUDIO_REQUEST_TYPE(CallbackRequest, ReportFinishedEvent, "{4BBB0A44-AE52-4734-B832-9E9A20C447EF}");
  283. TAudioEventID m_eventId{ INVALID_AUDIO_EVENT_ID };
  284. };
  285. } // namespace Callback
  286. namespace ListenerRequest
  287. {
  288. struct SetWorldTransform
  289. : public AudioRequestBase
  290. {
  291. AUDIO_REQUEST_TYPE(ListenerRequest, SetWorldTransform, "{30B70579-127A-476F-9651-0BD3408DA888}");
  292. SATLWorldPosition m_transform{};
  293. };
  294. } // namespace Listener
  295. using AudioRequestVariant = AZStd::variant<
  296. // System Requests
  297. Audio::SystemRequest::Initialize,
  298. Audio::SystemRequest::Shutdown,
  299. Audio::SystemRequest::ReserveObject,
  300. Audio::SystemRequest::CreateSource,
  301. Audio::SystemRequest::DestroySource,
  302. Audio::SystemRequest::LoadControls,
  303. Audio::SystemRequest::UnloadControls,
  304. Audio::SystemRequest::LoadBank,
  305. Audio::SystemRequest::UnloadBank,
  306. Audio::SystemRequest::UnloadBanksByScope,
  307. Audio::SystemRequest::ReloadAll,
  308. Audio::SystemRequest::LoseFocus,
  309. Audio::SystemRequest::GetFocus,
  310. Audio::SystemRequest::MuteAll,
  311. Audio::SystemRequest::UnmuteAll,
  312. Audio::SystemRequest::StopAllAudio,
  313. Audio::SystemRequest::DrawDebug,
  314. Audio::SystemRequest::ChangeLanguage,
  315. Audio::SystemRequest::SetPanningMode,
  316. // Object Requests
  317. Audio::ObjectRequest::ExecuteTrigger,
  318. Audio::ObjectRequest::ExecuteSourceTrigger,
  319. Audio::ObjectRequest::PrepareTrigger,
  320. Audio::ObjectRequest::UnprepareTrigger,
  321. Audio::ObjectRequest::StopTrigger,
  322. Audio::ObjectRequest::StopAllTriggers,
  323. Audio::ObjectRequest::SetPosition,
  324. Audio::ObjectRequest::SetParameterValue,
  325. Audio::ObjectRequest::SetSwitchValue,
  326. Audio::ObjectRequest::SetEnvironmentValue,
  327. Audio::ObjectRequest::ResetParameters,
  328. Audio::ObjectRequest::ResetEnvironments,
  329. Audio::ObjectRequest::Release,
  330. Audio::ObjectRequest::SetMultiplePositions,
  331. // Callback Requests
  332. Audio::CallbackRequest::ReportFinishedEvent,
  333. // Listener Requests
  334. Audio::ListenerRequest::SetWorldTransform>;
  335. using AudioRequestsQueue = AZStd::deque<AudioRequestVariant, AZ::AZStdAlloc<AZ::SystemAllocator>>;
  336. ///////////////////////////////////////////////////////////////////////////////////////////////////
  337. struct IAudioProxy
  338. {
  339. virtual ~IAudioProxy() = default;
  340. virtual void Initialize(const char* sObjectName, void* ownerOverride = nullptr, bool bInitAsync = true) = 0;
  341. virtual void Release() = 0;
  342. virtual void ExecuteTrigger(TAudioControlID nTriggerID) = 0;
  343. virtual void ExecuteSourceTrigger(TAudioControlID nTriggerID, const SAudioSourceInfo& rSourceInfo) = 0;
  344. virtual void StopAllTriggers() = 0;
  345. virtual void StopTrigger(TAudioControlID nTriggerID) = 0;
  346. virtual void SetSwitchState(TAudioControlID nSwitchID, TAudioSwitchStateID nStateID) = 0;
  347. virtual void SetRtpcValue(TAudioControlID nRtpcID, float fValue) = 0;
  348. virtual void SetObstructionCalcType(ObstructionType eObstructionType) = 0;
  349. virtual void SetPosition(const SATLWorldPosition& rPosition) = 0;
  350. virtual void SetPosition(const AZ::Vector3& rPosition) = 0;
  351. virtual void SetMultiplePositions(const MultiPositionParams& params) = 0;
  352. virtual void SetEnvironmentAmount(TAudioEnvironmentID nEnvironmentID, float fAmount) = 0;
  353. virtual void ResetEnvironments() = 0;
  354. virtual void ResetParameters() = 0;
  355. virtual TAudioObjectID GetAudioObjectID() const = 0;
  356. };
  357. ///////////////////////////////////////////////////////////////////////////////////////////////////
  358. class AudioPreloadNotifications
  359. : public AZ::EBusTraits
  360. {
  361. public:
  362. virtual ~AudioPreloadNotifications() = default;
  363. ///////////////////////////////////////////////////////////////////////////////////////////////
  364. // EBusTraits - PreloadID Address, Multiple Handler
  365. static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
  366. static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple;
  367. using BusIdType = TAudioPreloadRequestID;
  368. using MutexType = AZStd::recursive_mutex;
  369. ///////////////////////////////////////////////////////////////////////////////////////////////
  370. virtual void OnAudioPreloadCached() = 0;
  371. virtual void OnAudioPreloadUncached() = 0;
  372. };
  373. using AudioPreloadNotificationBus = AZ::EBus<AudioPreloadNotifications>;
  374. ///////////////////////////////////////////////////////////////////////////////////////////////////
  375. class IAudioSystem
  376. {
  377. // This interface is registered with AZ::Interface<>
  378. public:
  379. AZ_RTTI(IAudioSystem, "{4AF3417B-C264-4970-96C5-EBB888EA922D}");
  380. virtual ~IAudioSystem() = default;
  381. virtual bool Initialize() = 0;
  382. virtual void Release() = 0;
  383. virtual void ExternalUpdate() = 0;
  384. virtual void PushRequest(AudioRequestVariant&& request) = 0;
  385. virtual void PushRequests(AudioRequestsQueue& requests) = 0;
  386. virtual void PushRequestBlocking(AudioRequestVariant&& request) = 0;
  387. virtual void PushCallback(AudioRequestVariant&& callback) = 0;
  388. virtual TAudioControlID GetAudioTriggerID(const char* sAudioTriggerName) const = 0;
  389. virtual TAudioControlID GetAudioRtpcID(const char* sAudioRtpcName) const = 0;
  390. virtual TAudioControlID GetAudioSwitchID(const char* sAudioSwitchName) const = 0;
  391. virtual TAudioSwitchStateID GetAudioSwitchStateID(TAudioControlID nSwitchID, const char* sAudioSwitchStateName) const = 0;
  392. virtual TAudioPreloadRequestID GetAudioPreloadRequestID(const char* sAudioPreloadRequestName) const = 0;
  393. virtual TAudioEnvironmentID GetAudioEnvironmentID(const char* sAudioEnvironmentName) const = 0;
  394. virtual bool ReserveAudioListenerID(TAudioObjectID& rAudioObjectID) = 0;
  395. virtual bool ReleaseAudioListenerID(TAudioObjectID nAudioObjectID) = 0;
  396. virtual bool SetAudioListenerOverrideID(TAudioObjectID nAudioObjectID) = 0;
  397. virtual const char* GetControlsPath() const = 0;
  398. virtual void UpdateControlsPath() = 0;
  399. virtual void RefreshAudioSystem(const char* levelName) = 0;
  400. virtual IAudioProxy* GetAudioProxy() = 0;
  401. virtual void RecycleAudioProxy(IAudioProxy* pIAudioProxy) = 0;
  402. virtual TAudioSourceId CreateAudioSource(const SAudioInputConfig& sourceConfig) = 0;
  403. virtual void DestroyAudioSource(TAudioSourceId sourceId) = 0;
  404. };
  405. ///////////////////////////////////////////////////////////////////////////////////////////////////
  406. class AudioTriggerNotifications
  407. : public AZ::EBusTraits
  408. {
  409. public:
  410. virtual ~AudioTriggerNotifications() = default;
  411. ///////////////////////////////////////////////////////////////////////////////////////////////
  412. // EBusTraits - Address by ID, Multiple Handler, Recursive Mutex, Queued
  413. static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
  414. static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple;
  415. static const bool EnableEventQueue = true;
  416. using MutexType = AZStd::recursive_mutex;
  417. using BusIdType = TriggerNotificationIdType;
  418. ///////////////////////////////////////////////////////////////////////////////////////////////
  419. // Give default definitions, because handlers don't need to implement all these functions...
  420. virtual void ReportDurationInfo(
  421. [[maybe_unused]] TAudioControlID triggerId,
  422. [[maybe_unused]] TAudioEventID eventId,
  423. [[maybe_unused]] float duration,
  424. [[maybe_unused]] float estimatedDuration) {}
  425. virtual void ReportTriggerStarted([[maybe_unused]] TAudioControlID triggerId) {}
  426. virtual void ReportTriggerFinished([[maybe_unused]] TAudioControlID triggerId) {}
  427. };
  428. using AudioTriggerNotificationBus = AZ::EBus<AudioTriggerNotifications>;
  429. ///////////////////////////////////////////////////////////////////////////////////////////////////
  430. class AudioStreamingRequests
  431. : public AZ::EBusTraits
  432. {
  433. public:
  434. virtual ~AudioStreamingRequests() = default;
  435. ///////////////////////////////////////////////////////////////////////////////////////////////
  436. // EBusTraits overrides - Single Bus, Single Handler
  437. static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
  438. static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
  439. using BusIdType = TAudioSourceId;
  440. using MutexType = AZStd::recursive_mutex;
  441. ///////////////////////////////////////////////////////////////////////////////////////////////
  442. ///////////////////////////////////////////////////////////////////////////////////////////////
  443. // <title ReadStreamingInput>
  444. // Summary:
  445. // Load streaming input into the ATL-specific audio input
  446. // Arguments:
  447. // data - Buffer of data to load into the input device's internal buffer
  448. ///////////////////////////////////////////////////////////////////////////////////////////////
  449. virtual AZStd::size_t ReadStreamingInput(const AudioStreamData& data) = 0;
  450. ///////////////////////////////////////////////////////////////////////////////////////////////
  451. // <title ReadStreamingMultiTrackInput>
  452. // Summary:
  453. // Load streaming multi-track input into the ATL-specific audio input
  454. // Arguments:
  455. // data - Buffers of multi-track data to load into the input device's internal buffer
  456. // Return value:
  457. // The number of frames loaded into the internal buffer
  458. ///////////////////////////////////////////////////////////////////////////////////////////////
  459. virtual AZStd::size_t ReadStreamingMultiTrackInput(AudioStreamMultiTrackData& data) = 0;
  460. };
  461. using AudioStreamingRequestBus = AZ::EBus<AudioStreamingRequests>;
  462. ///////////////////////////////////////////////////////////////////////////////////////////////////
  463. namespace Gem
  464. {
  465. ///////////////////////////////////////////////////////////////////////////////////////////////
  466. // Audio initialization loads resources that may not be ready until after
  467. // component application (and AP) is fully up, so it is delayed until CSystem::Init.
  468. // Similarly, release is called in CSystem::ShutDown.
  469. class SystemBusInterface
  470. : public AZ::EBusTraits
  471. {
  472. public:
  473. virtual ~SystemBusInterface() = default;
  474. ///////////////////////////////////////////////////////////////////////////////////////////
  475. // EBusTraits overrides
  476. static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
  477. static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
  478. ///////////////////////////////////////////////////////////////////////////////////////////
  479. // Interface methods
  480. virtual bool Initialize() = 0;
  481. virtual void Release() = 0;
  482. ///////////////////////////////////////////////////////////////////////////////////////////
  483. };
  484. // SystemRequestBus is used with AudioSystem Gem
  485. class SystemRequests : public SystemBusInterface {};
  486. using SystemRequestBus = AZ::EBus<SystemRequests>;
  487. // EngineRequestBus is used with AudioEngine* Gem
  488. class EngineRequests : public SystemBusInterface {};
  489. using EngineRequestBus = AZ::EBus<EngineRequests>;
  490. } // namespace Gem
  491. } // namespace Audio