[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [k3b/2.0] src/rip: Rip audio tracks in ascending numerical order.
From: Johannes Obermayr <johannesobermayr () gmx ! de>
Date: 2014-09-28 1:23:18
Message-ID: E1XY3Co-00050S-Dx () scm ! kde ! org
[Download RAW message or body]
Git commit d81f9c8970634140486499598e8795ad3419109d by Johannes Obermayr, on behalf \
of Andrea Bocci. Committed on 11/05/2013 at 17:24.
Pushed by jobermayr into branch '2.0'.
Rip audio tracks in ascending numerical order.
K3B rips tracks in alphabetical target filename order, but ripping the first
track of a CD fails if it is not ripped first.
Workaround this problem by sorting ripping tracks in numerical order.
BUG: 319678
M +36 -1 src/rip/k3baudioripjob.cpp
http://commits.kde.org/k3b/d81f9c8970634140486499598e8795ad3419109d
diff --git a/src/rip/k3baudioripjob.cpp b/src/rip/k3baudioripjob.cpp
index 74d9060..97cbcba 100644
--- a/src/rip/k3baudioripjob.cpp
+++ b/src/rip/k3baudioripjob.cpp
@@ -30,6 +30,9 @@
#include "k3btrack.h"
#include "k3bglobals.h"
+#include <vector>
+#include <algorithm>
+
#include <QFile>
#include <QFileInfo>
#include <QHash>
@@ -55,6 +58,30 @@ namespace
K3b::AudioRipJob::Tracks const& m_tracks;
};
+ struct Task {
+ Task(K3b::AudioRipJob::Tracks::const_iterator const & it) :
+ tracknumber(it.value()),
+ filename (it.key()),
+ track (it)
+ { }
+
+ static
+ bool sort_by_filename(Task const & lhs, Task const & rhs)
+ {
+ return lhs.filename < rhs.filename;
+ }
+
+ static
+ bool sort_by_tracknumber(Task const & lhs, Task const & rhs)
+ {
+ return lhs.tracknumber < rhs.tracknumber;
+ }
+
+ int tracknumber;
+ QString filename;
+ K3b::AudioRipJob::Tracks::const_iterator track;
+ };
+
} // namespace
@@ -270,9 +297,17 @@ bool K3b::AudioRipJob::run()
emit infoMessage( i18n("Starting digital audio extraction (ripping)."), \
K3b::Job::MessageInfo );
+ // rip tracks in *numerical* order
+ std::vector<Task> tasks;
+ tasks.reserve( d->tracks.size() );
+ for (Tracks::const_iterator i = d->tracks.constBegin(); i != \
d->tracks.constEnd(); ++i ) + tasks.push_back( Task(i) );
+ std::sort(tasks.begin(), tasks.end(), Task::sort_by_tracknumber);
+
bool success = true;
QString lastFilename;
- for( d->currentTrack = d->tracks.constBegin(); d->currentTrack != \
d->tracks.constEnd(); ++d->currentTrack ) { + for( \
std::vector<Task>::const_iterator currentTask = tasks.begin(); currentTask != \
tasks.end(); ++currentTask) { + d->currentTrack = currentTask->track;
if( !ripTrack( d->currentTrack.value(), d->currentTrack.key(), lastFilename \
) ) { success = false;
break;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic