IAudioSystemImplementation.h 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514
  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 <ATLEntityData.h>
  10. #include <IAudioInterfacesCommonData.h>
  11. #include <AzCore/EBus/EBus.h>
  12. #include <AzCore/XML/rapidxml.h>
  13. namespace Audio
  14. {
  15. ///////////////////////////////////////////////////////////////////////////////////////////////////
  16. //! Notifications about the audio system for it and others to respond to.
  17. //! These notifications are sent from various places in the code for global events like gaining
  18. //! and losing application focus, mute and unmute, etc.
  19. class AudioSystemImplementationNotifications
  20. : public AZ::EBusTraits
  21. {
  22. public:
  23. virtual ~AudioSystemImplementationNotifications() = default;
  24. ///////////////////////////////////////////////////////////////////////////////////////////////
  25. // EBusTraits overrides - Single Bus, Multiple Handlers
  26. static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
  27. static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple;
  28. ///////////////////////////////////////////////////////////////////////////////////////////////
  29. ///////////////////////////////////////////////////////////////////////////////////////////////
  30. //! This method is called every time the main Game (or Editor) application loses focus.
  31. virtual void OnAudioSystemLoseFocus() = 0;
  32. ///////////////////////////////////////////////////////////////////////////////////////////////
  33. //! This method is called every time the main Game (or Editor) application receives focus.
  34. virtual void OnAudioSystemGetFocus() = 0;
  35. ///////////////////////////////////////////////////////////////////////////////////////////////
  36. //! This method is called when the audio output has been muted.
  37. //! After this call there should be no audio coming from the audio middleware.
  38. virtual void OnAudioSystemMuteAll() = 0;
  39. ///////////////////////////////////////////////////////////////////////////////////////////////
  40. //! This method is called when the audio output has been unmuted.
  41. virtual void OnAudioSystemUnmuteAll() = 0;
  42. ///////////////////////////////////////////////////////////////////////////////////////////////
  43. //! This method is called when user initiates a reload/refresh of all the audio data.
  44. virtual void OnAudioSystemRefresh() = 0;
  45. };
  46. using AudioSystemImplementationNotificationBus = AZ::EBus<AudioSystemImplementationNotifications>;
  47. ///////////////////////////////////////////////////////////////////////////////////////////////////
  48. //! Requests interface for audio middleware implementations.
  49. //! This is the main interface for interacting with an audio middleware implementation, creating
  50. //! and destroying objects, event handling, parameter setting, etc.
  51. class AudioSystemImplementationRequests
  52. : public AZ::EBusTraits
  53. {
  54. public:
  55. virtual ~AudioSystemImplementationRequests() = default;
  56. ///////////////////////////////////////////////////////////////////////////////////////////////
  57. // EBusTraits overrides - Single Bus, Single Handler
  58. static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
  59. static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single;
  60. ///////////////////////////////////////////////////////////////////////////////////////////////
  61. ///////////////////////////////////////////////////////////////////////////////////////////////
  62. //! Update the audio middleware implementation.
  63. //! Updates all of the internal sub-systems that require regular updates, and pumps the audio
  64. //! middleware api.
  65. //! @param updateIntervalMS Time since the last call to Update in milliseconds.
  66. virtual void Update(float updateIntervalMS) = 0;
  67. ///////////////////////////////////////////////////////////////////////////////////////////////
  68. //! Initialize all internal components of the audio middleware implementation.
  69. //! @return Success if the initialization was successful, Failure otherwise.
  70. virtual EAudioRequestStatus Initialize() = 0;
  71. ///////////////////////////////////////////////////////////////////////////////////////////////
  72. //! Shuts down all of the internal components of the audio middleware implementation.
  73. //! After calling ShutDown the system can still be brought back up by calling Initialize.
  74. //! @return Success if the shutdown was successful, Failure otherwise.
  75. virtual EAudioRequestStatus ShutDown() = 0;
  76. ///////////////////////////////////////////////////////////////////////////////////////////////
  77. //! Frees all of the resources used by the audio middleware implementation and destroys it.
  78. //! This action is not reversible.
  79. //! @return Success if the action was successful, Failure otherwise.
  80. virtual EAudioRequestStatus Release() = 0;
  81. ///////////////////////////////////////////////////////////////////////////////////////////////
  82. //! Stops all currently playing sounds.
  83. //! Has no effect on anything triggered after this method is called.
  84. //! @return Success if the action was successful, Failure otherwise.
  85. virtual EAudioRequestStatus StopAllSounds() = 0;
  86. ///////////////////////////////////////////////////////////////////////////////////////////////
  87. //! Register an audio object with the audio middleware.
  88. //! An object needs to be registered in order to set position, execute triggers on it,
  89. //! or set parameters and switches.
  90. //! @prarm objectData Implementation-specific audio object data.
  91. //! @param objectName The name of the audio object to be shown in debug info.
  92. //! @return Success if the object was registered, Failure otherwise.
  93. virtual EAudioRequestStatus RegisterAudioObject(IATLAudioObjectData* objectData, const char* objectName = nullptr) = 0;
  94. ///////////////////////////////////////////////////////////////////////////////////////////////
  95. //! Unregister an audio object with the audio middleware.
  96. //! After this action, executing triggers, setting position, states, or rtpcs no longer have
  97. //! an effect on the audio object.
  98. //! @prarm objectData Implementation-specific audio object data
  99. //! @return Success if the object was unregistered, Failure otherwise.
  100. virtual EAudioRequestStatus UnregisterAudioObject(IATLAudioObjectData* objectData) = 0;
  101. ///////////////////////////////////////////////////////////////////////////////////////////////
  102. //! Clear out the audio object's internal state and reset it.
  103. //! After this action, the object can be recycled back to the pool of available audio objects.
  104. //! @param objectData Implementation-specific audio object data.
  105. //! @return Success if the object was reset, Failure otherwise.
  106. virtual EAudioRequestStatus ResetAudioObject(IATLAudioObjectData* objectData) = 0;
  107. ///////////////////////////////////////////////////////////////////////////////////////////////
  108. //! Performs actions that need to be executed regularly on an audio object.
  109. //! @param objectData Implementation-specific audio object data.
  110. //! @return Success if the object was updated, Failure otherwise.
  111. virtual EAudioRequestStatus UpdateAudioObject(IATLAudioObjectData* objectData) = 0;
  112. ///////////////////////////////////////////////////////////////////////////////////////////////
  113. //! Prepare a trigger synchronously for execution.
  114. //! Loads any metadata and media needed by the audio middleware to execute the trigger.
  115. //! @param objectData Implementation-specific audio object data.
  116. //! @param triggerData Implementation-specific trigger data.
  117. //! @return Success if the the trigger was successfully prepared, Failure otherwise.
  118. virtual EAudioRequestStatus PrepareTriggerSync(
  119. IATLAudioObjectData* audioObjectData,
  120. const IATLTriggerImplData* triggerData) = 0;
  121. ///////////////////////////////////////////////////////////////////////////////////////////////
  122. //! Unprepare a trigger synchronously when no longer needed.
  123. //! The metadata and media associated with the trigger are released.
  124. //! @param objectData Implementation-specific audio object data.
  125. //! @param triggerData Implementation-specific trigger data.
  126. //! @return Success if the trigger data was successfully unloaded, Failure otherwise.
  127. virtual EAudioRequestStatus UnprepareTriggerSync(
  128. IATLAudioObjectData* objectData,
  129. const IATLTriggerImplData* triggerData) = 0;
  130. ///////////////////////////////////////////////////////////////////////////////////////////////
  131. //! Prepare a trigger asynchronously for execution.
  132. //! Loads any metadata and media needed by the audio middleware to execute the trigger.
  133. //! An event that references eventData is created on the audio object. The prepare event
  134. //! callback is called once the loading is done and the trigger is now prepared.
  135. //! @param objectData Implementation-specific audio object data.
  136. //! @param triggerData Implementation-specific trigger data.
  137. //! @param eventData Implementation-specific event data.
  138. //! Used to manage the prepare event.
  139. //! @return Success if the trigger prepare event was successfully sent to the audio
  140. //! middleware, Failure otherwise.
  141. virtual EAudioRequestStatus PrepareTriggerAsync(
  142. IATLAudioObjectData* objectData,
  143. const IATLTriggerImplData* triggerData,
  144. IATLEventData* eventData) = 0;
  145. ///////////////////////////////////////////////////////////////////////////////////////////////
  146. //! Unprepare a trigger asynchronously when no longer needed.
  147. //! The metadata and media associated with the trigger are released.
  148. //! An event that references eventData is created on the audio object. The unprepare event
  149. //! callback is called once the unloading is done and the trigger is unprepared.
  150. //! @param objectData Implementation-specific audio object data.
  151. //! @param triggerData Implementation-specific trigger data.
  152. //! @param eventData Implementation-specific event data.
  153. //! @return Success if the trigger unprepare event was successfully sent to the audio
  154. //! middleware, Failure otherwise.
  155. virtual EAudioRequestStatus UnprepareTriggerAsync(
  156. IATLAudioObjectData* pAudioObjectData,
  157. const IATLTriggerImplData* pTriggerData,
  158. IATLEventData* pEventData) = 0;
  159. ///////////////////////////////////////////////////////////////////////////////////////////////
  160. //! Activate a trigger on an audio object.
  161. //! @param objectData Implementation-specific audio object data.
  162. //! @param triggerData Implementation-specific trigger data.
  163. //! @param eventData Implementation-specific event data.
  164. //! @return Success if the trigger was activated and the event posted to the audio
  165. //! middleware, Failure otherwise.
  166. virtual EAudioRequestStatus ActivateTrigger(
  167. IATLAudioObjectData* objectData,
  168. const IATLTriggerImplData* triggerData,
  169. IATLEventData* tventData,
  170. const SATLSourceData* sourceData) = 0;
  171. ///////////////////////////////////////////////////////////////////////////////////////////////
  172. //! Stop an event active on an audio object.
  173. //! @param objectData Implementation-specific audio object data.
  174. //! @param eventData Implementation-specific event data.
  175. //! @return Success if the event was successfully stopped, Failure otherwise.
  176. virtual EAudioRequestStatus StopEvent(
  177. IATLAudioObjectData* objectData,
  178. const IATLEventData* eventData) = 0;
  179. ///////////////////////////////////////////////////////////////////////////////////////////////
  180. //! Stop all events currently active on an audio object.
  181. //! @param objectData Implementation-specific audio object data.
  182. //! @return Success if the events were successfully stopped, Failure otherwise.
  183. virtual EAudioRequestStatus StopAllEvents(
  184. IATLAudioObjectData* objectData) = 0;
  185. ///////////////////////////////////////////////////////////////////////////////////////////////
  186. //! Set the world position of an audio object.
  187. //! @param objectData Implementation-specific audio object data.
  188. //! @param worldPosition The transform to set the audio object to.
  189. //! @return Success if the position was successfully set, Failure otherwise.
  190. virtual EAudioRequestStatus SetPosition(
  191. IATLAudioObjectData* objectData,
  192. const SATLWorldPosition& worldPosition) = 0;
  193. ///////////////////////////////////////////////////////////////////////////////////////////////
  194. //! Sets multiple world positions of an audio object.
  195. //! @param objectData Implementation-specific audio object data.
  196. //! @param multiPositions Position parameter object containing world positions.
  197. //! @return Success if the position's were successfully set, Failure otherwise.
  198. virtual EAudioRequestStatus SetMultiplePositions(
  199. IATLAudioObjectData* objectData,
  200. const MultiPositionParams& multiPositions) = 0;
  201. ///////////////////////////////////////////////////////////////////////////////////////////////
  202. //! Set an audio rtpc to the specified value on a given audio object.
  203. //! @param objectData Implementation-specific audio object data.
  204. //! @param rtpcData Implementation-specific audio rtpc data.
  205. //! @param value The value to be set, normally in the range [0.0, 1.0].
  206. //! @return Success if the rtpc value was set on the audio object, Failure otherwise.
  207. virtual EAudioRequestStatus SetRtpc(
  208. IATLAudioObjectData* objectData,
  209. const IATLRtpcImplData* rtpcData,
  210. float value) = 0;
  211. ///////////////////////////////////////////////////////////////////////////////////////////////
  212. //! Set the audio switchstate on a given audio object.
  213. //! @param objectData Implementation-specific audio object data.
  214. //! @param switchStateData Implementation-specific audio switchstate data.
  215. //! @return Success if the audio switchstate has been successfully set, Failure
  216. //! otherwise.
  217. virtual EAudioRequestStatus SetSwitchState(
  218. IATLAudioObjectData* objectData,
  219. const IATLSwitchStateImplData* switchStateData) = 0;
  220. ///////////////////////////////////////////////////////////////////////////////////////////////
  221. //! Set the Obstruction and Occlusion amounts on a given audio object.
  222. //! @param objectData Implementation-specific audio object data.
  223. //! @param obstruction The amount of obstruction associated with the audio object.
  224. //! Obstruction describes direct sound path being blocked but other paths may exist.
  225. //! @param occlusion The amount of occlusion associated with the audio object.
  226. //! Occlusion describes all paths being blocked, direct and environmental reflection paths.
  227. //! @return Success if the values were set, Failure otherwise.
  228. virtual EAudioRequestStatus SetObstructionOcclusion(
  229. IATLAudioObjectData* objectData,
  230. float obstruction,
  231. float occlusion) = 0;
  232. ///////////////////////////////////////////////////////////////////////////////////////////////
  233. //! Set the amount of an audio environment associated with an audio object.
  234. //! @param objectData Implementation-specific audio object data.
  235. //! @param environmentData Implementation-specific audio environment data.
  236. //! @param amount The float value to set, in the range [0.0, 1.0].
  237. //! @return Success if the environment amount was set, Failure otherwise.
  238. virtual EAudioRequestStatus SetEnvironment(
  239. IATLAudioObjectData* objectData,
  240. const IATLEnvironmentImplData* environmentData,
  241. float amount) = 0;
  242. ///////////////////////////////////////////////////////////////////////////////////////////////
  243. //! Set the world transform of an audio listener.
  244. //! @param listenerData Implementation-specific audio listener data.
  245. //! @param newPosition The transform to set the listener to.
  246. //! @return Success if the audio listener's world transform has been successfully set,
  247. //! Failure otherwise.
  248. virtual EAudioRequestStatus SetListenerPosition(
  249. IATLListenerData* listenerData,
  250. const SATLWorldPosition& newPosition) = 0;
  251. ///////////////////////////////////////////////////////////////////////////////////////////////
  252. //! Resets the audio rtpc data to the default state for the provided audio object.
  253. //! @param objectData Implementation-specific audio object data.
  254. //! @param rtpcData Implementation-specific audio rtpc data.
  255. //! @return Success if the provided rtpc has been successfully reset, Failure
  256. //! otherwise.
  257. virtual EAudioRequestStatus ResetRtpc(
  258. IATLAudioObjectData* objectData,
  259. const IATLRtpcImplData* rtpcData) = 0;
  260. ///////////////////////////////////////////////////////////////////////////////////////////////
  261. //! Inform the audio middleware about the memory location of loaded audio data file.
  262. //! @param audioFileEntry ATL-specific information describing the in-memory file being
  263. //! registered.
  264. //! @return Success if the audio middleware successfully registered the file, Failure
  265. //! otherwise.
  266. virtual EAudioRequestStatus RegisterInMemoryFile(SATLAudioFileEntryInfo* audioFileEntry) = 0;
  267. ///////////////////////////////////////////////////////////////////////////////////////////////
  268. //! Inform the audio middleware that the memory containing the audio data file should no longer
  269. //! be used.
  270. //! @param audioFileEntry ATL-specific information describing the file being invalidated.
  271. //! @return Success if the audio middleware unregistered the file contents, Failure
  272. //! otherwise.
  273. virtual EAudioRequestStatus UnregisterInMemoryFile(SATLAudioFileEntryInfo* audioFileEntry) = 0;
  274. ///////////////////////////////////////////////////////////////////////////////////////////////
  275. //! Parse the implementation-specific XML node that represents an audio file entry.
  276. //! Fill the fields of the struct with the data necessary to locate and store the file's
  277. //! contents in memory.
  278. //! @param audioFileEntryNode XML node corresponding to information about the file.
  279. //! Assumes that strings are null-terminated (i.e. the xml_document has been
  280. //! parsed without the 'parse_no_string_terminators' flag).
  281. //! @param fileEntryInfo Pointer to the struct containing the file entry information.
  282. //! @return Success if the XML node was parsed successfully, Failure otherwise.
  283. virtual EAudioRequestStatus ParseAudioFileEntry(
  284. const AZ::rapidxml::xml_node<char>* audioFileEntryNode,
  285. SATLAudioFileEntryInfo* fileEntryInfo) = 0;
  286. ///////////////////////////////////////////////////////////////////////////////////////////////
  287. //! Free the memory and resources of the supplied audio file entry data.
  288. //! @param oldAudioFileEntryData Implementation-specific audio file entry data.
  289. virtual void DeleteAudioFileEntryData(IATLAudioFileEntryData* oldAudioFileEntryData) = 0;
  290. ///////////////////////////////////////////////////////////////////////////////////////////////
  291. //! Get the full path to the folder containing the file described by fileEntryInfo.
  292. //! @param fileEntryInfo ATL-specific information describing the file whose location is being
  293. //! queried.
  294. //! @return A zero-terminated C-string containing the path to the file.
  295. virtual const char* const GetAudioFileLocation(SATLAudioFileEntryInfo* fileEntryInfo) = 0;
  296. ///////////////////////////////////////////////////////////////////////////////////////////////
  297. //! Parse the implementation-specific XML node that represents an audio trigger.
  298. //! @param audioTriggerNode XML node corresponding to the new audio trigger object to be
  299. //! created.
  300. //! Assumes that strings are null-terminated (i.e. the xml_document has been
  301. //! parsed without the 'parse_no_string_terminators' flag).
  302. //! @return Pointer to the newly created audio trigger object, or nullptr if it was not created.
  303. virtual IATLTriggerImplData* NewAudioTriggerImplData(const AZ::rapidxml::xml_node<char>* audioTriggerNode) = 0;
  304. ///////////////////////////////////////////////////////////////////////////////////////////////
  305. //! Free the memory and resources of the supplied audio trigger object.
  306. //! @param oldTriggerData Implementation-specific audio trigger data.
  307. virtual void DeleteAudioTriggerImplData(IATLTriggerImplData* oldTriggerData) = 0;
  308. ///////////////////////////////////////////////////////////////////////////////////////////////
  309. //! Parse the implementation-specific XML node that represents an audio rtpc.
  310. //! @param audioRtpcNode XML node corresponding to the new audio rtpc object to be created.
  311. //! Assumes that strings are null-terminated (i.e. the xml_document has been
  312. //! parsed without the 'parse_no_string_terminators' flag).
  313. //! @return Pointer to the newly created audio rtpc object, or nullptr if it was not created.
  314. virtual IATLRtpcImplData* NewAudioRtpcImplData(const AZ::rapidxml::xml_node<char>* audioRtpcNode) = 0;
  315. ///////////////////////////////////////////////////////////////////////////////////////////////
  316. //! Free the memory and resources of the supplied audio rtpc object.
  317. //! @param oldRtpcData Implementation-specific audio rtpc data.
  318. virtual void DeleteAudioRtpcImplData(IATLRtpcImplData* oldRtpcData) = 0;
  319. ///////////////////////////////////////////////////////////////////////////////////////////////
  320. //! Parse the implementation-specific XML node that represents an audio switchstate.
  321. //! @param audioSwitchStateNode XML node corresponding to the new audio switchstate object to
  322. //! be created.
  323. //! Assumes that strings are null-terminated (i.e. the xml_document has been
  324. //! parsed without the 'parse_no_string_terminators' flag).
  325. //! @return Pointer to the newly created audio switchstate object, or nullptr if it was not
  326. //! created.
  327. virtual IATLSwitchStateImplData* NewAudioSwitchStateImplData(const AZ::rapidxml::xml_node<char>* audioSwitchStateNode) = 0;
  328. ///////////////////////////////////////////////////////////////////////////////////////////////
  329. //! Free the memory and resources of the supplied audio switchstate object.
  330. //! @param oldAudioSwitchStateData Implementation-specific audio switchstate data.
  331. virtual void DeleteAudioSwitchStateImplData(IATLSwitchStateImplData* oldAudioSwitchStateData) = 0;
  332. ///////////////////////////////////////////////////////////////////////////////////////////////
  333. //! Parse the implementation-specific XML node that represents an audio environment.
  334. //! @param audioEnvironmentNode XML node corresponding to the new audio environment object to
  335. //! be created.
  336. //! Assumes that strings are null-terminated (i.e. the xml_document has been
  337. //! parsed without the 'parse_no_string_terminators' flag).
  338. //! @return Pointer to the newly created audio environment object, or nullptr if it was not
  339. //! created.
  340. virtual IATLEnvironmentImplData* NewAudioEnvironmentImplData(const AZ::rapidxml::xml_node<char>* audioEnvironmentNode) = 0;
  341. ///////////////////////////////////////////////////////////////////////////////////////////////
  342. //! Free the memory and resources of the supplied audio environment object.
  343. //! @param oldEnvironmentData Implementation-specific audio environment data.
  344. virtual void DeleteAudioEnvironmentImplData(IATLEnvironmentImplData* oldEnvironmentData) = 0;
  345. ///////////////////////////////////////////////////////////////////////////////////////////////
  346. //! Create an implementation-specific global audio object.
  347. //! @param objectId Unique ID to assign to the global audio object.
  348. //! @return Pointer to the newly created global audio object, or nullptr if it was not created.
  349. virtual IATLAudioObjectData* NewGlobalAudioObjectData(TAudioObjectID objectId) = 0;
  350. ///////////////////////////////////////////////////////////////////////////////////////////////
  351. //! Create an implementation-specific audio object.
  352. //! @param objectId Unique ID of the audio object.
  353. //! @return Pointer to the newly created audio object, or nullptr if it was not created.
  354. virtual IATLAudioObjectData* NewAudioObjectData(TAudioObjectID objectId) = 0;
  355. ///////////////////////////////////////////////////////////////////////////////////////////////
  356. //! Free the memory and resources of the supplied audio object data.
  357. //! @param oldObjectData Implementation-specific audio object data.
  358. virtual void DeleteAudioObjectData(IATLAudioObjectData* oldObjectData) = 0;
  359. ///////////////////////////////////////////////////////////////////////////////////////////////
  360. //! Create an implementation-specific listener object data that will be the default listener.
  361. //! @param objectId Unique ID of the default listener.
  362. //! @return Pointer to the newly created default listener object, or nullptr if it was not
  363. //! created.
  364. virtual IATLListenerData* NewDefaultAudioListenerObjectData(TATLIDType objectId) = 0;
  365. ///////////////////////////////////////////////////////////////////////////////////////////////
  366. //! Create an implementation-specific listener object data.
  367. //! @param objectId Unique ID of the listener.
  368. //! @return Pointer to the newly created listener object, or nullptr if it was not created.
  369. virtual IATLListenerData* NewAudioListenerObjectData(TATLIDType objectId) = 0;
  370. ///////////////////////////////////////////////////////////////////////////////////////////////
  371. //! Free the memory and resources of the supplied listener object.
  372. //! @param oldListenerData Implementation-specific listener object.
  373. virtual void DeleteAudioListenerObjectData(IATLListenerData* oldListenerData) = 0;
  374. ///////////////////////////////////////////////////////////////////////////////////////////////
  375. //! Create an implementation-specific event object data.
  376. //! @param eventId Unique ID for the event.
  377. //! @return Pointer to the newly created event object, or nullptr if it was not created.
  378. virtual IATLEventData* NewAudioEventData(TAudioEventID eventID) = 0;
  379. ///////////////////////////////////////////////////////////////////////////////////////////////
  380. //! Free the memory and resources of the supplied event object.
  381. //! @param oldEventData Implementation-specific event object.
  382. virtual void DeleteAudioEventData(IATLEventData* oldEventData) = 0;
  383. ///////////////////////////////////////////////////////////////////////////////////////////////
  384. //! Reset all the members of an audio event instance without releasing the memory.
  385. //! This is used so the event object can be recycled back to the pool.
  386. //! @param eventData Implementation-specific event data.
  387. virtual void ResetAudioEventData(IATLEventData* eventData) = 0;
  388. ///////////////////////////////////////////////////////////////////////////////////////////////
  389. //! Set the language used by the audio middleware.
  390. //! Informs the audio middleware that the localized sound banks and streamed files need to
  391. //! use a different language. This function does not unload or reload the currently
  392. //! loaded audio files.
  393. //! @param language A zero-terminated C-string representing the language.
  394. virtual void SetLanguage(const char* language) = 0;
  395. ///////////////////////////////////////////////////////////////////////////////////////////////
  396. //! Get the canonical subfolder for this audio middleware implementation.
  397. //! Used for locating audio data in the game assets folder.
  398. //! @return A zero-terminated C-string with the subfolder this implementation uses.
  399. virtual const char* const GetImplSubPath() const = 0;
  400. ///////////////////////////////////////////////////////////////////////////////////////////////
  401. //! Get the name of the audio middleware implementation.
  402. //! This string can be displayed on screen.
  403. //! @return A zero-terminated C-string with the name of the audio middleware implementation.
  404. virtual const char* const GetImplementationNameString() const = 0;
  405. ///////////////////////////////////////////////////////////////////////////////////////////////
  406. //! Obtain information describing the current memory usage of this audio middleware
  407. //! implementation.
  408. //! This data can be displayed on screen.
  409. //! param memoryInfo A reference to a SAudioImplMemoryInfo struct.
  410. virtual void GetMemoryInfo(SAudioImplMemoryInfo& memoryInfo) const = 0;
  411. ///////////////////////////////////////////////////////////////////////////////////////////////
  412. //! Retrieve information about memory pools active in the audio middleware.
  413. //! @return Vector of AudioImplMemoryPoolInfo.
  414. virtual AZStd::vector<AudioImplMemoryPoolInfo> GetMemoryPoolInfo() = 0;
  415. ///////////////////////////////////////////////////////////////////////////////////////////////
  416. //! Create an Audio Source as specified by a configuration.
  417. //! @param sourceConfig Configuration information specifying the format of the source.
  418. virtual bool CreateAudioSource(const SAudioInputConfig& sourceConfig) = 0;
  419. ///////////////////////////////////////////////////////////////////////////////////////////////
  420. //! Destroys a managed Audio Source.
  421. //! @param sourceId ID of the Audio Source.
  422. virtual void DestroyAudioSource(TAudioSourceId sourceId) = 0;
  423. ///////////////////////////////////////////////////////////////////////////////////////////////
  424. //! Set the panning mode for the audio middleware.
  425. //! @param mode The PanningMode to use.
  426. virtual void SetPanningMode(PanningMode mode) = 0;
  427. };
  428. using AudioSystemImplementationRequestBus = AZ::EBus<AudioSystemImplementationRequests>;
  429. ///////////////////////////////////////////////////////////////////////////////////////////////////
  430. //! This interface is used by the AudioTranslationLayer to interact with an audio middleware
  431. //! implementation.
  432. class AudioSystemImplementation
  433. : public AudioSystemImplementationNotificationBus::Handler
  434. , public AudioSystemImplementationRequestBus::Handler
  435. {
  436. public:
  437. ~AudioSystemImplementation() override = default;
  438. };
  439. } // namespace Audio