diff options
Diffstat (limited to 'src/mixer/playerinfo.h')
-rw-r--r-- | src/mixer/playerinfo.h | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/src/mixer/playerinfo.h b/src/mixer/playerinfo.h new file mode 100644 index 0000000000..ce822a89bc --- /dev/null +++ b/src/mixer/playerinfo.h @@ -0,0 +1,81 @@ +/*************************************************************************** + playerinfo.h - Helper class to have easy access + to a lot of data (singleton) + ------------------- + copyright : (C) 2007 by Wesley Stessens + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#ifndef MIXER_PLAYERINFO_H +#define MIXER_PLAYERINFO_H + +#include <QObject> +#include <QMutex> +#include <QMap> +#include <QTimerEvent> + +#include "controlobjectslave.h" +#include "trackinfoobject.h" + +class PlayerInfo : public QObject { + Q_OBJECT + public: + static PlayerInfo& instance(); + static void destroy(); + TrackPointer getTrackInfo(const QString& group); + void setTrackInfo(const QString& group, const TrackPointer& trackInfoObj); + TrackPointer getCurrentPlayingTrack(); + QMap<QString, TrackPointer> getLoadedTracks(); + bool isTrackLoaded(const TrackPointer& pTrack) const; + bool isFileLoaded(const QString& track_location) const; + + signals: + void currentPlayingDeckChanged(int deck); + void currentPlayingTrackChanged(TrackPointer pTrack); + void trackLoaded(QString group, TrackPointer pTrack); + void trackUnloaded(QString group, TrackPointer pTrack); + + private: + class DeckControls { + public: + DeckControls(QString& group) + : m_play(group, "play"), + m_pregain(group, "pregain"), + m_volume(group, "volume"), + m_orientation(group, "orientation") { + } + + ControlObjectSlave m_play; + ControlObjectSlave m_pregain; + ControlObjectSlave m_volume; + ControlObjectSlave m_orientation; + }; + + void clearControlCache(); + void timerEvent(QTimerEvent* pTimerEvent); + void updateCurrentPlayingDeck(); + int getCurrentPlayingDeck(); + DeckControls* getDeckControls(int i); + + PlayerInfo(); + virtual ~PlayerInfo(); + + mutable QMutex m_mutex; + ControlObjectSlave* m_pCOxfader; + // QMap is faster than QHash for small count of elements < 50 + QMap<QString, TrackPointer> m_loadedTrackMap; + int m_currentlyPlayingDeck; + QList<DeckControls*> m_deckControlList; + + static PlayerInfo* m_pPlayerinfo; +}; + +#endif /* MIXER_PLAYERINFO_H */ |