1 | /* |
2 | Copyright (C) 2012 Trever Fischer <tdfischer@fedoraproject.org> |
3 | Copyright (C) 2012 Harald Sitter <sitter@kde.org> |
4 | |
5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Lesser General Public |
7 | License as published by the Free Software Foundation; either |
8 | version 2.1 of the License, or (at your option) version 3, or any |
9 | later version accepted by the membership of KDE e.V. (or its |
10 | successor approved by the membership of KDE e.V.), Nokia Corporation |
11 | (or its successors, if any) and the KDE Free Qt Foundation, which shall |
12 | act as a proxy defined in Section 6 of version 3 of the license. |
13 | |
14 | This library is distributed in the hope that it will be useful, |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
17 | Lesser General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Lesser General Public |
20 | License along with this library. If not, see <http://www.gnu.org/licenses/>. |
21 | */ |
22 | |
23 | #ifndef PHONON_STATESVALIDATOR_P_H |
24 | #define PHONON_STATESVALIDATOR_P_H |
25 | |
26 | #include <QObject> |
27 | |
28 | #include "phononnamespace.h" |
29 | |
30 | namespace Phonon |
31 | { |
32 | |
33 | class MediaObject; |
34 | |
35 | class StatesValidator : public QObject |
36 | { |
37 | Q_OBJECT |
38 | public: |
39 | explicit StatesValidator(MediaObject *parent = nullptr); |
40 | ~StatesValidator() override; |
41 | |
42 | inline void sourceQueued() { m_sourceQueued = true; } |
43 | |
44 | private slots: |
45 | void validateStateChange(Phonon::State, Phonon::State); |
46 | void validateTick(qint64 tick); |
47 | void validateAboutToFinish(); |
48 | void validateFinished(); |
49 | void validateBufferStatus(); |
50 | void validateSourceChange(); |
51 | |
52 | private: |
53 | bool validateStateTransition(Phonon::State newstate, Phonon::State oldstate); |
54 | |
55 | MediaObject *m_mediaObject; |
56 | |
57 | Phonon::State m_prevState; /** < Track prev state to do a better job at Buffering validation */ |
58 | |
59 | bool m_sourceQueued; /** < Track whether a source was queued in the backend */ |
60 | qint64 m_pos; /** < Track position for abouttofinish validation */ |
61 | |
62 | bool m_aboutToFinishEmitted; |
63 | bool m_aboutToFinishBeforeSeek; /** < True when a seek was conducted before a source change */ |
64 | qint64 m_aboutToFinishPos; /** < Position when abouttofinish was emitted */ |
65 | }; |
66 | |
67 | } // namespace Phonon |
68 | |
69 | #endif // PHONON_STATESVALIDATOR_P_H |
70 | |