ijksdl_aout.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*****************************************************************************
  2. * ijksdl_aout.c
  3. *****************************************************************************
  4. *
  5. * Copyright (c) 2013 Bilibili
  6. * copyright (c) 2013 Zhang Rui <bbcallen@gmail.com>
  7. *
  8. * This file is part of ijkPlayer.
  9. *
  10. * ijkPlayer is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU Lesser General Public
  12. * License as published by the Free Software Foundation; either
  13. * version 2.1 of the License, or (at your option) any later version.
  14. *
  15. * ijkPlayer is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * Lesser General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Lesser General Public
  21. * License along with ijkPlayer; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  23. */
  24. #include "ijksdl_aout.h"
  25. #include <stdlib.h>
  26. #include "ijkplayer/ff_ffplay_def.h"
  27. int SDL_AoutOpenAudio(SDL_Aout *aout, const SDL_AudioSpec *desired, SDL_AudioSpec *obtained)
  28. {
  29. if (aout && desired && aout->open_audio)
  30. return aout->open_audio(aout, desired, obtained);
  31. return -1;
  32. }
  33. void SDL_AoutPauseAudio(SDL_Aout *aout, int pause_on)
  34. {
  35. if (aout && aout->pause_audio)
  36. aout->pause_audio(aout, pause_on);
  37. }
  38. void SDL_AoutFlushAudio(SDL_Aout *aout)
  39. {
  40. if (aout && aout->flush_audio)
  41. aout->flush_audio(aout);
  42. }
  43. void SDL_AoutSetStereoVolume(SDL_Aout *aout, float left_volume, float right_volume)
  44. {
  45. if (aout && aout->set_volume)
  46. aout->set_volume(aout, left_volume, right_volume);
  47. }
  48. void SDL_AoutCloseAudio(SDL_Aout *aout)
  49. {
  50. if (aout && aout->close_audio)
  51. return aout->close_audio(aout);
  52. }
  53. void SDL_AoutFree(SDL_Aout *aout)
  54. {
  55. if (!aout)
  56. return;
  57. if (aout->free_l)
  58. aout->free_l(aout);
  59. else
  60. free(aout);
  61. }
  62. void SDL_AoutFreeP(SDL_Aout **paout)
  63. {
  64. if (!paout)
  65. return;
  66. SDL_AoutFree(*paout);
  67. *paout = NULL;
  68. }
  69. double SDL_AoutGetLatencySeconds(SDL_Aout *aout)
  70. {
  71. if (!aout)
  72. return 0;
  73. if (aout->func_get_latency_seconds)
  74. return aout->func_get_latency_seconds(aout);
  75. return aout->minimal_latency_seconds;
  76. }
  77. void SDL_AoutSetDefaultLatencySeconds(SDL_Aout *aout, double latency)
  78. {
  79. if (aout) {
  80. if (aout->func_set_default_latency_seconds)
  81. aout->func_set_default_latency_seconds(aout, latency);
  82. aout->minimal_latency_seconds = latency;
  83. }
  84. }
  85. void SDL_AoutSetPlaybackRate(SDL_Aout *aout, float playbackRate)
  86. {
  87. if (aout) {
  88. if (aout->func_set_playback_rate)
  89. aout->func_set_playback_rate(aout, playbackRate);
  90. }
  91. }
  92. void SDL_AoutSetPlaybackVolume(SDL_Aout *aout, float volume)
  93. {
  94. if (aout) {
  95. if (aout->func_set_playback_volume)
  96. aout->func_set_playback_volume(aout, volume);
  97. }
  98. }
  99. int SDL_AoutGetAudioSessionId(SDL_Aout *aout)
  100. {
  101. if (aout) {
  102. if (aout->func_get_audio_session_id) {
  103. return aout->func_get_audio_session_id(aout);
  104. }
  105. }
  106. return 0;
  107. }
  108. int SDL_AoutGetAudioPerSecondCallBacks(SDL_Aout *aout)
  109. {
  110. if (aout) {
  111. if (aout->func_get_audio_persecond_callbacks) {
  112. return aout->func_get_audio_persecond_callbacks(aout);
  113. }
  114. }
  115. return SDL_AUDIO_MAX_CALLBACKS_PER_SEC;
  116. }