Hello
I'm using the taglib library (1.7.2) in my Qt application, to read some metadatas of mp3 files from a music folder.
The problem is that I find it very slow.
For example, this is the code:
fileTypes << "*.mp3" ;
d.setNameFilters(fileTypes);
t.start();
foreach
(QString fileName, pathList
) { fileName = path + fileName;
TagLib::FileRef *f = new TagLib::FileRef(fileName.toStdWString().c_str());
}
qDebug()<<t.elapsed();
QString path = "C:/Music/";
QDir d(path);
QStringList fileTypes;
fileTypes << "*.mp3" ;
d.setNameFilters(fileTypes);
QStringList pathList = d.entryList( QDir::NoDotAndDotDot | QDir::Files);
QTime t;
t.start();
foreach (QString fileName, pathList) {
fileName = path + fileName;
TagLib::FileRef *f = new TagLib::FileRef(fileName.toStdWString().c_str());
}
qDebug()<<t.elapsed();
To copy to clipboard, switch view to plain text mode
This code takes about 11s to load a folder containing 400 songs, ie about 28ms for each file.
This is the line very slow:
TagLib::FileRef *f = new TagLib::FileRef(pathFile.toStdWString().c_str());
TagLib::FileRef *f = new TagLib::FileRef(pathFile.toStdWString().c_str());
To copy to clipboard, switch view to plain text mode
Is it normal it's so long ?
I've tried using multi threading, but it doesn't change anything, and it doesn't come from my PC, as it's enough powerful.
The weird thing is that once all the files have been loaded, the next time it load the folder again, it's done instantaneous (until i reboot the os).
----
I have also another problem.
Sometimes, when a tag is not set, the app crashes, and output:
HEAP[myapp.exe]:
Invalid address specified to RtlFreeHeap( 0ED90000, 0ED92CC0 )
On the following line for example:
if (!f->tag()->genre().isNull())
if (!f->tag()->genre().isNull())
To copy to clipboard, switch view to plain text mode
I'm using Windows 7.
Thanks.
Bookmarks