1
0
mirror of https://github.com/clementine-player/Clementine synced 2025-01-31 11:35:24 +01:00

Ogg transcoding working, found a bug on wav2mp3 transcoding, UI integration needed

This commit is contained in:
asiviero 2014-01-11 01:26:13 -02:00
parent 658767daea
commit 1733c412a1
2 changed files with 42 additions and 8 deletions

View File

@ -1,6 +1,8 @@
#include "ripcd.h" #include "ripcd.h"
#include "config.h" #include "config.h"
#include "ui_ripcd.h" #include "ui_ripcd.h"
#include "transcoder/transcoder.h"
#include <QSettings>
#include <QCheckBox> #include <QCheckBox>
#include <QFrame> #include <QFrame>
#include <QLineEdit> #include <QLineEdit>
@ -20,15 +22,25 @@
#include <tstring.h> #include <tstring.h>
#include <tstringlist.h> #include <tstringlist.h>
// winspool.h defines this :(
#ifdef AddJob
# undef AddJob
#endif
RipCD::RipCD(QWidget* parent) RipCD::RipCD(QWidget* parent)
: QDialog(parent), : QDialog(parent),
transcoder_(new Transcoder(this)) transcoder_(new Transcoder(this)),
queued_(0),
finished_success_(0),
finished_failed_(0)
{ {
// Init // Init
ui_.setupUi(this); ui_.setupUi(this);
connect(ui_.ripButton,SIGNAL(clicked()),this,SLOT(clickedRipButton())); 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(transcoder_, SIGNAL(AllJobsComplete()), SLOT(AllJobsComplete()));
connect(this, SIGNAL(RippingComplete()), SLOT(threadedTranscoding()));
setWindowTitle(tr("Rip CD")); setWindowTitle(tr("Rip CD"));
@ -53,6 +65,7 @@ RipCD::RipCD(QWidget* parent)
void RipCD::clickedRipButton() { void RipCD::clickedRipButton() {
QtConcurrent::run(this,&RipCD::toThreadClickedRipButton); QtConcurrent::run(this,&RipCD::toThreadClickedRipButton);
} }
void RipCD::toThreadClickedRipButton() { void RipCD::toThreadClickedRipButton() {
@ -62,6 +75,7 @@ void RipCD::toThreadClickedRipButton() {
qDebug() << "Going for track " << i; qDebug() << "Going for track " << i;
lsn_t i_first_lsn = cdio_get_track_lsn(p_cdio,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 = cdio_get_track_last_lsn(p_cdio,i);
// lsn_t i_last_lsn = i_first_lsn+300; // debug
lsn_t i_cursor; lsn_t i_cursor;
int16_t *p_readbuf = (int16_t *)calloc(CDIO_CD_FRAMESIZE_RAW,1); int16_t *p_readbuf = (int16_t *)calloc(CDIO_CD_FRAMESIZE_RAW,1);
@ -78,13 +92,23 @@ void RipCD::toThreadClickedRipButton() {
} }
fclose(fp); 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); free(p_readbuf);
p_readbuf = NULL; 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(); transcoder_->Start();
} }
void RipCD::put_num(long int num, FILE *stream, int bytes) { void RipCD::put_num(long int num, FILE *stream, int bytes) {
@ -121,7 +145,11 @@ void RipCD::AllJobsComplete() {
qDebug() << "All Jobs Complete emmited"; qDebug() << "All Jobs Complete emmited";
// TODO Handle this properly // TODO Handle this properly
// having a little trouble on wav files, works fine on mp3 // 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.tag()->setArtist("Queen");
f.save(); f.save();
} }
void RipCD::JobComplete(const QString& filename, bool success) {
qDebug() << "Completed";
}

View File

@ -14,7 +14,8 @@
#include <QThread> #include <QThread>
#include <cdio/cdio.h> #include <cdio/cdio.h>
#include "ui_ripcd.h" #include "ui_ripcd.h"
#include "transcoder/transcoder.h"
class Transcoder;
class RipCD : public QDialog class RipCD : public QDialog
{ {
@ -33,9 +34,14 @@ private:
CdIo_t *p_cdio; CdIo_t *p_cdio;
void write_WAV_header(FILE *stream,int32_t i_bytecount); void write_WAV_header(FILE *stream,int32_t i_bytecount);
void put_num(long int num, FILE *stream, int bytes); void put_num(long int num, FILE *stream, int bytes);
private slots:
void clickedRipButton();
void toThreadClickedRipButton(); void toThreadClickedRipButton();
signals:
void RippingComplete();
private slots:
void threadedTranscoding();
void clickedRipButton();
void JobComplete(const QString& filename, bool success);
void AllJobsComplete(); void AllJobsComplete();
}; };