AudioOutputOpenSLES.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //
  2. // libtgvoip is free and unencumbered public domain software.
  3. // For more information, see http://unlicense.org or the UNLICENSE file
  4. // you should have received with this source code distribution.
  5. //
  6. #ifndef LIBTGVOIP_AUDIOOUTPUTOPENSLES_H
  7. #define LIBTGVOIP_AUDIOOUTPUTOPENSLES_H
  8. #include <SLES/OpenSLES.h>
  9. #include <SLES/OpenSLES_Android.h>
  10. #include "../../audio/AudioOutput.h"
  11. namespace tgvoip{ namespace audio{
  12. class AudioOutputOpenSLES : public AudioOutput{
  13. public:
  14. AudioOutputOpenSLES();
  15. virtual ~AudioOutputOpenSLES();
  16. virtual void Configure(uint32_t sampleRate, uint32_t bitsPerSample, uint32_t channels);
  17. virtual bool IsPhone();
  18. virtual void EnableLoudspeaker(bool enabled);
  19. virtual void Start();
  20. virtual void Stop();
  21. virtual bool IsPlaying();
  22. virtual float GetLevel();
  23. static void SetNativeBufferSize(unsigned int size);
  24. static unsigned int nativeBufferSize;
  25. private:
  26. static void BufferCallback(SLAndroidSimpleBufferQueueItf bq, void *context);
  27. void HandleSLCallback();
  28. SLEngineItf slEngine;
  29. SLObjectItf slPlayerObj;
  30. SLObjectItf slOutputMixObj;
  31. SLPlayItf slPlayer;
  32. SLAndroidSimpleBufferQueueItf slBufferQueue;
  33. int16_t* buffer;
  34. int16_t* nativeBuffer;
  35. bool stopped;
  36. unsigned char remainingData[10240];
  37. size_t remainingDataSize;
  38. };
  39. }}
  40. #endif //LIBTGVOIP_AUDIOOUTPUTANDROID_H