mirror of
https://github.com/clementine-player/Clementine
synced 2024-12-17 12:02:48 +01:00
Assorted edits to the ripper class.
- The constructor of the AlbumInformation struct now takes no arguments. - Only add tracks to the rip list if their track numbers are valid. - Only call cdio_get_media_changed if we have a valid cdio_ object. - Add a description of the ripper class.
This commit is contained in:
parent
fc2e4db229
commit
eed0c0d45f
@ -60,6 +60,10 @@ Ripper::~Ripper() { cdio_destroy(cdio_); }
|
|||||||
void Ripper::AddTrack(int track_number, const QString& title,
|
void Ripper::AddTrack(int track_number, const QString& title,
|
||||||
const QString& transcoded_filename,
|
const QString& transcoded_filename,
|
||||||
const TranscoderPreset& preset) {
|
const TranscoderPreset& preset) {
|
||||||
|
if (track_number < 1 || track_number > TracksOnDisc()) {
|
||||||
|
qLog(Warning) << "Invalid track number:" << track_number << "Ignoring";
|
||||||
|
return;
|
||||||
|
}
|
||||||
TrackInformation track(track_number, title, transcoded_filename, preset);
|
TrackInformation track(track_number, title, transcoded_filename, preset);
|
||||||
tracks_.append(track);
|
tracks_.append(track);
|
||||||
}
|
}
|
||||||
@ -67,7 +71,12 @@ void Ripper::AddTrack(int track_number, const QString& title,
|
|||||||
void Ripper::SetAlbumInformation(const QString& album, const QString& artist,
|
void Ripper::SetAlbumInformation(const QString& album, const QString& artist,
|
||||||
const QString& genre, int year, int disc,
|
const QString& genre, int year, int disc,
|
||||||
Song::FileType type) {
|
Song::FileType type) {
|
||||||
album_ = AlbumInformation(album, artist, genre, year, disc, type);
|
album_.album = album;
|
||||||
|
album_.artist = artist;
|
||||||
|
album_.genre = genre;
|
||||||
|
album_.year = year;
|
||||||
|
album_.disc = disc;
|
||||||
|
album_.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Ripper::TracksOnDisc() const {
|
int Ripper::TracksOnDisc() const {
|
||||||
@ -88,7 +97,9 @@ bool Ripper::CheckCDIOIsValid() {
|
|||||||
cdio_ = cdio_open(NULL, DRIVER_UNKNOWN);
|
cdio_ = cdio_open(NULL, DRIVER_UNKNOWN);
|
||||||
// Refresh the status of the cd media. This will prevent unnecessary
|
// Refresh the status of the cd media. This will prevent unnecessary
|
||||||
// rebuilds of the track list table.
|
// rebuilds of the track list table.
|
||||||
|
if (cdio_) {
|
||||||
cdio_get_media_changed(cdio_);
|
cdio_get_media_changed(cdio_);
|
||||||
|
}
|
||||||
return cdio_;
|
return cdio_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,22 +28,40 @@
|
|||||||
|
|
||||||
class QFile;
|
class QFile;
|
||||||
|
|
||||||
|
// Rips selected tracks from an audio CD, transcodes them to a chosen
|
||||||
|
// format, and finally tags the files with the supplied metadata.
|
||||||
|
//
|
||||||
|
// Usage: Add tracks with AddTrack() and album metadata with
|
||||||
|
// SetAlbumInformation(). Then start the ripper with Start(). The ripper
|
||||||
|
// emits the Finished() signal when it's done or the Cancelled()
|
||||||
|
// signal if the ripping has been cancelled.
|
||||||
class Ripper : public QObject {
|
class Ripper : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Ripper(QObject* parent = nullptr);
|
explicit Ripper(QObject* parent = nullptr);
|
||||||
~Ripper();
|
~Ripper();
|
||||||
|
|
||||||
|
// Adds a track to the rip list if the track number corresponds to a
|
||||||
|
// track on the audio cd. The track will transcoded according to the
|
||||||
|
// chosen TranscoderPreset.
|
||||||
void AddTrack(int track_number, const QString& title,
|
void AddTrack(int track_number, const QString& title,
|
||||||
const QString& transcoded_filename,
|
const QString& transcoded_filename,
|
||||||
const TranscoderPreset& preset);
|
const TranscoderPreset& preset);
|
||||||
|
// Sets album metadata. This information is used when tagging the
|
||||||
|
// final files.
|
||||||
void SetAlbumInformation(const QString& album, const QString& artist,
|
void SetAlbumInformation(const QString& album, const QString& artist,
|
||||||
const QString& genre, int year, int disc,
|
const QString& genre, int year, int disc,
|
||||||
Song::FileType type);
|
Song::FileType type);
|
||||||
|
// Returns the number of audio tracks on the disc.
|
||||||
int TracksOnDisc() const;
|
int TracksOnDisc() const;
|
||||||
|
// Returns the number of tracks added to the rip list.
|
||||||
int AddedTracks() const;
|
int AddedTracks() const;
|
||||||
|
// Clears the rip list.
|
||||||
void ClearTracks();
|
void ClearTracks();
|
||||||
|
// Returns true if a cd device was successfully opened.
|
||||||
bool CheckCDIOIsValid();
|
bool CheckCDIOIsValid();
|
||||||
|
// Returns true if the cd media has changed.
|
||||||
bool MediaChanged() const;
|
bool MediaChanged() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
@ -81,16 +99,7 @@ signals:
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct AlbumInformation {
|
struct AlbumInformation {
|
||||||
AlbumInformation(const QString& album = QString(),
|
AlbumInformation() : year(0), disc(0), type(Song::Type_Unknown) {}
|
||||||
const QString& artist = QString(),
|
|
||||||
const QString& genre = QString(), int year = 0,
|
|
||||||
int disc = 0, Song::FileType type = Song::Type_Unknown)
|
|
||||||
: album(album),
|
|
||||||
artist(artist),
|
|
||||||
genre(genre),
|
|
||||||
year(year),
|
|
||||||
disc(disc),
|
|
||||||
type(type) {}
|
|
||||||
|
|
||||||
QString album;
|
QString album;
|
||||||
QString artist;
|
QString artist;
|
||||||
|
Loading…
Reference in New Issue
Block a user