From f5985fb20416d7bf90c0bb97b9f947d570548485 Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Sun, 3 Jan 2016 15:54:36 +0100 Subject: [PATCH] Implemented a better method to set the working directory for "tool" processes. --- src/Config.h | 8 ++++---- src/Decoder_ADPCM.cpp | 6 ++---- src/Decoder_Avisynth.cpp | 6 ++---- src/Encoder_AAC_FDK.cpp | 6 ++---- src/Encoder_AAC_QAAC.cpp | 6 ++---- src/Filter_Downmix.cpp | 6 ++---- src/Filter_Normalize.cpp | 6 ++---- src/Filter_Resample.cpp | 6 ++---- src/Filter_ToneAdjust.cpp | 6 ++---- src/Tool_Abstract.cpp | 6 +++--- src/Tool_Abstract.h | 4 ++-- 11 files changed, 25 insertions(+), 41 deletions(-) diff --git a/src/Config.h b/src/Config.h index 7998b392..eab8d8dc 100644 --- a/src/Config.h +++ b/src/Config.h @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////// // LameXP - Audio Encoder Front-End -// Copyright (C) 2004-2015 LoRd_MuldeR +// Copyright (C) 2004-2016 LoRd_MuldeR // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -32,10 +32,10 @@ #define VER_LAMEXP_MAJOR 4 #define VER_LAMEXP_MINOR_HI 1 -#define VER_LAMEXP_MINOR_LO 3 -#define VER_LAMEXP_TYPE Final +#define VER_LAMEXP_MINOR_LO 4 +#define VER_LAMEXP_TYPE Alpha #define VER_LAMEXP_PATCH 1 -#define VER_LAMEXP_BUILD 1852 +#define VER_LAMEXP_BUILD 1854 #define VER_LAMEXP_CONFG 1818 /////////////////////////////////////////////////////////////////////////////// diff --git a/src/Decoder_ADPCM.cpp b/src/Decoder_ADPCM.cpp index 58463048..edf025b2 100644 --- a/src/Decoder_ADPCM.cpp +++ b/src/Decoder_ADPCM.cpp @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////// // LameXP - Audio Encoder Front-End -// Copyright (C) 2004-2015 LoRd_MuldeR +// Copyright (C) 2004-2016 LoRd_MuldeR // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -52,14 +52,12 @@ bool ADPCMDecoder::decode(const QString &sourceFile, const QString &outputFile, QProcess process; QStringList args; - process.setWorkingDirectory(QFileInfo(outputFile).canonicalPath()); - args << "-V3" << "-S" << "--temp" << "."; args << QDir::toNativeSeparators(sourceFile); args << "-e" << "signed-integer"; args << QDir::toNativeSeparators(outputFile); - if(!startProcess(process, m_binary, args)) + if(!startProcess(process, m_binary, args, QFileInfo(outputFile).canonicalPath())) { return false; } diff --git a/src/Decoder_Avisynth.cpp b/src/Decoder_Avisynth.cpp index e72a52db..38302372 100644 --- a/src/Decoder_Avisynth.cpp +++ b/src/Decoder_Avisynth.cpp @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////// // LameXP - Audio Encoder Front-End -// Copyright (C) 2004-2015 LoRd_MuldeR +// Copyright (C) 2004-2016 LoRd_MuldeR // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -53,12 +53,10 @@ bool AvisynthDecoder::decode(const QString &sourceFile, const QString &outputFil QProcess process; QStringList args; - process.setWorkingDirectory(QFileInfo(outputFile).absolutePath()); - args << QDir::toNativeSeparators(sourceFile); args << QDir::toNativeSeparators(outputFile); - if(!startProcess(process, m_binary, args)) + if(!startProcess(process, m_binary, args, QFileInfo(outputFile).absolutePath())) { return false; } diff --git a/src/Encoder_AAC_FDK.cpp b/src/Encoder_AAC_FDK.cpp index 4513f426..cc4c4bb5 100644 --- a/src/Encoder_AAC_FDK.cpp +++ b/src/Encoder_AAC_FDK.cpp @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////// // LameXP - Audio Encoder Front-End -// Copyright (C) 2004-2015 LoRd_MuldeR +// Copyright (C) 2004-2016 LoRd_MuldeR // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -148,8 +148,6 @@ bool FDKAACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaI QProcess process; QStringList args; - process.setWorkingDirectory(QFileInfo(outputFile).canonicalPath()); - QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); env.insert("PATH", QDir::toNativeSeparators(QString("%1;%1/QTfiles;%2").arg(QDir(QCoreApplication::applicationDirPath()).canonicalPath(), MUtils::temp_folder()))); process.setProcessEnvironment(env); @@ -193,7 +191,7 @@ bool FDKAACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaI args << "-o" << QDir::toNativeSeparators(outputFile); args << QDir::toNativeSeparators(sourceFile); - if(!startProcess(process, m_binary, args)) + if(!startProcess(process, m_binary, args, QFileInfo(outputFile).canonicalPath())) { return false; } diff --git a/src/Encoder_AAC_QAAC.cpp b/src/Encoder_AAC_QAAC.cpp index 2bf7bcaf..b033d4f6 100644 --- a/src/Encoder_AAC_QAAC.cpp +++ b/src/Encoder_AAC_QAAC.cpp @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////// // LameXP - Audio Encoder Front-End -// Copyright (C) 2004-2015 LoRd_MuldeR +// Copyright (C) 2004-2016 LoRd_MuldeR // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -156,8 +156,6 @@ bool QAACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInf QProcess process; QStringList args; - process.setWorkingDirectory(QFileInfo(outputFile).canonicalPath()); - QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); env.insert("PATH", QDir::toNativeSeparators(QString("%1;%1/QTfiles;%2").arg(QDir(QCoreApplication::applicationDirPath()).canonicalPath(), MUtils::temp_folder()))); process.setProcessEnvironment(env); @@ -204,7 +202,7 @@ bool QAACEncoder::encode(const QString &sourceFile, const AudioFileModel_MetaInf args << "-o" << QDir::toNativeSeparators(outputFile); args << QDir::toNativeSeparators(sourceFile); - if(!startProcess(process, qaac_bin, args)) + if(!startProcess(process, qaac_bin, args, QFileInfo(outputFile).canonicalPath())) { return false; } diff --git a/src/Filter_Downmix.cpp b/src/Filter_Downmix.cpp index bb2211f9..29325e8b 100644 --- a/src/Filter_Downmix.cpp +++ b/src/Filter_Downmix.cpp @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////// // LameXP - Audio Encoder Front-End -// Copyright (C) 2004-2015 LoRd_MuldeR +// Copyright (C) 2004-2016 LoRd_MuldeR // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -64,8 +64,6 @@ bool DownmixFilter::apply(const QString &sourceFile, const QString &outputFile, QProcess process; QStringList args; - process.setWorkingDirectory(QFileInfo(outputFile).canonicalPath()); - args << "-V3" << "-S"; args << "--guard" << "--temp" << "."; args << QDir::toNativeSeparators(sourceFile); @@ -102,7 +100,7 @@ bool DownmixFilter::apply(const QString &sourceFile, const QString &outputFile, break; } - if(!startProcess(process, m_binary, args)) + if(!startProcess(process, m_binary, args, QFileInfo(outputFile).canonicalPath())) { return false; } diff --git a/src/Filter_Normalize.cpp b/src/Filter_Normalize.cpp index 2ca11c83..21c310a8 100644 --- a/src/Filter_Normalize.cpp +++ b/src/Filter_Normalize.cpp @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////// // LameXP - Audio Encoder Front-End -// Copyright (C) 2004-2015 LoRd_MuldeR +// Copyright (C) 2004-2016 LoRd_MuldeR // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -62,8 +62,6 @@ bool NormalizeFilter::apply(const QString &sourceFile, const QString &outputFile QProcess process; QStringList args; - process.setWorkingDirectory(QFileInfo(outputFile).canonicalPath()); - args << "-V3" << "-S"; args << "--temp" << "."; args << QDir::toNativeSeparators(sourceFile); @@ -86,7 +84,7 @@ bool NormalizeFilter::apply(const QString &sourceFile, const QString &outputFile } } - if(!startProcess(process, m_binary, args)) + if(!startProcess(process, m_binary, args, QFileInfo(outputFile).canonicalPath())) { return false; } diff --git a/src/Filter_Resample.cpp b/src/Filter_Resample.cpp index e208d3a4..6547ec96 100644 --- a/src/Filter_Resample.cpp +++ b/src/Filter_Resample.cpp @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////// // LameXP - Audio Encoder Front-End -// Copyright (C) 2004-2015 LoRd_MuldeR +// Copyright (C) 2004-2016 LoRd_MuldeR // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -73,8 +73,6 @@ bool ResampleFilter::apply(const QString &sourceFile, const QString &outputFile, return true; } - process.setWorkingDirectory(QFileInfo(outputFile).canonicalPath()); - args << "-V3" << "-S"; args << "--guard" << "--temp" << "."; args << QDir::toNativeSeparators(sourceFile); @@ -99,7 +97,7 @@ bool ResampleFilter::apply(const QString &sourceFile, const QString &outputFile, args << "dither" << "-s"; //if you're mastering to 16-bit, you also need to add 'dither' (and in most cases noise-shaping) after the rate } - if(!startProcess(process, m_binary, args)) + if(!startProcess(process, m_binary, args, QFileInfo(outputFile).canonicalPath())) { return false; } diff --git a/src/Filter_ToneAdjust.cpp b/src/Filter_ToneAdjust.cpp index 60ba67ea..99a1cfbd 100644 --- a/src/Filter_ToneAdjust.cpp +++ b/src/Filter_ToneAdjust.cpp @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////// // LameXP - Audio Encoder Front-End -// Copyright (C) 2004-2015 LoRd_MuldeR +// Copyright (C) 2004-2016 LoRd_MuldeR // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -56,8 +56,6 @@ bool ToneAdjustFilter::apply(const QString &sourceFile, const QString &outputFil QProcess process; QStringList args; - process.setWorkingDirectory(QFileInfo(outputFile).canonicalPath()); - args << "-V3" << "-S"; args << "--guard" << "--temp" << "."; args << QDir::toNativeSeparators(sourceFile); @@ -72,7 +70,7 @@ bool ToneAdjustFilter::apply(const QString &sourceFile, const QString &outputFil args << "treble" << QString().sprintf("%s%.2f", ((m_treble < 0) ? "-" : "+"), static_cast(abs(m_treble)) / 100.0); } - if(!startProcess(process, m_binary, args)) + if(!startProcess(process, m_binary, args, QFileInfo(outputFile).canonicalPath())) { return false; } diff --git a/src/Tool_Abstract.cpp b/src/Tool_Abstract.cpp index 8e2ac8ce..1498595d 100644 --- a/src/Tool_Abstract.cpp +++ b/src/Tool_Abstract.cpp @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////// // LameXP - Audio Encoder Front-End -// Copyright (C) 2004-2015 LoRd_MuldeR +// Copyright (C) 2004-2016 LoRd_MuldeR // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -102,7 +102,7 @@ AbstractTool::~AbstractTool(void) /* * Initialize and launch process object */ -bool AbstractTool::startProcess(QProcess &process, const QString &program, const QStringList &args) +bool AbstractTool::startProcess(QProcess &process, const QString &program, const QStringList &args, const QString &workingDir) { QMutexLocker lock(&s_startProcessMutex); @@ -119,7 +119,7 @@ bool AbstractTool::startProcess(QProcess &process, const QString &program, const } emit messageLogged(commandline2string(program, args) + "\n"); - MUtils::init_process(process, QFileInfo(program).absolutePath()); + MUtils::init_process(process, workingDir.isEmpty() ? QFileInfo(program).absolutePath() : workingDir); process.start(program, args); diff --git a/src/Tool_Abstract.h b/src/Tool_Abstract.h index b9a358eb..2ba64a58 100644 --- a/src/Tool_Abstract.h +++ b/src/Tool_Abstract.h @@ -1,6 +1,6 @@ /////////////////////////////////////////////////////////////////////////////// // LameXP - Audio Encoder Front-End -// Copyright (C) 2004-2015 LoRd_MuldeR +// Copyright (C) 2004-2016 LoRd_MuldeR // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -41,7 +41,7 @@ public: AbstractTool(void); ~AbstractTool(void); - bool startProcess(QProcess &process, const QString &program, const QStringList &args); + bool startProcess(QProcess &process, const QString &program, const QStringList &args, const QString &workingDir = QString()); static QString commandline2string(const QString &program, const QStringList &arguments); signals: