Add the ability to cancel a running CD rip.
This commit is contained in:
parent
ddda13ceb7
commit
1b00e91fdf
|
@ -254,6 +254,10 @@ void RipCD::ThreadClickedRipButton() {
|
||||||
|
|
||||||
QByteArray buffered_input_bytes(CDIO_CD_FRAMESIZE_RAW,'\0');
|
QByteArray buffered_input_bytes(CDIO_CD_FRAMESIZE_RAW,'\0');
|
||||||
for (lsn_t i_cursor = i_first_lsn; i_cursor <= i_last_lsn; i_cursor++) {
|
for (lsn_t i_cursor = i_first_lsn; i_cursor <= i_last_lsn; i_cursor++) {
|
||||||
|
if (cancel_requested_) {
|
||||||
|
qLog(Debug) << "CD ripping canceled.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
if(cdio_read_audio_sector(cdio_, buffered_input_bytes.data(), i_cursor) == DRIVER_OP_SUCCESS) {
|
if(cdio_read_audio_sector(cdio_, buffered_input_bytes.data(), i_cursor) == DRIVER_OP_SUCCESS) {
|
||||||
destination_file->write(buffered_input_bytes.data(), buffered_input_bytes.size());
|
destination_file->write(buffered_input_bytes.data(), buffered_input_bytes.size());
|
||||||
} else {
|
} else {
|
||||||
|
@ -328,6 +332,7 @@ void RipCD::ThreadedTranscoding() {
|
||||||
|
|
||||||
void RipCD::ClickedRipButton() {
|
void RipCD::ClickedRipButton() {
|
||||||
SetWorking(true);
|
SetWorking(true);
|
||||||
|
cancel_requested_ = false;
|
||||||
QtConcurrent::run(this, &RipCD::ThreadClickedRipButton);
|
QtConcurrent::run(this, &RipCD::ThreadClickedRipButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -413,6 +418,7 @@ void RipCD::AddDestinationDirectory(QString dir) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void RipCD::Cancel() {
|
void RipCD::Cancel() {
|
||||||
|
cancel_requested_ = true;
|
||||||
transcoder_->Cancel();
|
transcoder_->Cancel();
|
||||||
RemoveTemporaryDirectory();
|
RemoveTemporaryDirectory();
|
||||||
SetWorking(false);
|
SetWorking(false);
|
||||||
|
|
|
@ -58,6 +58,7 @@ class RipCD: public QDialog {
|
||||||
QPushButton* close_button_;
|
QPushButton* close_button_;
|
||||||
QPushButton* rip_button_;
|
QPushButton* rip_button_;
|
||||||
QString temporary_directory_;
|
QString temporary_directory_;
|
||||||
|
bool cancel_requested_;
|
||||||
|
|
||||||
void WriteWAVHeader(QFile *stream, int32_t i_bytecount);
|
void WriteWAVHeader(QFile *stream, int32_t i_bytecount);
|
||||||
int NumTracksToRip();
|
int NumTracksToRip();
|
||||||
|
|
Loading…
Reference in New Issue