mirror of
https://github.com/clementine-player/Clementine
synced 2024-12-17 20:09:50 +01:00
Swapped non const reference for pointer, used qdata_stream writeRawData to write to file, removed unnecessary intializers
This commit is contained in:
parent
97129ec3c0
commit
2859d826ae
@ -21,6 +21,7 @@
|
|||||||
#include "transcoder/transcoder.h"
|
#include "transcoder/transcoder.h"
|
||||||
#include "transcoder/transcoderoptionsdialog.h"
|
#include "transcoder/transcoderoptionsdialog.h"
|
||||||
#include "ui/iconloader.h"
|
#include "ui/iconloader.h"
|
||||||
|
#include "core/logging.h"
|
||||||
|
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
@ -70,11 +71,7 @@ RipCD::RipCD(QWidget* parent) :
|
|||||||
queued_(0),
|
queued_(0),
|
||||||
finished_success_(0),
|
finished_success_(0),
|
||||||
finished_failed_(0),
|
finished_failed_(0),
|
||||||
ui_(new Ui_RipCD()),
|
ui_(new Ui_RipCD)
|
||||||
checkboxes_(QList<QCheckBox*>()),
|
|
||||||
generated_files_(QList<QString>()),
|
|
||||||
tracks_to_rip_(QList<int>()),
|
|
||||||
track_names_(QList<QLineEdit*>())
|
|
||||||
{
|
{
|
||||||
// Init
|
// Init
|
||||||
ui_->setupUi(this);
|
ui_->setupUi(this);
|
||||||
@ -100,8 +97,8 @@ RipCD::RipCD(QWidget* parent) :
|
|||||||
ui_->tableWidget->setRowCount(i_tracks);
|
ui_->tableWidget->setRowCount(i_tracks);
|
||||||
|
|
||||||
for (int i = 1; i <= i_tracks; i++) {
|
for (int i = 1; i <= i_tracks; i++) {
|
||||||
QCheckBox *checkbox_i = new QCheckBox(tr(""), ui_->tableWidget);
|
QCheckBox *checkbox_i = new QCheckBox(ui_->tableWidget);
|
||||||
checkbox_i->click();
|
checkbox_i->setCheckState(Qt::Checked);
|
||||||
checkboxes_.append(checkbox_i);
|
checkboxes_.append(checkbox_i);
|
||||||
ui_->tableWidget->setCellWidget(i - 1, kCheckboxColumn, checkbox_i);
|
ui_->tableWidget->setCellWidget(i - 1, kCheckboxColumn, checkbox_i);
|
||||||
ui_->tableWidget->setCellWidget(i - 1, kTrackNumberColumn, new QLabel(QString::number(i)));
|
ui_->tableWidget->setCellWidget(i - 1, kTrackNumberColumn, new QLabel(QString::number(i)));
|
||||||
@ -162,22 +159,22 @@ RipCD::RipCD(QWidget* parent) :
|
|||||||
* | Marks the beginning of the data section.
|
* | Marks the beginning of the data section.
|
||||||
* 41-44 | File size (data) | Size of the data section.
|
* 41-44 | File size (data) | Size of the data section.
|
||||||
*/
|
*/
|
||||||
void RipCD::WriteWAVHeader(QFile &stream, int32_t i_bytecount) {
|
void RipCD::WriteWAVHeader(QFile *stream, int32_t i_bytecount) {
|
||||||
QDataStream data_stream(&stream);
|
QDataStream data_stream(stream);
|
||||||
data_stream.setByteOrder(QDataStream::LittleEndian);
|
data_stream.setByteOrder(QDataStream::LittleEndian);
|
||||||
stream.write(kWavHeaderRiffMarker); /* 0-3 */
|
// sizeof() - 1 to avoid including "\0" in the file too
|
||||||
data_stream << qint32(i_bytecount + 44 - 8);
|
data_stream.writeRawData(kWavHeaderRiffMarker,sizeof(kWavHeaderRiffMarker)-1); /* 0-3 */
|
||||||
//PutNum(i_bytecount + 44 - 8, stream, 4); /* 4-7 */
|
data_stream << qint32(i_bytecount + 44 - 8); /* 4-7 */
|
||||||
stream.write(kWavFileTypeFormatChunk); /* 8-15 */
|
data_stream.writeRawData(kWavFileTypeFormatChunk,sizeof(kWavFileTypeFormatChunk)-1); /* 8-15 */
|
||||||
data_stream << (qint32)16; /* 16-19 */
|
data_stream << (qint32)16; /* 16-19 */
|
||||||
data_stream << (qint16)1; /* 20-21 */
|
data_stream << (qint16)1; /* 20-21 */
|
||||||
data_stream << (qint16)2; /* 22-23 */
|
data_stream << (qint16)2; /* 22-23 */
|
||||||
data_stream << (qint32)44100; /* 24-27 */
|
data_stream << (qint32)44100; /* 24-27 */
|
||||||
data_stream << (qint32)(44100 * 2 * 2); /* 28-31 */
|
data_stream << (qint32)(44100 * 2 * 2); /* 28-31 */
|
||||||
data_stream << (qint16)4; /* 32-33 */
|
data_stream << (qint16)4; /* 32-33 */
|
||||||
data_stream << (qint16)16; /* 34-35 */
|
data_stream << (qint16)16; /* 34-35 */
|
||||||
stream.write(kWavDataString); /* 36-39 */
|
data_stream.writeRawData(kWavDataString,sizeof(kWavDataString)-1); /* 36-39 */
|
||||||
data_stream << (qint32)i_bytecount; /* 40-43 */
|
data_stream << (qint32)i_bytecount; /* 40-43 */
|
||||||
}
|
}
|
||||||
|
|
||||||
int RipCD::NumTracksToRip() {
|
int RipCD::NumTracksToRip() {
|
||||||
@ -191,6 +188,7 @@ int RipCD::NumTracksToRip() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RipCD::ThreadClickedRipButton() {
|
void RipCD::ThreadClickedRipButton() {
|
||||||
|
|
||||||
QString source_directory = QDir::tempPath() + "/";
|
QString source_directory = QDir::tempPath() + "/";
|
||||||
|
|
||||||
finished_success_ = 0;
|
finished_success_ = 0;
|
||||||
@ -209,8 +207,8 @@ void RipCD::ThreadClickedRipButton() {
|
|||||||
|
|
||||||
QString filename = source_directory
|
QString filename = source_directory
|
||||||
+ ParseFileFormatString(ui_->format_filename->text(), i) + ".wav";
|
+ ParseFileFormatString(ui_->format_filename->text(), i) + ".wav";
|
||||||
QFile destination_file(filename);
|
QFile *destination_file = new QFile(filename);
|
||||||
destination_file.open(QIODevice::WriteOnly);
|
destination_file->open(QIODevice::WriteOnly);
|
||||||
|
|
||||||
lsn_t i_first_lsn = cdio_get_track_lsn(cdio_, i);
|
lsn_t i_first_lsn = cdio_get_track_lsn(cdio_, i);
|
||||||
lsn_t i_last_lsn = cdio_get_track_last_lsn(cdio_, i);
|
lsn_t i_last_lsn = cdio_get_track_last_lsn(cdio_, i);
|
||||||
@ -220,15 +218,14 @@ 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(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 {
|
||||||
qDebug() << "Read error. Stopping.";
|
qLog(Error) << "CD read error";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finished_success_++;
|
finished_success_++;
|
||||||
emit(SignalUpdateProgress());
|
emit(SignalUpdateProgress());
|
||||||
destination_file.close();
|
|
||||||
TranscoderPreset preset =
|
TranscoderPreset preset =
|
||||||
ui_->format->itemData(ui_->format->currentIndex())
|
ui_->format->itemData(ui_->format->currentIndex())
|
||||||
.value<TranscoderPreset>();
|
.value<TranscoderPreset>();
|
||||||
|
@ -54,7 +54,7 @@ class RipCD: public QDialog {
|
|||||||
QString last_add_dir_;
|
QString last_add_dir_;
|
||||||
QPushButton* cancel_button_;
|
QPushButton* cancel_button_;
|
||||||
|
|
||||||
void WriteWAVHeader(QFile& stream, int32_t i_bytecount);
|
void WriteWAVHeader(QFile *stream, int32_t i_bytecount);
|
||||||
int NumTracksToRip();
|
int NumTracksToRip();
|
||||||
void ThreadClickedRipButton();
|
void ThreadClickedRipButton();
|
||||||
QString TrimPath(const QString& path) const;
|
QString TrimPath(const QString& path) const;
|
||||||
|
Loading…
Reference in New Issue
Block a user