aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/Input/sndfile/decodersndfilefactory.cpp
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2018-06-09 21:00:38 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2018-06-09 21:00:38 +0000
commite9de5431a1a5e9d7808cae45c234bb5cb9fd473a (patch)
tree29809d99a1732a537c203b205b69b30b4d65dd2f /src/plugins/Input/sndfile/decodersndfilefactory.cpp
parentce79cbc21b6559f54d11da95fef7364616c3d872 (diff)
downloadqmmp-e9de5431a1a5e9d7808cae45c234bb5cb9fd473a.tar.gz
qmmp-e9de5431a1a5e9d7808cae45c234bb5cb9fd473a.tar.bz2
qmmp-e9de5431a1a5e9d7808cae45c234bb5cb9fd473a.zip
continue optimization, fixed memory leak
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@8008 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/Input/sndfile/decodersndfilefactory.cpp')
-rw-r--r--src/plugins/Input/sndfile/decodersndfilefactory.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/plugins/Input/sndfile/decodersndfilefactory.cpp b/src/plugins/Input/sndfile/decodersndfilefactory.cpp
index 55638b133..753cdb0d2 100644
--- a/src/plugins/Input/sndfile/decodersndfilefactory.cpp
+++ b/src/plugins/Input/sndfile/decodersndfilefactory.cpp
@@ -102,20 +102,25 @@ Decoder *DecoderSndFileFactory::create(const QString &, QIODevice *input)
QList<TrackInfo *> DecoderSndFileFactory::createPlayList(const QString &path, TrackInfo::Parts parts, QStringList *)
{
+ TrackInfo *info = new TrackInfo(path);
+
+ if(parts == TrackInfo::NoParts)
+ return QList<TrackInfo*>() << info;
+
SF_INFO snd_info;
SNDFILE *sndfile = 0;
- memset (&snd_info, 0, sizeof(snd_info));
+ memset(&snd_info, 0, sizeof(snd_info));
snd_info.format = 0;
#ifdef Q_OS_WIN
sndfile = sf_wchar_open(reinterpret_cast<LPCWSTR>(fileName.utf16()), SFM_READ, &snd_info);
#else
sndfile = sf_open(path.toLocal8Bit().constData(), SFM_READ, &snd_info);
#endif
- if (!sndfile)
+ if(!sndfile)
+ {
+ delete info;
return QList<TrackInfo *>();
-
- TrackInfo *info = new TrackInfo(path);
- info->setDuration(int(snd_info.frames * 1000 / snd_info.samplerate));
+ }
if(parts & TrackInfo::MetaData)
{
@@ -165,6 +170,7 @@ QList<TrackInfo *> DecoderSndFileFactory::createPlayList(const QString &path, Tr
format_info.format = (snd_info.format & SF_FORMAT_TYPEMASK);
sf_command(0, SFC_GET_FORMAT_INFO, &format_info, sizeof(format_info));
info->setValue(Qmmp::FORMAT_NAME, QString::fromLatin1(format_info.name));
+ info->setDuration(int(snd_info.frames * 1000 / snd_info.samplerate));
}
sf_close(sndfile);