{
QString baseName = QFileInfo(m_cueFileName).completeBaseName().replace(".", " ").simplified();
- WorkingBanner *progress = new WorkingBanner(this);
- CueSplitter *splitter = new CueSplitter(m_outputDir, baseName, m_model, m_fileInfo);
+ QScopedPointer<WorkingBanner> progress(new WorkingBanner(this));
+ QScopedPointer<CueSplitter> splitter(new CueSplitter(m_outputDir, baseName, m_model, m_fileInfo));
- connect(splitter, SIGNAL(fileSelected(QString)), progress, SLOT(setText(QString)), Qt::QueuedConnection);
- connect(splitter, SIGNAL(fileSplit(AudioFileModel)), m_fileList, SLOT(addFile(AudioFileModel)), Qt::QueuedConnection);
- connect(splitter, SIGNAL(progressValChanged(unsigned int)), progress, SLOT(setProgressVal(unsigned int)), Qt::QueuedConnection);
- connect(splitter, SIGNAL(progressMaxChanged(unsigned int)), progress, SLOT(setProgressMax(unsigned int)), Qt::QueuedConnection);
- connect(progress, SIGNAL(userAbort()), splitter, SLOT(abortProcess()), Qt::DirectConnection);
+ connect(splitter.data(), SIGNAL(fileSelected(QString)), progress.data(), SLOT(setText(QString)), Qt::QueuedConnection);
+ connect(splitter.data(), SIGNAL(fileSplit(AudioFileModel)), m_fileList, SLOT(addFile(AudioFileModel)), Qt::QueuedConnection);
+ connect(splitter.data(), SIGNAL(progressValChanged(unsigned int)), progress.data(), SLOT(setProgressVal(unsigned int)), Qt::QueuedConnection);
+ connect(splitter.data(), SIGNAL(progressMaxChanged(unsigned int)), progress.data(), SLOT(setProgressMax(unsigned int)), Qt::QueuedConnection);
+ connect(progress.data(), SIGNAL(userAbort()), splitter.data(), SLOT(abortProcess()), Qt::DirectConnection);
DecoderRegistry::configureDecoders(m_settings);
- progress->show(tr("Splitting file(s), please wait..."), splitter);
+ progress->show(tr("Splitting file(s), please wait..."), splitter.data());
progress->close();
if(splitter->getAborted())
QString text = QString("<nobr>%1 %2</nobr>").arg(tr("Imported %n track(s) from the Cue Sheet.", "", splitter->getTracksSuccess()), tr("Skipped %n track(s).", "", splitter->getTracksSkipped()));
QMessageBox::information(this, tr("Cue Sheet Completed"), text);
}
-
- MUTILS_DELETE(splitter);
- MUTILS_DELETE(progress);
}
QProcess process;
MUtils::init_process(process, m_outputDir);
+ qDebug("SoX args: \"%s\"", MUTILS_UTF8(args.join(QLatin1String("\", \""))));
process.start(m_soxBin, args);
if(!process.waitForStarted())
while(process.bytesAvailable() > 0)
{
QByteArray line = process.readLine();
- QString text = QString::fromUtf8(line.constData()).simplified();
- if(rxProgress.lastIndexIn(text) >= 0)
+ if (line.size() > 0)
{
- bool ok = false;
- int progress = rxProgress.cap(1).toInt(&ok);
- if(ok)
+ QString text = QString::fromUtf8(line.constData()).simplified();
+ if (!text.isEmpty())
{
- const int newProgress = baseProgress + qRound(static_cast<double>(qBound(0, progress, 100)) / 10.0);
- if(newProgress > prevProgress)
+ if (rxProgress.lastIndexIn(text) >= 0)
{
- emit progressValChanged(newProgress);
- prevProgress = newProgress;
+ int progress;
+ if (MUtils::regexp_parse_int32(rxProgress, progress))
+ {
+ const int newProgress = baseProgress + qRound(static_cast<double>(qBound(0, progress, 100)) / 10.0);
+ if (newProgress > prevProgress)
+ {
+ emit progressValChanged(newProgress);
+ prevProgress = newProgress;
+ }
+ }
}
- }
- }
- else if(rxChannels.lastIndexIn(text) >= 0)
- {
- bool ok = false;
- unsigned int channels = rxChannels.cap(1).toUInt(&ok);
- if(ok) outFileInfo.techInfo().setAudioChannels(channels);
- }
- else if(rxSamplerate.lastIndexIn(text) >= 0)
- {
- bool ok = false;
- unsigned int samplerate = rxSamplerate.cap(1).toUInt(&ok);
- if(ok) outFileInfo.techInfo().setAudioSamplerate(samplerate);
- }
- else if(rxPrecision.lastIndexIn(text) >= 0)
- {
- bool ok = false;
- unsigned int precision = rxPrecision.cap(1).toUInt(&ok);
- if(ok) outFileInfo.techInfo().setAudioBitdepth(precision);
- }
- else if(rxDuration.lastIndexIn(text) >= 0)
- {
- bool ok1 = false, ok2 = false, ok3 = false;
- unsigned int hh = rxDuration.cap(1).toUInt(&ok1);
- unsigned int mm = rxDuration.cap(2).toUInt(&ok2);
- unsigned int ss = rxDuration.cap(3).toUInt(&ok3);
- if(ok1 && ok2 && ok3)
- {
- unsigned intputLen = (hh * 3600) + (mm * 60) + ss;
- if(length == std::numeric_limits<double>::infinity())
+ else if (rxChannels.lastIndexIn(text) >= 0)
+ {
+ unsigned int channels;
+ if (MUtils::regexp_parse_uint32(rxChannels, channels))
+ {
+ outFileInfo.techInfo().setAudioChannels(channels);
+ }
+ }
+ else if (rxSamplerate.lastIndexIn(text) >= 0)
+ {
+ unsigned int samplerate;
+ if (MUtils::regexp_parse_uint32(rxSamplerate, samplerate))
+ {
+ outFileInfo.techInfo().setAudioSamplerate(samplerate);
+ }
+ }
+ else if (rxPrecision.lastIndexIn(text) >= 0)
+ {
+ unsigned int precision;
+ if (MUtils::regexp_parse_uint32(rxPrecision, precision))
+ {
+ outFileInfo.techInfo().setAudioBitdepth(precision);
+ }
+ }
+ else if (rxDuration.lastIndexIn(text) >= 0)
{
- qDebug("Duration updated from SoX info!");
- int duration = intputLen - static_cast<int>(floor(offset + 0.5));
- if(duration < 0) qWarning("Track is out of bounds: Track offset exceeds input file duration!");
- outFileInfo.techInfo().setDuration(qMax(0, duration));
+ unsigned int duration[3U];
+ if (MUtils::regexp_parse_uint32(rxDuration, duration, 3U))
+ {
+ unsigned intputLen = (duration[0U] * 3600) + (duration[1U] * 60) + duration[2U];
+ if (length == std::numeric_limits<double>::infinity())
+ {
+ qDebug("Duration updated from SoX info!");
+ int duration = intputLen - static_cast<int>(floor(offset + 0.5));
+ if (duration < 0)
+ {
+ qWarning("Track is out of bounds: Track offset exceeds input file duration!");
+ }
+ outFileInfo.techInfo().setDuration(qMax(0, duration));
+ }
+ else
+ {
+ unsigned int trackEnd = static_cast<unsigned int>(floor(offset + 0.5)) + static_cast<unsigned int>(floor(length + 0.5));
+ if (trackEnd > intputLen) qWarning("Track is out of bounds: End of track exceeds input file duration!");
+ }
+ }
}
else
{
- unsigned int trackEnd = static_cast<unsigned int>(floor(offset + 0.5)) + static_cast<unsigned int>(floor(length + 0.5));
- if(trackEnd > intputLen) qWarning("Track is out of bounds: End of track exceeds input file duration!");
+ qDebug("SoX line: %s", MUTILS_UTF8(text));
}
}
}
process.waitForFinished(-1);
}
+ qDebug("SoX exit code: %d", process.exitCode());
if(process.exitCode() != EXIT_SUCCESS || QFileInfo(output).size() == 0)
{
qWarning("Splitting has failed !!!");