mirror of
https://github.com/GoldenCheetah/GoldenCheetah.git
synced 2026-02-13 16:18:42 +00:00
Fix slow startup of Train View on Windows
The train view video/media list is constructed by attempting
to parse any file found in the workout directory. This was
a strategy to avoid missing files with odd extensions that
could be processed by VLC and also to avoid needing to
maintain a list of common extensions.
In practice, this was very slow to process and quite annoying.
VLC would load large volumes of DLLs and Codecs when trying
to parse.
In addition, the most common file types /by far/ are from
a relatively short list i.e; .mov, .avi, .mkv, .mp4 etc.
The strategy is now adjusted to search for a common list of
file types, namely;
3GP ASF AVI DIVX FLAC FLV M4V MKV MOV MP4 MPEG MPG
MXF Nut OGG OGM RM VOB WAV WMA WMV
The filename is checked without case sensitivity, i.e. files
will match regardless of whether they are in upper or lower
case (or combination of upper/lower).
This commit is contained in:
@@ -165,42 +165,55 @@ void VideoWindow::mediaSelected(QString filename)
|
||||
|
||||
MediaHelper::MediaHelper()
|
||||
{
|
||||
// config paramaters to libvlc
|
||||
const char * const vlc_args[] = {
|
||||
"-I", "dummy", /* Don't use any interface */
|
||||
"--ignore-config", /* Don't use VLC's config */
|
||||
"--extraintf=logger", //log anything
|
||||
"--verbose=-1" // -1 = no output at all
|
||||
};
|
||||
|
||||
/* Load the VLC engine */
|
||||
inst = libvlc_new(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args);
|
||||
}
|
||||
|
||||
MediaHelper::~MediaHelper()
|
||||
{
|
||||
// unload vlc
|
||||
libvlc_release (inst);
|
||||
}
|
||||
|
||||
QStringList
|
||||
MediaHelper::listMedia(QDir dir)
|
||||
{
|
||||
QStringList supported;
|
||||
QStringList returning;
|
||||
|
||||
// construct a list of supported types
|
||||
// Using the basic list from the VLC
|
||||
// Wiki here: http://www.videolan.org/vlc/features.html and then looked for
|
||||
// the common extensions used from here: http://www.fileinfo.com/filetypes/video
|
||||
supported << ".3GP";
|
||||
supported << ".ASF";
|
||||
supported << ".AVI";
|
||||
supported << ".DIVX";
|
||||
supported << ".FLAC";
|
||||
supported << ".FLV";
|
||||
supported << ".M4V";
|
||||
supported << ".MKV";
|
||||
supported << ".MOV";
|
||||
supported << ".MP4";
|
||||
supported << ".MPEG";
|
||||
supported << ".MPG";
|
||||
supported << ".MXF";
|
||||
supported << ".Nut";
|
||||
supported << ".OGG";
|
||||
supported << ".OGM";
|
||||
supported << ".RM";
|
||||
supported << ".VOB";
|
||||
supported << ".WAV";
|
||||
supported << ".WMA";
|
||||
supported << ".WMV";
|
||||
|
||||
// whizz through every file in the directory
|
||||
// and try and open it, if we succeed then huzzah
|
||||
// otherwise ignore it
|
||||
// if it has the right extension then we are happy
|
||||
foreach(QString name, dir.entryList()) {
|
||||
|
||||
libvlc_media_t *m = libvlc_media_new_path(inst, QString(dir.absolutePath() + "/" + name).toLatin1());
|
||||
|
||||
if (m) {
|
||||
|
||||
libvlc_media_parse(m);
|
||||
if (libvlc_media_get_duration(m) > 0) returning << name;
|
||||
libvlc_media_release(m);
|
||||
foreach(QString extension, supported) {
|
||||
if (name.endsWith(extension, Qt::CaseInsensitive)) {
|
||||
returning << name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return returning;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user