diff options
| author | manuel <manuel@mausz.at> | 2011-04-14 02:37:31 +0200 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2011-04-14 02:37:31 +0200 |
| commit | b18385a95f25e13c767244b494f31bd4fc238143 (patch) | |
| tree | af389057a2d4a03565f70186d7c1d2e49b95828f /pacman-c++/audio.h | |
| parent | 3d20638fa8e295271ce38953ad1c657d9275bd99 (diff) | |
| download | foop-b18385a95f25e13c767244b494f31bd4fc238143.tar.gz foop-b18385a95f25e13c767244b494f31bd4fc238143.tar.bz2 foop-b18385a95f25e13c767244b494f31bd4fc238143.zip | |
encapsulate gapless audioplayer commit from yesterday into an own class (gaplessaudioplayer)
added two new menu entrys: toggle sound + toggle ambient sound (2. very useful!)
Diffstat (limited to 'pacman-c++/audio.h')
| -rw-r--r-- | pacman-c++/audio.h | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/pacman-c++/audio.h b/pacman-c++/audio.h index 49d29a9..3e76f50 100644 --- a/pacman-c++/audio.h +++ b/pacman-c++/audio.h | |||
| @@ -25,6 +25,8 @@ namespace Sound | |||
| 25 | }; | 25 | }; |
| 26 | }; | 26 | }; |
| 27 | 27 | ||
| 28 | /* --------------------------------------------------------------- */ | ||
| 29 | |||
| 28 | class AudioPlayer | 30 | class AudioPlayer |
| 29 | : public Phonon::MediaObject | 31 | : public Phonon::MediaObject |
| 30 | { | 32 | { |
| @@ -46,32 +48,61 @@ public: | |||
| 46 | bool isWorking() const; | 48 | bool isWorking() const; |
| 47 | void setMuted(bool mute = true); | 49 | void setMuted(bool mute = true); |
| 48 | bool isMuted() const; | 50 | bool isMuted() const; |
| 49 | void setLoop(QFile *sound); | ||
| 50 | void setLoop(Sound::Type sound); | 51 | void setLoop(Sound::Type sound); |
| 51 | void play(); | 52 | void play(); |
| 52 | void play(Sound::Type sound); | 53 | void play(Sound::Type sound); |
| 53 | 54 | ||
| 54 | private: | 55 | protected: |
| 55 | void test(QFile *testsound); | 56 | void test(QFile *testsound); |
| 57 | void setLoop(QFile *sound); | ||
| 56 | 58 | ||
| 57 | public slots: | 59 | public slots: |
| 58 | void loopEnqueue(); | 60 | void loopEnqueue(); |
| 59 | 61 | ||
| 60 | private slots: | 62 | protected slots: |
| 61 | void testFinished(); | 63 | void testFinished(); |
| 62 | void stateChanged_ex(Phonon::State newstate, Phonon::State oldstate); | 64 | void stateChanged_ex(Phonon::State newstate, Phonon::State oldstate); |
| 63 | 65 | ||
| 64 | private: | 66 | protected: |
| 65 | bool m_working; | 67 | bool m_working; |
| 66 | QFile *m_loopsound; | 68 | QFile *m_loopsound; |
| 67 | Phonon::AudioOutput *m_output; | 69 | Phonon::AudioOutput *m_output; |
| 68 | }; | 70 | }; |
| 69 | 71 | ||
| 72 | /* --------------------------------------------------------------- */ | ||
| 73 | |||
| 74 | class GaplessAudioPlayer | ||
| 75 | : public QObject | ||
| 76 | { | ||
| 77 | Q_OBJECT | ||
| 78 | |||
| 79 | public: | ||
| 80 | GaplessAudioPlayer(Sound::Type sound, qint32 mark, QObject *parent = 0); | ||
| 81 | bool isWorking() const; | ||
| 82 | void setMuted(bool mute = true); | ||
| 83 | bool isMuted() const; | ||
| 84 | void play(); | ||
| 85 | void pause(); | ||
| 86 | |||
| 87 | protected slots: | ||
| 88 | void startPlayer1(); | ||
| 89 | void startPlayer2(); | ||
| 90 | |||
| 91 | protected: | ||
| 92 | bool m_working; | ||
| 93 | Sound::Type m_sound; | ||
| 94 | AudioPlayer *m_player1; | ||
| 95 | AudioPlayer *m_player2; | ||
| 96 | }; | ||
| 97 | |||
| 98 | /* --------------------------------------------------------------- */ | ||
| 99 | |||
| 70 | class AudioManager | 100 | class AudioManager |
| 71 | : public QObject | 101 | : public QObject |
| 72 | { | 102 | { |
| 73 | Q_OBJECT | 103 | Q_OBJECT |
| 74 | friend class AudioPlayer; | 104 | friend class AudioPlayer; |
| 105 | friend class GaplessAudioPlayer; | ||
| 75 | 106 | ||
| 76 | public: | 107 | public: |
| 77 | AudioManager(); | 108 | AudioManager(); |
