MythTV  master
cddecoder.h
Go to the documentation of this file.
1 #ifndef CDDECODER_H_
2 #define CDDECODER_H_
3 
4 #include "decoder.h"
5 
6 #include <mythconfig.h>
7 #include "config.h"
8 
9 #if CONFIG_DARWIN
10 #include <vector>
11 using std::vector;
12 #endif
13 
14 #ifdef HAVE_CDIO
15 # ifdef HAVE_CDPARANOIA_SUBDIR
16 # include <cdio/paranoia/cdda.h>
17 # include <cdio/paranoia/paranoia.h>
18 # else
19 # include <cdio/cdda.h>
20 # include <cdio/paranoia.h>
21 # endif
22 #endif
23 
24 class MusicMetadata;
25 
26 class CdDecoder : public Decoder
27 {
29 
30  public:
31  CdDecoder(const QString &file, DecoderFactory *d, AudioOutput *o);
32  ~CdDecoder() override;
33 
34  // Decoder implementation
35  bool initialize() override; // Decoder
36  void seek(double pos) override; // Decoder
37  void stop() override; // Decoder
38 
40 
41  // The following need to allocate a new MusicMetadata object each time,
42  // because their callers free the returned value
43  // TODO check this is still true
44  MusicMetadata *getMetadata(int track);
45 
46 #if CONFIG_DARWIN
47  double lengthInSeconds();
48 #endif
49  int getNumTracks();
50  int getNumCDAudioTracks();
51 
52  void setDevice(const QString &dev);
53  void setCDSpeed(int speed);
54 
55  private:
56  void run() override; // MThread
57 
58  void writeBlock();
59  void deinit();
60 
61  volatile bool m_inited {false};
62  volatile bool m_userStop {false};
63 
64  QString m_deviceName;
65 
66 #if CONFIG_DARWIN
67  void lookupCDDB(const QString &hexID, uint tracks);
68 
69  uint32_t m_diskID;
70  uint m_firstTrack,
71  m_lastTrack,
72  m_leadout;
73  double m_lengthInSecs;
74  vector<int> m_tracks;
75 #endif
76  static QMutex& getCdioMutex();
77 
78  DecoderEvent::Type m_stat {DecoderEvent::Error};
79  char *m_outputBuf {nullptr};
80  std::size_t m_outputAt {0};
81 
82  std::size_t m_bks {0};
83  std::size_t m_bksFrames {0};
84  std::size_t m_decodeBytes {0};
85  bool m_finish {false};
86  long m_freq {0};
87  long m_bitrate {0};
88  int m_chan {0};
89  double m_seekTime {-1.0};
90 
91  int m_setTrackNum {-1};
92  int m_trackNum {0};
93 
94 #ifdef HAVE_CDIO
95  CdIo_t *m_cdio {nullptr};
96  cdrom_drive_t *m_device {nullptr};
97  cdrom_paranoia_t *m_paranoia {nullptr};
98  lsn_t m_start {CDIO_INVALID_LSN};
99  lsn_t m_end {CDIO_INVALID_LSN};
100  lsn_t m_curPos {CDIO_INVALID_LSN};
101 #endif
102 };
103 
104 #endif
105 
CdDecoder::getMetadata
MusicMetadata * getMetadata(void)
Definition: cddecoder.cpp:501
CdDecoder::m_setTrackNum
int m_setTrackNum
Definition: cddecoder.h:91
CdDecoder::getCdioMutex
static QMutex & getCdioMutex()
Definition: cddecoder.cpp:141
CdDecoder::m_seekTime
double m_seekTime
Definition: cddecoder.h:89
CdDecoder::m_bitrate
long m_bitrate
Definition: cddecoder.h:87
CdDecoder::m_decodeBytes
std::size_t m_decodeBytes
Definition: cddecoder.h:84
CdDecoder::deinit
void deinit()
Definition: cddecoder.cpp:270
CdDecoder::writeBlock
void writeBlock()
Definition: cddecoder.cpp:123
DecoderEvent::Error
static Type Error
Definition: decoder.h:50
CdDecoder::initialize
bool initialize() override
Definition: cddecoder.cpp:148
MusicMetadata
Definition: musicmetadata.h:81
DecoderFactory
Definition: decoder.h:113
build_compdb.file
file
Definition: build_compdb.py:55
AudioOutput
Definition: audiooutput.h:26
CdDecoder::m_userStop
volatile bool m_userStop
Definition: cddecoder.h:62
Decoder
Definition: decoder.h:66
CdDecoder::seek
void seek(double pos) override
Definition: cddecoder.cpp:262
CdDecoder
Definition: cddecoder.h:27
CdDecoder::setCDSpeed
void setCDSpeed(int speed)
Definition: cddecoder.cpp:430
CdDecoder::m_outputAt
std::size_t m_outputAt
Definition: cddecoder.h:80
CdDecoder::m_bksFrames
std::size_t m_bksFrames
Definition: cddecoder.h:83
CdDecoder::m_inited
volatile bool m_inited
Definition: cddecoder.h:61
CdDecoder::m_freq
long m_freq
Definition: cddecoder.h:86
uint
unsigned int uint
Definition: compat.h:141
CdDecoder::~CdDecoder
~CdDecoder() override
Definition: cddecoder.cpp:100
CdDecoder::setDevice
void setDevice(const QString &dev)
Definition: cddecoder.cpp:106
CdDecoder::getNumTracks
int getNumTracks()
Definition: cddecoder.cpp:448
CdDecoder::CdDecoder
CdDecoder(const QString &file, DecoderFactory *d, AudioOutput *o)
Definition: cddecoder.cpp:93
CdDecoder::m_stat
DecoderEvent::Type m_stat
Definition: cddecoder.h:78
CdDecoder::getNumCDAudioTracks
int getNumCDAudioTracks()
Definition: cddecoder.cpp:466
CdDecoder::run
void run() override
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
Definition: cddecoder.cpp:294
CdDecoder::m_deviceName
QString m_deviceName
Definition: cddecoder.h:64
CdDecoder::m_bks
std::size_t m_bks
Definition: cddecoder.h:82
CdDecoder::Q_DECLARE_TR_FUNCTIONS
Q_DECLARE_TR_FUNCTIONS(CdDecoder)
CdDecoder::m_chan
int m_chan
Definition: cddecoder.h:88
d
static const iso6937table * d
Definition: iso6937tables.cpp:1025
CdDecoder::stop
void stop() override
Definition: cddecoder.cpp:117
CdDecoder::m_trackNum
int m_trackNum
Definition: cddecoder.h:92
CdDecoder::m_outputBuf
char * m_outputBuf
Definition: cddecoder.h:79
decoder.h
CdDecoder::m_finish
bool m_finish
Definition: cddecoder.h:85