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 *, AudioOutput *);
32  virtual ~CdDecoder();
33 
34  // Decoder implementation
35  bool initialize() override; // Decoder
36  void seek(double) 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_user_stop {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_output_buf {nullptr};
80  std::size_t m_output_at {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 
void deinit()
Definition: cddecoder.cpp:272
void stop() override
Definition: cddecoder.cpp:118
void setCDSpeed(int speed)
Definition: cddecoder.cpp:432
std::size_t m_output_at
Definition: cddecoder.h:80
double m_seekTime
Definition: cddecoder.h:89
virtual ~CdDecoder()
Definition: cddecoder.cpp:101
int getNumTracks()
Definition: cddecoder.cpp:450
volatile bool m_inited
Definition: cddecoder.h:61
std::size_t m_decodeBytes
Definition: cddecoder.h:84
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:296
unsigned int uint
Definition: compat.h:140
std::size_t m_bks
Definition: cddecoder.h:82
MusicMetadata * getMetadata(void)
Definition: cddecoder.cpp:538
void writeBlock()
Definition: cddecoder.cpp:124
std::size_t m_bksFrames
Definition: cddecoder.h:83
volatile bool m_user_stop
Definition: cddecoder.h:62
int m_chan
Definition: cddecoder.h:88
static QMutex & getCdioMutex()
Definition: cddecoder.cpp:143
CdDecoder(const QString &file, DecoderFactory *, AudioOutput *)
Definition: cddecoder.cpp:94
static Type Error
Definition: decoder.h:50
Q_DECLARE_TR_FUNCTIONS(CdDecoder)
void setDevice(const QString &dev)
Definition: cddecoder.cpp:107
char * m_output_buf
Definition: cddecoder.h:79
void seek(double) override
Definition: cddecoder.cpp:264
long m_bitrate
Definition: cddecoder.h:87
DecoderEvent::Type m_stat
Definition: cddecoder.h:78
int m_tracknum
Definition: cddecoder.h:92
long m_freq
Definition: cddecoder.h:86
bool m_finish
Definition: cddecoder.h:85
bool initialize() override
Definition: cddecoder.cpp:150
int m_settracknum
Definition: cddecoder.h:91
int getNumCDAudioTracks()
Definition: cddecoder.cpp:468
QString m_devicename
Definition: cddecoder.h:64