File indexing completed on 2024-04-21 04:54:25

0001 /*
0002  *  KCompactDisc - A CD drive interface for the KDE Project.
0003  *
0004  *  Copyright (C) 2007 Alexander Kern <alex.kern@gmx.de>
0005  *
0006  *  This program is free software; you can redistribute it and/or modify
0007  *  it under the terms of the GNU General Public License as published by
0008  *  the Free Software Foundation; either version 2, or (at your option)
0009  *  any later version.
0010  *
0011  *  This program is distributed in the hope that it will be useful,
0012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014  *  GNU General Public License for more details.
0015  *
0016  *  You should have received a copy of the GNU General Public License
0017  *  along with this program; if not, write to the Free Software
0018  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
0019  */
0020 
0021 #ifndef KCOMPACTDISC_P_H
0022 #define KCOMPACTDISC_P_H
0023 
0024 #include <QString>
0025 #include <QList>
0026 #include <QLoggingCategory>
0027 #include <QtGlobal>
0028 #include <QRandomGenerator>
0029 
0030 #include "kcompactdisc.h"
0031 
0032 Q_DECLARE_LOGGING_CATEGORY(CD_PLAYLIST)
0033 
0034 class KCompactDiscPrivate : public QObject
0035 {
0036     Q_OBJECT
0037 
0038     public:
0039         KCompactDiscPrivate(KCompactDisc *, const QString&);
0040         ~KCompactDiscPrivate() override { }
0041     
0042         bool moveInterface(const QString &, const QString &, const QString &);
0043         virtual bool createInterface();
0044 
0045         QString m_interface;
0046         KCompactDisc::InformationMode m_infoMode;
0047         QString m_deviceName;
0048     
0049         KCompactDisc::DiscStatus m_status;
0050         KCompactDisc::DiscStatus m_statusExpected;
0051         unsigned m_discId;
0052         unsigned m_discLength;
0053         unsigned m_track;
0054         unsigned m_tracks;
0055         unsigned m_trackPosition;
0056         unsigned m_discPosition;
0057         unsigned m_trackExpectedPosition;
0058         int m_seek;
0059     
0060         QList<unsigned> m_trackStartFrames;
0061         QStringList m_trackArtists;
0062         QStringList m_trackTitles;
0063     
0064         QRandomGenerator m_randSequence;
0065         QList<unsigned> m_playlist;
0066         bool m_loopPlaylist;
0067         bool m_randomPlaylist;
0068         bool m_autoMetadata;
0069     
0070         void make_playlist();
0071         unsigned getNextTrackInPlaylist();
0072         unsigned getPrevTrackInPlaylist();
0073         bool skipStatusChange(KCompactDisc::DiscStatus);
0074         static const QString discStatusI18n(KCompactDisc::DiscStatus);
0075 
0076         void clearDiscInfo();
0077 
0078         virtual unsigned trackLength(unsigned);
0079         virtual bool isTrackAudio(unsigned);
0080         virtual void playTrackPosition(unsigned, unsigned);
0081         virtual void pause();
0082         virtual void stop();
0083         virtual void eject();
0084         virtual void closetray();
0085     
0086         virtual void setVolume(unsigned);
0087         virtual void setBalance(unsigned);
0088         virtual unsigned volume();
0089         virtual unsigned balance();
0090 
0091         virtual void queryMetadata();
0092     
0093         QString m_deviceVendor;
0094         QString m_deviceModel;
0095         QString m_deviceRevision;
0096 
0097     public:
0098         Q_DECLARE_PUBLIC(KCompactDisc)
0099         KCompactDisc * const q_ptr;
0100 };
0101 
0102 
0103 #define SEC2FRAMES(sec) ((sec) * 75)
0104 #define FRAMES2SEC(frames) ((frames) / 75)
0105 #define MS2SEC(ms) ((ms) / 1000)
0106 #define SEC2MS(sec) ((sec) * 1000)
0107 #define MS2FRAMES(ms) (((ms) * 75) / 1000)
0108 #define FRAMES2MS(frames) (((frames) * 1000) / 75)
0109 
0110 #endif /* KCOMPACTDISC_P_H */