From 2016a8e62ddca2a8d5c7d153d48a845c4e5a0aea Mon Sep 17 00:00:00 2001 From: "craig.p.drummond" Date: Thu, 6 Mar 2014 20:06:59 +0000 Subject: [PATCH] When copying from a CD, check that we have enough space for track that was encoded with a 1:18 ratio. Just a sanity check really. --- ChangeLog | 2 ++ devices/actiondialog.cpp | 4 +++- devices/audiocddevice.cpp | 5 ++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 07eb6bca1..485161bee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -60,6 +60,8 @@ albums. 13. Fix calculating size of song files when copying off a device that has been previously scanned, and its contents cached. +14. When copying from a CD, check that we have enough space for track that was + encoded with a 1:18 ratio. Just a sanity check really. 1.3.1 ----- diff --git a/devices/actiondialog.cpp b/devices/actiondialog.cpp index d596af624..bcee27239 100644 --- a/devices/actiondialog.cpp +++ b/devices/actiondialog.cpp @@ -251,7 +251,9 @@ void ActionDialog::copy(const QString &srcUdi, const QString &dstUdi, const QLis #endif foreach (const Song &s, songsToAction) { quint32 size=s.size; - if (0==size) { + if (sourceIsAudioCd) { + size/=18; // Just guess at a compression ratio... ~18x ~=80kbps MP3 + } else if (0==size) { if (srcUdi.isEmpty()) { size=QFileInfo(MPDConnection::self()->getDetails().dir+s.file).size(); } else if (QFile::exists(dev->path()+s.file)) { // FS device... diff --git a/devices/audiocddevice.cpp b/devices/audiocddevice.cpp index cc6f9f936..c5ed1f5d0 100644 --- a/devices/audiocddevice.cpp +++ b/devices/audiocddevice.cpp @@ -336,6 +336,8 @@ void AudioCdDevice::copySongToResult(int status) } } +static const int constBytesPerSecond=44100*4; + void AudioCdDevice::setDetails(const CdAlbum &a) { bool differentAlbum=album!=a.name || artist!=a.artist; @@ -349,8 +351,9 @@ void AudioCdDevice::setDetails(const CdAlbum &a) disc=a.disc; update=new MusicLibraryItemRoot(); int totalDuration=0; - foreach (const Song &s, a.tracks) { + foreach (Song s, a.tracks) { totalDuration+=s.time; + s.size=s.time*constBytesPerSecond; update->append(new MusicLibraryItemSong(s, update)); } setStatusMessage(QString());