audio_opensles_device_impl.cxx 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* Copyright (C) 2012 Doubango Telecom <http://www.doubango.org>
  2. *
  3. * This file is part of Open Source Doubango Framework.
  4. *
  5. * DOUBANGO is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * DOUBANGO is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with DOUBANGO.
  17. */
  18. #include "audio_opensles_device_impl.h"
  19. #include "audio_opensles_producer.h"
  20. #include "audio_opensles_consumer.h"
  21. SLAudioDeviceCallbackImpl::SLAudioDeviceCallbackImpl():
  22. SLAudioDeviceCallback()
  23. {
  24. }
  25. SLAudioDeviceCallbackImpl::~SLAudioDeviceCallbackImpl()
  26. {
  27. }
  28. int32_t SLAudioDeviceCallbackImpl::RecordedDataIsAvailable(const void* audioSamples,
  29. const uint32_t nSamples,
  30. const uint8_t nBytesPerSample,
  31. const uint8_t nChannels,
  32. const uint32_t samplesPerSec)
  33. {
  34. if(!m_pProducer) {
  35. AUDIO_OPENSLES_DEBUG_WARN("No wrapped producer");
  36. return 0;
  37. }
  38. return audio_producer_opensles_handle_data_10ms(m_pProducer, audioSamples, nSamples, nBytesPerSample, samplesPerSec, nChannels);
  39. }
  40. int32_t SLAudioDeviceCallbackImpl::NeedMorePlayData(const uint32_t nSamples,
  41. const uint8_t nBytesPerSample,
  42. const uint8_t nChannels,
  43. const uint32_t samplesPerSec,
  44. void* audioSamples,
  45. uint32_t& nSamplesOut)
  46. {
  47. if(!m_pConsumer) {
  48. AUDIO_OPENSLES_DEBUG_WARN("No wrapped consumer");
  49. return 0;
  50. }
  51. return audio_consumer_opensles_get_data_10ms(m_pConsumer, audioSamples, nSamples, nBytesPerSample, nChannels, samplesPerSec, nSamplesOut);
  52. }