pushaudioout.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /**
  2. * Copyright (c) 2011 Nokia Corporation.
  3. *
  4. * Part of the Qt GameEnabler.
  5. */
  6. #ifndef GEPUSHAUDIOOUT_H
  7. #define GEPUSHAUDIOOUT_H
  8. #include <QAudioOutput>
  9. #include <QThread>
  10. #include <QIODevice>
  11. #include <QPointer>
  12. #include "geglobal.h"
  13. #include "audioout.h"
  14. #include "audiosourceif.h"
  15. namespace GE {
  16. class Q_GE_EXPORT PushAudioOut : public QThread,
  17. public AudioOut
  18. {
  19. Q_OBJECT
  20. public:
  21. PushAudioOut(AudioSource *source, QObject *parent = 0);
  22. virtual ~PushAudioOut();
  23. public:
  24. bool needsManualTick() const { return m_needsTick; }
  25. void tick();
  26. virtual bool startAudio();
  27. virtual void stopAudio();
  28. protected: // From QThread
  29. virtual void run(); // For the threaded mode only!
  30. private: // Data types
  31. enum ThreadStates {
  32. NotRunning = 0,
  33. DoRun = 1,
  34. DoExit = 2
  35. };
  36. protected: // Data
  37. QAudioOutput *m_audioOutput; // Owned
  38. QIODevice *m_outTarget; // Not owned
  39. AUDIO_SAMPLE_TYPE *m_sendBuffer; // Owned
  40. int m_sendBufferSize;
  41. qint64 m_samplesMixed;
  42. int m_threadState;
  43. bool m_needsTick;
  44. AudioSource *m_source; // Not owned
  45. };
  46. } // namespace GE
  47. #endif // GEPUSHAUDIOOUT_H