AUD_PlaybackManager.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*******************************************************************************
  2. * Copyright 2015-2016 Juan Francisco Crespo Galán
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. ******************************************************************************/
  16. #pragma once
  17. #include "AUD_Types.h"
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. /**
  22. * Creates a new PlaybackManager object.
  23. * \param device The device that will be used to play sounds.
  24. * \return The new PlaybackManager object.
  25. */
  26. extern AUD_API AUD_PlaybackManager* AUD_PlaybackManager_create(AUD_Device* device);
  27. /**
  28. * Deletes a PlaybackManager object.
  29. * \param manager The PlaybackManager object to be deleted.
  30. */
  31. extern AUD_API void AUD_PlaybackManager_free(AUD_PlaybackManager* manager);
  32. /**
  33. * Plays a sound through the playback manager, adding it into a category.
  34. * \param manager The PlaybackManager object.
  35. * \param sound The sound to be played.
  36. * \param catKey The key of the category into which the sound will be added. If it doesn't exist a new one will be creatd.
  37. */
  38. extern AUD_API void AUD_PlaybackManager_play(AUD_PlaybackManager* manager, AUD_Sound* sound, unsigned int catKey);
  39. /**
  40. * Resumes the playback of all the paused sounds assigned to a category of a playback manager.
  41. * \param manager The PlaybackManager object.
  42. * \param catKey The key of the category.
  43. * \return 0 if the category doesn't exist.
  44. */
  45. extern AUD_API int AUD_PlaybackManager_resume(AUD_PlaybackManager* manager, unsigned int catKey);
  46. /**
  47. * Pauses all the sounds assigned to a category of a playback manager.
  48. * \param manager The PlaybackManager object.
  49. * \param catKey The key of the category.
  50. * \return 0 if the category doesn't exist.
  51. */
  52. extern AUD_API int AUD_PlaybackManager_pause(AUD_PlaybackManager* manager, unsigned int catKey);
  53. /**
  54. * Adds a new category with a custom volume.
  55. * \param manager The PlaybackManager object.
  56. * \param volume The volume value.
  57. * \return The key of the new category.
  58. */
  59. extern AUD_API unsigned int AUD_PlaybackManager_addCategory(AUD_PlaybackManager* manager, float volume);
  60. /**
  61. * Retrieves the volume of a category of a playback manager.
  62. * \param manager The PlaybackManager object.
  63. * \param catKey The key of the category.
  64. * \return The volume of the category.
  65. */
  66. extern AUD_API float AUD_PlaybackManager_getVolume(AUD_PlaybackManager* manager, unsigned int catKey);
  67. /**
  68. * Changes the voulume of a category of a playback manager.
  69. * \param manager The PlaybackManager object.
  70. * \param volume The new volume of the category.
  71. * \param catKey The key of the category.
  72. * \return 0 if the category doesn't exist.
  73. */
  74. extern AUD_API int AUD_PlaybackManager_setVolume(AUD_PlaybackManager* manager, float volume, unsigned int catKey);
  75. /**
  76. * Stops all the sounds assigned to a category of a playback manager.
  77. * \param manager The PlaybackManager object.
  78. * \param catKey The key of the category.
  79. * \return 0 if the category doesn't exist.
  80. */
  81. extern AUD_API int AUD_PlaybackManager_stop(AUD_PlaybackManager* manager, unsigned int catKey);
  82. /**
  83. * Cleans all the invalid handles in a playback manager
  84. * \param manager The PlaybackManager object.
  85. */
  86. extern AUD_API void AUD_PlaybackManager_clean(AUD_PlaybackManager* manager);
  87. #ifdef __cplusplus
  88. }
  89. #endif