OpenAL_AudioInterface.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /// @file
  2. /// @version 2.0
  3. ///
  4. /// @section LICENSE
  5. ///
  6. /// This program is free software; you can redistribute it and/or modify it under
  7. /// the terms of the BSD license: http://opensource.org/licenses/BSD-3-Clause
  8. ///
  9. /// @section DESCRIPTION
  10. ///
  11. /// Defines an audio interface for OpenAL.
  12. #ifndef THEORAPLAYER_DEMOS_OPENAL_AUDIO_INTERFACE_H
  13. #define THEORAPLAYER_DEMOS_OPENAL_AUDIO_INTERFACE_H
  14. #ifndef __APPLE__
  15. #include <AL/al.h>
  16. #include <AL/alc.h>
  17. #else
  18. #include <OpenAL/al.h>
  19. #include <OpenAL/alc.h>
  20. #endif
  21. #include <queue>
  22. #include <theoraplayer/AudioInterface.h>
  23. #include <theoraplayer/AudioInterfaceFactory.h>
  24. #include <theoraplayer/Timer.h>
  25. #include <theoraplayer/VideoClip.h>
  26. class OpenAL_AudioInterface : public theoraplayer::AudioInterface, theoraplayer::Timer
  27. {
  28. public:
  29. OpenAL_AudioInterface(theoraplayer::VideoClip* clip, int channelsCount, int frequency);
  30. ~OpenAL_AudioInterface();
  31. //! queued audio buffers, expressed in seconds
  32. float getQueuedAudioSize();
  33. void insertData(float* data, int samplesCount);
  34. void update(float timeDelta);
  35. void pause();
  36. void play();
  37. void seek(float time);
  38. private:
  39. int sourceNumChannels;
  40. int maxBuffSize;
  41. int buffSize;
  42. short* tempBuffer;
  43. float currentTimer;
  44. struct OpenAL_Buffer
  45. {
  46. ALuint id;
  47. int samplesCount;
  48. };
  49. std::queue<OpenAL_Buffer> bufferQueue;
  50. ALuint source;
  51. int numProcessedSamples;
  52. int numPlayedSamples;
  53. };
  54. class OpenAL_AudioInterfaceFactory : public theoraplayer::AudioInterfaceFactory
  55. {
  56. public:
  57. OpenAL_AudioInterfaceFactory();
  58. ~OpenAL_AudioInterfaceFactory();
  59. OpenAL_AudioInterface* createInstance(theoraplayer::VideoClip* clip, int channelsCount, int frequency);
  60. };
  61. #endif