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.

This commit is contained in:
craig.p.drummond
2014-03-06 20:06:59 +00:00
committed by craig.p.drummond
parent 0d7b041348
commit 2016a8e62d
3 changed files with 9 additions and 2 deletions

View File

@@ -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
-----

View File

@@ -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...

View File

@@ -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());