Guest User

qtgain skip flac patch

a guest
Nov 16th, 2014
164
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --- a/src/QtGain.cpp
  2. +++ b/src/QtGain.cpp
  3. @@ -270,7 +270,13 @@ void QtGain::processFiles_TrackGain(){
  4.      }
  5.  
  6.      // Check output of replay gain tools
  7. -    processOutput();
  8. +    if (this->m_lastFileSkipped) {
  9. +        addSkippedFiles();
  10. +        if (isLogSkippedFiles()) addToErrorlog(tr("<font color='green'>File already gained -> skipped</font> :: %1<br>").arg(currentFileName()));
  11. +    } else {
  12. +        processOutput();
  13. +    }
  14. +    this->m_lastFileSkipped = false;
  15.  
  16.      if (finishedFiles() < allFiles.size()){
  17.  
  18. @@ -305,8 +311,17 @@ void QtGain::processFiles_TrackGain(){
  19.          // FLAC
  20.          else if (allFiles[finishedFiles()].endsWith(".flac", Qt::CaseInsensitive)){
  21.              ui.FileFormatIcon->setPixmap(QPixmap(":/Icons/flac.png"));
  22. -            Parameter << "--add-replay-gain" << allFiles[finishedFiles()];
  23. -            TrackGainProcess->start(FlacGainBinaryPath(), Parameter);
  24. +            // Check if flac file is already gained, metaflac does not do this by itself
  25. +            QProcess checkProcess;
  26. +            checkProcess.start(FlacGainBinaryPath(), QStringList() << "--show-tag" << "REPLAYGAIN_TRACK_GAIN" << allFiles[finishedFiles()]);
  27. +            checkProcess.waitForFinished();
  28. +            QString output(checkProcess.readAllStandardOutput());
  29. +            if (output.contains("REPLAYGAIN_TRACK_GAIN=")) {
  30. +                this->m_lastFileSkipped = true;
  31. +            } else {
  32. +                Parameter << "--add-replay-gain" << allFiles[finishedFiles()];
  33. +                TrackGainProcess->start(FlacGainBinaryPath(), Parameter);
  34. +            }
  35.          }
  36.      }
  37.  
  38. @@ -347,6 +362,8 @@ void QtGain::processFiles_TrackGain(){
  39.      else {
  40.          setCurrentFileName(allFiles[finishedFiles()]);
  41.          addFinishedFiles();
  42. +        if (this->m_lastFileSkipped)
  43. +            QMetaObject::invokeMethod( this, "processFiles_TrackGain", Qt::QueuedConnection);
  44.      }
  45.  }
  46.  
  47. @@ -499,6 +516,7 @@ void QtGain::processFoundFiles(){
  48.          }
  49.  
  50.          setGUI_To(BUSY);
  51. +        this->m_lastFileSkipped = false;
  52.          isTrackGain() ? processFiles_TrackGain() : processFiles_AlbumGain();
  53.      } else {
  54.          setGUI_To(IDLE, tr("No media files found..."));
  55. --- a/src/QtGain.h
  56. +++ b/src/QtGain.h
  57. @@ -51,6 +51,7 @@ private:
  58.      QAction  *actionQuit;
  59.      QString m_Errorlog;
  60.      QString m_lastAlbumGainOutput;
  61. +    bool    m_lastFileSkipped;
  62.  
  63.      void startupInitiations();
  64.      void processOutput();
RAW Paste Data