From 1733c412a14f25ce49fa57c2a2277867fc0db035 Mon Sep 17 00:00:00 2001 From: asiviero Date: Sat, 11 Jan 2014 01:26:13 -0200 Subject: [PATCH] Ogg transcoding working, found a bug on wav2mp3 transcoding, UI integration needed --- src/ui/ripcd.cpp | 38 +++++++++++++++++++++++++++++++++----- src/ui/ripcd.h | 12 +++++++++--- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/src/ui/ripcd.cpp b/src/ui/ripcd.cpp index 6d672b8db..4d9844d7f 100644 --- a/src/ui/ripcd.cpp +++ b/src/ui/ripcd.cpp @@ -1,6 +1,8 @@ #include "ripcd.h" #include "config.h" #include "ui_ripcd.h" +#include "transcoder/transcoder.h" +#include #include #include #include @@ -20,15 +22,25 @@ #include #include +// winspool.h defines this :( +#ifdef AddJob +# undef AddJob +#endif RipCD::RipCD(QWidget* parent) : QDialog(parent), - transcoder_(new Transcoder(this)) + transcoder_(new Transcoder(this)), + queued_(0), + finished_success_(0), + finished_failed_(0) { // Init ui_.setupUi(this); connect(ui_.ripButton,SIGNAL(clicked()),this,SLOT(clickedRipButton())); + + connect(transcoder_, SIGNAL(JobComplete(QString,bool)), SLOT(JobComplete(QString,bool))); connect(transcoder_, SIGNAL(AllJobsComplete()), SLOT(AllJobsComplete())); + connect(this, SIGNAL(RippingComplete()), SLOT(threadedTranscoding())); setWindowTitle(tr("Rip CD")); @@ -53,6 +65,7 @@ RipCD::RipCD(QWidget* parent) void RipCD::clickedRipButton() { QtConcurrent::run(this,&RipCD::toThreadClickedRipButton); + } void RipCD::toThreadClickedRipButton() { @@ -62,6 +75,7 @@ void RipCD::toThreadClickedRipButton() { qDebug() << "Going for track " << i; lsn_t i_first_lsn = cdio_get_track_lsn(p_cdio,i); lsn_t i_last_lsn = cdio_get_track_last_lsn(p_cdio,i); +// lsn_t i_last_lsn = i_first_lsn+300; // debug lsn_t i_cursor; int16_t *p_readbuf = (int16_t *)calloc(CDIO_CD_FRAMESIZE_RAW,1); @@ -78,13 +92,23 @@ void RipCD::toThreadClickedRipButton() { } fclose(fp); - TranscoderPreset preset(Transcoder::PresetForFileType(Song::Type_Mpeg)); - transcoder_->AddJob(QString(source_directory + "track" + QString::number(i) + ".wav").toUtf8().constData(), preset); - // free(p_readbuf); p_readbuf = NULL; } + emit(RippingComplete()); +} + +void RipCD::threadedTranscoding() { + QString source_directory = "/tmp/"; + track_t i_tracks = cdio_get_num_tracks(p_cdio); + + TranscoderPreset preset(Transcoder::PresetForFileType(Song::Type_OggVorbis)); + for(int i=1; i <= i_tracks; i++) { + transcoder_->AddJob(QString(source_directory + "track" + QString::number(i) + ".wav").toUtf8().constData(), preset); + } + qDebug() << "Total jobs: " << transcoder_->QueuedJobsCount(); transcoder_->Start(); + } void RipCD::put_num(long int num, FILE *stream, int bytes) { @@ -121,7 +145,11 @@ void RipCD::AllJobsComplete() { qDebug() << "All Jobs Complete emmited"; // TODO Handle this properly // having a little trouble on wav files, works fine on mp3 - TagLib::FileRef f(QString("/tmp/track" + QString::number(1) + ".mp3").toUtf8().constData()); + TagLib::FileRef f(QString("/tmp/track" + QString::number(1) + ".ogg").toUtf8().constData()); f.tag()->setArtist("Queen"); f.save(); } + +void RipCD::JobComplete(const QString& filename, bool success) { + qDebug() << "Completed"; +} diff --git a/src/ui/ripcd.h b/src/ui/ripcd.h index 0bf9ff360..2a7916a50 100644 --- a/src/ui/ripcd.h +++ b/src/ui/ripcd.h @@ -14,7 +14,8 @@ #include #include #include "ui_ripcd.h" -#include "transcoder/transcoder.h" + +class Transcoder; class RipCD : public QDialog { @@ -33,9 +34,14 @@ private: CdIo_t *p_cdio; void write_WAV_header(FILE *stream,int32_t i_bytecount); void put_num(long int num, FILE *stream, int bytes); -private slots: - void clickedRipButton(); void toThreadClickedRipButton(); + +signals: + void RippingComplete(); +private slots: + void threadedTranscoding(); + void clickedRipButton(); + void JobComplete(const QString& filename, bool success); void AllJobsComplete(); };